Skip to content

Latest commit

 

History

History
78 lines (54 loc) · 1.99 KB

File metadata and controls

78 lines (54 loc) · 1.99 KB

Query Syntax

The zombodb query syntax is modeled after standard SQL with many conveniences for perform text-search operations.

An example query might look like:

    beer wine cheese w/3 food

Which would find all documents that contain the words beer and wine and occurrences of cheese within 3 words of food, regardless of the field (or fields) that contain each word.

The zombodb query syntax provides support for searching (in no particular order):

  • words
  • phrases
  • out-of-order phrases
  • fuzzy words
  • proximity (of word or phrase or combinations)
  • full boolean operators (AND, OR, NOT)
  • value ranges
  • wildcards (left, middle, and right truncation)

Boolean expressions and operator precedence

The supported set of boolean operators are the standard NOT, AND, and OR operators. If no operator is declared between terms, AND is assumed. Additionally, parenthetical groupings are allowed to form complex boolean expressions.

It is important to understand the operator precedence. NOT takes the highest priority, followed by AND, then finally OR.

For example, this query finds all documents which contain both beer AND cheese plus any documents that contain wine:

    wine or beer and cheese

It is functionally equivalent to this query:

    wine or (beer and cheese)

Whereas, this query finds all documents which contain both beer AND cheese but NOT food, plus any documents that contain wine:

    wine or beer and cheese not food

It is functionally equivalent to this query:

    wine or (beer and (cheese not food))

For convenience, each boolean operator has a single-character abbreviation:

  • AND: &
  • OR: ,
  • NOT: !

So taking the example above, it could be rewritten as:

    wine, beer & cheese !food

And since the AND operator is the default, it could also be written as:

    wine, beer cheese !food