|
When creating a Search index, you can't use the dot syntax to access to a field in an object inside an array. For example, take the following document into consideration:
{
|
"movie": "Barbie",
|
"topReviews": [
|
{ "score": 10, "review": "I'm just Ken" }
|
]
|
}
|
If we want to create an index so we can search top reviews by text, it would be reasonable to try to define an index like this:
{
|
"mappings": {
|
"fields": {
|
"topReviews.review": {
|
"type": "string"
|
}
|
}
|
}
|
}
|
However, as review is an object inside an array of topReviews, this is not possible. We need to use the embeddedDocs type:
{
|
"mappings": {
|
"fields": {
|
"topReviews": {
|
"type": "embeddedDocument", "fields": { "review": { "type": "string" } }
|
}
|
}
|
}
|
}
|
The autocomplete should be aware of the type of the document tree so it doesn't autocomplete with invalid index definitions.
More documentation:
|