Skip to content

Query Syntax

Nikita Ganzikov edited this page Jan 6, 2026 · 2 revisions

Query Syntax

Bright uses Bleve's query string syntax, which provides powerful search capabilities.

Basic Queries

Simple Term

Search for a single term across all fields:

hello

Phrase Search

Search for an exact phrase:

"hello world"

Field-Specific Search

Search in a specific field:

title:hello
author:"John Doe"

Boolean Operators

AND

Both terms must be present:

hello AND world

OR

At least one term must be present:

hello OR world

NOT

Exclude documents containing the term:

hello NOT world

Grouping

Use parentheses for complex queries:

(hello OR hi) AND world
title:(quick OR fast) AND status:published

Wildcards

Single Character (?)

Match any single character:

te?t
# matches: test, text, tent

Multiple Characters (*)

Match zero or more characters:

test*
# matches: test, testing, tester

*ing
# matches: testing, running, walking

te*t
# matches: test, text, tenant

Fuzzy Search

Find similar terms with edit distance:

hello~1
# matches: hello, hallo, hellow (1 edit away)

hello~2
# matches: hello, hallo, helo, hell (up to 2 edits)

Range Queries

Numeric Ranges

price:>100
price:>=100
price:<50
price:<=50
price:[10 TO 100]

Date Ranges

created:[2024-01-01 TO 2024-12-31]
updated:>2024-06-01

String Ranges

name:[a TO m]

Boosting

Increase the relevance of certain terms:

title:laptop^2 description:laptop
# title matches are twice as important

Regex Search

Use regular expressions (prefix with /):

/joh?n(ath[oa]n)/

Special Characters

To search for special characters, escape them with \:

hello\:world
# searches for literal "hello:world"

Special characters that need escaping:

+ - = && || > < ! ( ) { } [ ] ^ " ~ * ? : \ /

Tips

  1. Default Operator: If no operator is specified, OR is used

    • hello world = hello OR world
  2. Field Search: Prefix the term with field name

    • title:hello searches only in the title field
  3. Fuzzy Matching: Use ~ for typo tolerance

    • Good for user-generated search queries
  4. Wildcards: Use sparingly as they can be slow

    • Avoid leading wildcards (*term) when possible
  5. Phrase Search: Use quotes for exact matches

    • "exact phrase" vs individual words

Reference

For complete documentation, see Bleve Query String Query Documentation.

Clone this wiki locally