- Indexes >
- Indexing Tutorials >
- Text Search Tutorials >
- Create
textIndex to Satisfy thefilterComponent of Text Search
Create text Index to Satisfy the filter Component of Text Search¶
On this page
To perform a text search that also includes additional
query conditions, the text command provides a filter
option. A compound index can support the text search and the filter
condition, such that the operation does not need to scan any documents
to satisfy the filter condition; i.e. the returned text.stats
contain 0 for the nscannedObjects field.
Procedure¶
To create a text index that can fulfill the filter condition of
a text search:
Append scalar index fields to a
textindex, as in the following example which specifies an ascending index key oncited:Use the
filteroption in thetextto specify an condition on thecitedfield, as in the following:
Considerations¶
When creating a compound index with that includes the text index,
you cannot include multi-key index field
or geospatial index field.
With a compound index that includes the text index and an
ascending/descending key or keys, sort operations do not use the
ascending/descending key from this index; only the text score
determines the sort order.