qs implements a query language for the Bleve text indexer library.
The query syntax is aiming to be about the same as those used by Lucene and Elasticsearch.
The full syntax is described in syntax.md.
import "github.com/bcampbell/qs"
query, err := qs.Parse("grapefruit lemon orange lime")
Or, to create a parse which uses AND as the default operator:
p := qs.Parser{DefaultOp: qs.AND}
query,err := p.Parse("grapefruit lemon orange lime")
Documents containing the term grapefruit
:
grapefruit
There is support for boolean AND, OR and NOT:
grapefruit OR lemon
grapefruit AND lemon
grapefruit AND NOT lemon
Phrases are indicated with quotes:
"navel orange"
The default boolean operator is OR, so these two are equivalent when using the default parser:
grapefruit lemon
grapefruit OR lemon
Fields:
tags:citrus
headline:"How to Make the Perfect Negroni"
Grouping:
(lemon AND lime) OR (orange AND grapefruit)
Boosting term relevance:
fruit grapefruit^2
Inclusive ranges in square brackets, Exclusive ranges in curly brackets:
date:[2012-01-01 TO 2012-12-31]
count:{0 TO 100}
Wildcard markers *
(any character sequence, 0 or more) and ?
(any single character)
eg to match foot
, fort
, fret
etc:
f??t
eg to match ant
, anteater
, antidisestablishmentarianism
etc:
ant*