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.

The string type doesn't support all MongoDB Search features for string fields. Index the string field as a token to:

  • Run a facet query on string fields.

  • Sort the MongoDB Search results by string fields.

  • Find an exact match for queries using equals, in, and range operators.

The MongoDB Search dynamic mappings with the default typeSet only indexes string fields as string types. Specify a custom typeSet to dynamically index strings as token or autocomplete to use their supported features.

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