Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Sales search: Writing a query parser/AST using Pyparsing+Elasticsearch (part 2) (close.io)
8 points by thomas-st on May 5, 2013 | hide | past | favorite | 2 comments


I've seen many parsers, from ad-hoc regexes to real grammars like this one, that attempt to process natural, human-readable query strings that resemble Google searches. (The example at the top of this writeup, `john city:"new york" last_called < "3 days ago"`, illustrates what I'm talking about.) But there's no standard definition that I know of that could make all these slightly-different implementations interoperate.

Does anyone know of any specification of a colon-style query syntax that other projects could reuse? Even something semi-formal would be better than nothing.


Google "lucene query syntax"- it's pretty common. In fact, the only reason it seems they needed pyparsing (from the last article) instead of using Lucene syntax (which Elasticsearch supports) is to support more field operators like '>'.

EDIT: If you're a Python guy we've published a library to make generating such query strings easier - https://github.com/scholrly/lucene-querybuilder




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: