Find data with lexicographical matching
Hybrid search, lexical search, and reranking are currently in public preview. Development is ongoing, and the features and functionality are subject to change. Astra DB Serverless, and the use of such, is subject to the DataStax Preview Terms. |
You can use lexicographical matching to find documents in collections and rows in tables.
Use lexicographical matching with the Data API
-
Collections
-
Tables
There are two ways to use lexicographical matching to find documents with the Data API:
-
Sort on the
$lexical
field to find the documents whose$lexical
field value is most relevant to a given string of space-separated keywords or terms -
Filter on the
$lexical
field with the$match
operator to find the documents whose$lexical
field value is a lexicographical match to the specified string of space-separated keywords or terms
You can use these strategies together or separately.
You can only use lexicographical matching on collections that have lexical enabled. For more information, see Create a collection that supports lexicographical matching.
Documents must have the $lexical
field populated to be included in lexicographical matching.
For examples, see Insert a document for retrieval with lexicographical matching and Insert documents for retrieval with lexicographical matching.
There are two ways to use lexicographical matching to find rows with the Data API:
-
Sort to find rows with a
text
orascii
column value that is most relevant to a given string of space-separated keywords or terms. -
Filter with the
$match
operator to find rows with atext
orascii
column value that is a lexicographical match to the specified string of space-separated keywords or terms
You can use these strategies together or separately.
Lexicographical matching is only available for text
or ascii
columns that have a text index, not a regular index.
For more information, see Create a text index and Indexes in tables.