Parse and serialize ElasticSearch search query strings.
This package allows to parse an elastic simple query string into an AST.
Notes:
~N operator is not supported.type AST
= And AST AST
| Or AST AST
| Exclude AST
| Exact String
| Word String
| Prefix StringIn our case, to follow the production rules AST will be Expr
type Expr
= And Expr Expr
| Exact String
| Exclude Expr
| Or Expr Expr
| Prefix String
| Word StringUnless explicitly indicated, spaces are ignored.
Query => ORExpr EOF
ORExpr => ANDExpr | ANDExpr "|" ORExpr
ANDExpr => EXCExpr | EXCExpr ("+"|\s+) ANDExpr
EXCExpr => "-" GRPExpr | GRPExpr
GRPExpr => WORD~"\*" | WORD | \" EXACTExpr \" | "(" ORExpr ")"
EXACTExpr => [^"]+big* (potatoes|"french fries") -salad