LambdaDB supports a simple string query that uses the Lucene Query Syntax to search documents.
This gives queryString access to expressive lexical search features such as terms, phrases, wildcards, boolean operators, range operators, proximity search, regular expressions, fuzzy term matching, term boosting, minimum-should-match constraints, interval functions, and special character escaping.
Supported syntax highlights
| Feature | Example | Use it to |
|---|
| Term search | hello | Match documents containing a term. |
| Phrase search | "hello world" | Match an exact phrase. |
| Field search | title:LambdaDB | Target a specific field. |
| Boolean logic and grouping | title:database AND (serverless OR managed) | Combine required, optional, and excluded clauses. |
| Wildcards | vector* | Match terms by prefix or pattern. |
| Proximity search | "serverless database"~4 | Match words that occur near each other. |
| Regular expression | /vec(tor|tors)/ | Match terms using a regular expression. |
| Fuzzy term matching | lambdadb~2 | Match terms within an edit distance. |
| Range query | created_at:[2024-01-01T00:00:00Z TO *] | Match numeric, datetime, or keyword ranges. |
| Term boosting | database^2 OR storage^0.5 | Increase or decrease the relevance weight of clauses. |
| Minimum should match | (semantic vector keyword)@2 | Require at least N optional clauses to match. |
| Interval function | fn:ordered(serverless vector database) | Express ordered or positional relationships between terms. |
Parameters
| Parameter | Description | Type | Required | Default |
|---|
| query | Query string | string | ✓ | |
| defaultField | Default field name to apply query | string | | |
| skipSyntax | Skip syntax check for special characters | boolean | | false |
A query to a collection with object field type requires special handling.
Examples
Basic query
{
"queryString": {
"query": "hello world",
"defaultField": "text"
}
}
When multiple terms are separated by spaces, each term is treated as an optional clause on the defaultField.
The above example is equivalent to:
{
"queryString": {
"query": "text:hello OR text:world"
}
}
You can also query multiple fields by specifying field names in the query string. Terms are separated by spaces, and specific fields are targeted using the field:value syntax:
{
"queryString": {
"query": "hello world keyword:python",
"defaultField": "text"
}
}
Exact keyword match
Use a keyword field when you want to match a literal value instead of analyzed text.
{
"queryString": {
"query": "python",
"defaultField": "keyword"
}
}
If the keyword contains spaces or query syntax characters, wrap the value in double quotes ("):
{
"queryString": {
"query": "\"hello world\"",
"defaultField": "keyword"
}
}
For raw literal values that include special characters, you can also use the skipSyntax option:
{
"queryString": {
"query": "https://sample_url.com",
"defaultField": "keyword",
"skipSyntax": true
}
}
Alternatively, quote the literal value:
{
"queryString": {
"query": "\"https://sample_url.com\"",
"defaultField": "keyword"
}
}
Phrase search
On analyzed text fields, wrap terms in double quotes (") to search for an exact phrase.
{
"queryString": {
"query": "\"serverless database\"",
"defaultField": "content"
}
}
Proximity search
Use proximity search to match phrase terms that appear near each other, even when they are not adjacent.
The number after ~ controls the maximum distance between phrase terms.
{
"queryString": {
"query": "\"serverless database\"~4",
"defaultField": "content"
}
}
Regular expression query
Wrap a regular expression in forward slashes (/) to match terms by pattern.
{
"queryString": {
"query": "/vec(tor|tors)/",
"defaultField": "content"
}
}
Fuzzy term matching
Use ~ after a term to match terms within an edit distance.
This is useful for typos, spelling variants, and noisy text.
{
"queryString": {
"query": "lambdadb~2",
"defaultField": "content"
}
}
Term boosting
Use ^ to increase or decrease the relevance weight of a term, phrase, range expression, or grouped clause.
{
"queryString": {
"query": "database^2 OR storage^0.5",
"defaultField": "content"
}
}
You can also boost a grouped sub-query:
{
"queryString": {
"query": "title:(serverless OR managed)^2.5 OR content:database"
}
}
Minimum should match
Use the minimum-should-match operator (@) on a disjunction group to require at least the specified number of optional clauses to match.
{
"queryString": {
"query": "(semantic vector keyword)@2",
"defaultField": "content"
}
}
Interval function
Use interval functions with the fn: prefix to express ordered or positional relationships between terms.
{
"queryString": {
"query": "fn:ordered(serverless vector database)",
"defaultField": "content"
}
}
You can target a field and combine interval functions:
{
"queryString": {
"query": "title:fn:maxwidth(5 fn:atLeast(2 serverless vector database))"
}
}
Range query
Range queries allow you to search for values within a specific range using range query syntax.
Supported field types
Range queries work with the following field types:
long
double
datetime
keyword
Syntax
- Inclusive range:
[min TO max] includes both lower and upper bounds.
- Exclusive range:
{min TO max} excludes both lower and upper bounds.
{
"queryString": {
"query": "[123 TO 456]",
"defaultField": "long"
}
}
{
"queryString": {
"query": "{2024-03-10T09:15:45Z TO 2024-03-10T09:15:46Z}",
"defaultField": "datetime"
}
}