- Tutorials >
- Text Search
Text SearchΒΆ
MongoDB provides text indexes to support text search queries on string content. Text indexes can include any field whose value is a string or an array of string elements.
To perform a text search with the Ruby driver, first create a text
index with indexes.create_one()
. The following command creates a
text index on the name
field of the restaurants
collection in
the test
database.
Once the text index is created you can use it as part of a query. The
following code finds all documents in the restaurants
collection
which contain the word garden
, without case sensitivity.