Parse and serialize ElasticSearch search query strings.
This package allows to parse an elastic simple query string into an AST, and serialize string search queries out of it.
Notes:
\r
, \n
and \t
characters will be considered as blank spaces.An ElasticSearh expression.
parse : String -> Result (List Parser.DeadEnd) Expr
Parse an ElasticSearch search query string and convert it into an
Expr
.
serialize : Expr -> String
Serialize an Expr
to an ElasticSearch query string.
Note: Operator precedence will be enforced by the use of parenthesis groups everywhere applicable. That also means this function might act as a formatter as well as a sanitizer:
> " a b |c d " |> parse |> Result.map serialize
Ok ("(a b) | (c d)") : Result (List Parser.DeadEnd) String