Docs Menu
Docs Home
/ /

How to Index String Fields

Use the MongoDB Search string type to index string fields. Use the MongoDB Search phrase, querystring, span, text, wildcard, regex, and moreLikeThis operators to query fields indexed as the string type.

You can't use the MongoDB Search string type to index fields for facet or autocomplete operator queries. You can't use the string type to index fields for sorting MongoDB Search results. Instead, you must use static mappings to index the string fields as the following types:

  • stringFacet type to run a facet operator query on string fields. Note that MongoDB Search doesn't dynamically index string fields for faceting.

  • autocomplete type to run autocomplete operator queries on string fields. Note that MongoDB Search doesn't dynamically index string fields for autocompletion.

  • token type to sort the MongoDB Search results by the string field. MongoDB Search doesn't dynamically index string fields for sorting the results.

  • token type to find an exact match for queries using equals, in, and range operators. MongoDB Search doesn't dynamically index string fields as token type for querying using these operators.

Important

MongoDB Search won't index string fields where analyzer tokens exceed 32766 bytes in size. If using the keyword analyzer, string fields which exceed 32766 bytes will not be indexed.

Back

objectId

On this page