Documentation
¶
Overview ¶
Package qs is a query language parser for Bleve (http://www.blevesearch.com).
Example:
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")
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ParseError ¶
type ParseError struct { // Pos is the character position where the error occured Pos int // Msg is a description of the error Msg string }
ParseError is the error type returned by Parse()
func (ParseError) Error ¶
func (pe ParseError) Error() string
type Parser ¶
type Parser struct { // DefaultOp is used when no explict OR or AND is present // ie: foo bar => foo OR bar | foo AND bar // TODO: not sure AND/OR is the right terminology (but it's what others use) // Doesn't actually use OR or AND. AND is treated as an implied '+' prefix DefaultOp OpType // Loc is the location to use for parsing dates in range queries. // If nil, UTC is assumed. Loc *time.Location // contains filtered or unexported fields }
func (*Parser) Parse ¶
Parse takes a query string and turns it into a bleve Query.
Returned errors are type ParseError, which includes the position of the offending part of the input string.
BNF(ish) query syntax:
exprList = expr1* expr1 = expr2 {"OR" expr2} expr2 = expr3 {"AND" expr3} expr3 = {"NOT"} expr4 expr4 = {("+"|"-")} expr5 expr5 = {field} part {boost} part = lit {"~" number} | range | "(" exprList ")" field = lit ":" range = ("["|"}") {lit} "TO" {lit} ("]"|"}") relational = ("<"|">"|"<="|">=") lit boost = "^" number
(where lit is a string, quoted string or number)
Directories
¶
Path | Synopsis |
---|---|
bleve_queryparser - tool to parse and dump a query string to json for debugging.
|
bleve_queryparser - tool to parse and dump a query string to json for debugging. |
Click to show internal directories.
Click to hide internal directories.