How to Index Fields in Objects and Documents
On this page
You can use the Atlas Search document
type to index fields in objects or
documents.
If you enable dynamic mappings, Atlas Search
automatically indexes fields of type document
. You can
use the Visual Editor or the JSON Editor in the Atlas UI to
index fields as the document
type.
Review document
Type Limitations
You can't use the Atlas Search document
type to index fields in objects or
documents that are inside an array. Instead, use the Atlas Search
embeddedDocuments type to
index fields in objects or documents that are elements of an array.
Define the Index for the document
Type
To define the index for the document
type, choose your preferred
configuration method in the Atlas UI and then select the
database and collection.
Configure document
Field Properties
The Atlas Search document
type takes the following parameters:
Option | Type | Necessity | Description | Default |
---|---|---|---|---|
type | string | Required | Human-readable label that identifies the field type.
Value must be document . | |
dynamic | boolean | Optional | Flag that indicates whether Atlas Search recursively indexes all fields
and embedded documents. If set to To index all fields in a document including fields that Atlas Search doesn't dynamically index, define the fields in the index definition. If omitted or set to ImportantAtlas Search dynamically indexes all fields in a | false |
fields | document | Optional | Document that maps field names to field definitions. To learn
more, see an example. This is
required if dynamic is omitted or set to false . |
Try an Example for the document
Type
The following index definition example uses the sample_mflix.movies collection. If you have the sample data already loaded on your cluster, you can use the Visual Editor or JSON Editor in the Atlas UI to configure the index. After you select your preferred configuration method, select the database and collection, and refine your index to add field mappings.
The index definition indexes the awards
field as the document
type. It also configures Atlas Search to automatically index all the
dynamically indexable fields inside the awards
object.