Indexing Text/JSON Expressions
The following statement indexes an expression which concatenatesdescription and category, which are both text fields:
- Add the expression to the column list. In this example, the expression is
description || ' ' || category. - Cast it to a tokenizer, in this example
pdb.simple. - ParadeDB will try and infer a field name based on the field used in the expression. However,
if the field name cannot be inferred (e.g. because the expression involves more than one field), you will be required
to add an
alias=<alias_name>to the tokenizer.
The expression on the left-hand side of the operator must exactly match the
expression that was indexed.
Indexing Non-Text Expressions
To index a non-text expression, cast the expression topdb.alias. For example, the following statement indexes
the expression rating + 1, which returns an integer:
A current limitation is that the alias name must be the same as the field
inside the expression in order for the index to be used at query time. For
example, the statement above uses
rating as the alias name.