Query parser
hypha.apply.search.query_parser
¶
parser
module-attribute
¶
parser = Lark('\n ?start: expression\n\n expression: (filter_expression | search_term)*\n filter_expression: string FILTER_COLON string\n | string FILTER_COLON ESCAPED_STRING\n | FILTER_HASH NUMBER\n search_term: string\n filer_value: string\n | ESCAPED_STRING\n\n string: /[^:#\\s]+/\n\n FILTER_COLON: ":"\n FILTER_HASH: "#"\n\n %import common.NUMBER\n %import common.ESCAPED_STRING\n %ignore /\\s+/\n', start='start', parser='lalr', transformer=QueryTransformer())
QueryTransformer
¶
tokenize_date_filter_value
¶
Convert a date filter string into a list of tokens.
Format: [operator][year][-[month]-[day]] The tokens are: - The operator (>=, <=, >, <) (if present) - The year - The month (if present) - The day (if present)
Source code in hypha/apply/search/query_parser.py
parse_search_query
¶
Parses Gmail-like search query string into a dictionary of filters and the remaining text. Example: "from:johndoe@example.com to:janedoe@example.com subject:hello world #12" would be parsed into: { "filters": { "from": ["johndoe@example.com"], "to": ["janedoe@example.com"], "subject": ["hello", "world"], "id": ["12"] }, "text": "hello world" }
Source code in hypha/apply/search/query_parser.py
|