How to perform a keyword search
To perform a keyword search on your documents, use thematch()
function.
In the following example we’ll:
- Create a collection with a
title
anddescription
text fields and add a keyword index to both of them. - Run a keyword search on the
title
anddescription
fields using thematch()
function.
Define a collection schema
Let’s create a collection with atitle
and description
text fields and add a keyword index to both of them:
Run a keyword search
Now, let’s run a keyword search on thetitle
and description
fields using the match()
function.
We’ll query the collection to match the term "great"
in the title
field or the term "novel"
in any of the keyword-indexed text fields:
The
match()
function will by default execute against all
fields with a keyword index.