SKEG · REFERENCE

Payload fields and filters

Look up payload types, filter syntax, ranges and which rows NOT can match.

Skeg 0.8 · Development documentation

Use SKEG.VSEARCH ... FILTER <expression> to determine which rows in the selected tenant and index are eligible for a search. Pass the complete expression as one UTF-8 argument. See search with payloads and filters for a worked example, or the vector API for the command and reply formats.

Payload encoding and types

Skeg stores the original payload bytes. To index fields, it decodes the whole payload as UTF-8, splits it on whitespace, and splits each token at its first =. It skips tokens without = and tokens with an empty field name. A payload with invalid UTF-8 contributes zero indexed fields. The write can still store the blob, and WITHPAYLOAD returns its original bytes.

Payload token or tokensIndexed values
lang=itKeyword it in field lang
year=2025Integer 2025 in field year
code=007Integer 7 in field code
code=id-007Keyword id-007 in field code
rating=4.5Keyword 4.5 in field rating
tag=guide tag=apiKeywords guide and api in field tag
tag=An empty keyword in field tag
free textNo fields

Each token value that parses as a signed 64-bit integer is indexed as an integer. All other values are indexed as keywords, including decimals and integers outside that range. A field can contain values of different types. Field names and keyword values are case-sensitive.

Matching rules

PredicateA row matches whenExample
field = valueA value for the field equals the typed operandlang = it
field IN (value, ...)A value for the field equals any operand in the listlang IN (it, en)
field >= value, >, <=, <A value for the field satisfies the comparisonyear >= 2024
field BETWEEN low AND highA value for the field is within both bounds, inclusiveyear BETWEEN 2024 AND 2025
field EXISTSThe field has an indexed value, including an empty keywordtag EXISTS

Equality and range operands use the same integer-or-keyword rule as stored values. For example, code = 007 and code = 7 compare against the same integer. An unknown field matches no rows in these predicates. To make an empty state queryable by equality, store an explicit keyword such as source=unknown. The expression grammar has no empty-value literal.

On a multi-valued field, each predicate is satisfied by any matching value on the row. A row with tag=guide tag=api matches tag = guide AND tag = api because the two predicates can match different values. A single BETWEEN predicate requires one value within both bounds.

Range ordering

Keywords are ordered lexicographically and come before all integers. Integers are ordered numerically. Use ascending bounds of the same type and keep field types consistent across rows. For example, if year contains the keyword unknown on some rows, year < 2024 can match those rows because keywords sort before integers.

Negation and rows without indexed fields

NOT complements its operand among rows with at least one indexed field. A missing field can match a negated predicate when another field puts the row in that set.

RowPayloadMatches NOT lang = itMatches NOT lang EXISTS
1lang=itNoNo
2lang=enYesNo
3category=guideYesYes
4No payloadNoNo
5free textNoNo

This table shows eligibility. An approximate search plan can return only some eligible rows. To query the absence of an attribute across every document, store an explicit state on every row.

Expression grammar

Operator words are case-insensitive. Precedence goes from NOT to AND to OR. Use parentheses to group predicates. The AND inside BETWEEN separates the bounds, and an IN list requires at least one value.

In this grammar, | separates alternatives, braces denote repetition, and quoted text denotes literal syntax.

expression = or_expression
or_expression = and_expression { "OR" and_expression }
and_expression = not_expression { "AND" not_expression }
not_expression = "NOT" not_expression | atom
atom = "(" expression ")" | predicate
predicate = field "=" value
          | field "IN" "(" value { "," value } ")"
          | field ( ">=" | ">" | "<=" | "<" ) value
          | field "BETWEEN" value "AND" value
          | field "EXISTS"

An empty or malformed expression returns an error. Check for missing operands, unbalanced parentheses and trailing tokens.

Names, values and quoting

Whitespace and the characters (, ), ,, =, < and > separate tokens. AND, OR, NOT, IN, BETWEEN and EXISTS are reserved regardless of case. Choose field names and keyword values that avoid these separators and reserved words.

Use shell quotes to send the entire expression in one argument, as in FILTER "lang = it". Quotes inside that argument are ordinary characters. For example, in lang = 'it', the apostrophes are part of the keyword and the predicate does not match lang=it. Use a single token for each searchable value and keep display text separately.

Supported scope

The filter language operates on flat keyword and integer fields. JSON paths, nested objects, floating-point fields, geographic predicates, full-text matching and the != operator are outside that grammar. Use NOT for negation with the eligibility rules above.

Use tenant authentication to control access. A payload predicate only narrows a search within the caller’s index.