-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: FTS
-
Labels:
-
3
Description
In Tutorial: Create and Query an Atlas Search Index we provide an example that indexes an array, but do not explicitly call out that we are indexing an array. We have received a number of questions on how to index arrays using Atlas Search. So customers are not finding this example. We should add a section on how to index arrays using Atlas Search. For reference the following explanation was provided to customers, which they found helpful:
For example, in the sample_mflix database, movies contain a genres array. (Only showing title and genres to highlight that genres is an array of strings.)
{ "title" : "The Final Countdown", "genres" : [ "Action", "Sci-Fi" ] }
We then define an index on genres, once again focusing on the genres portion of the index definition:
"genres": { "type": "string", "analyzer": "lucene.standard" },
Note how the type is string and not array, array[string], string[], or some other syntax. We define the index as the data type of the array elements and do not have to specify that the data is contained in an array. The fact that it is an array is automatically detected and handled by MongoDB.