Skip to main content

Full-text search finds documents that contain the words of your query. Semantic search finds documents with a similar meaning, even when they use different words. Hybrid search runs both and merges the results into one list.

Hybrid search has two parts:

  • HYBRID fields are indexed for both full-text and semantic search.
  • Retrievers run the searches. $ann runs a semantic search, and $rrf merges the results of several retrievers into one list.

Hybrid fields#

A HYBRID field is a TEXT field that also stores a vector embedding. Full-text queries work on it the same way as on a TEXT field, and $ann searches its embeddings by meaning. See Hybrid Fields for the field options.

  • An index can have more than one HYBRID field.
  • If the text of a document cannot be embedded, the document is still searchable by its text.
  • HYBRID fields work with JSON, hash, string, and stream indexes.

Create an index#

Declare the fields you want to search by meaning as HYBRID:

Add documents#

Write documents as usual. Search indexes them and creates their embeddings:

Search by meaning#

Use $ann to find the documents that are closest in meaning to a text. This query can find the earplugs, even though their description does not contain the word “noise”:

Use $rrf to run a full-text query and a semantic search, and merge their results into one list. Documents that rank high in both come first:

To give one side more influence, set its weight. A full-text query takes a weight when you wrap it in $standard:

Next steps#