How to Index String Fields For Faceted Search
On this page
You can use the Atlas Search stringFacet
type to index string fields for faceting, which allows you
to run a facet query on that field. Atlas Search doesn't apply the analyzer
when indexing string
fields for faceting.
Atlas Search only supports facet queries against fields
indexed as the stringFacet
type. To perform a normal search also
on the same field, you must index the field as type string
also.
Atlas Search doesn't dynamically index
string
values for faceting. You must use static
mappings to index string
values for
faceting. You can use the Visual Editor or the JSON Editor in
the Atlas UI to index date fields as the stringFacet
type.
Define the Index for the stringFacet
Type
To define the index for the stringFacet
type, choose your preferred
configuration method in the Atlas UI and then select the
database and collection.
Configure Properties for the stringFacet
Type
The Atlas Search stringFacet
type has the following parameters:
UI Field Name | JSON Option | Type | Necessity | Description |
---|---|---|---|---|
Data Type | type | string | Required | Human-readable label that identifies this field type.
Value must be stringFacet . |
Try an Example for the stringFacet
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.