The objective is to perform an Autocomplete type search on a field under Array of Objects:
"hashTags": [
{
"tag": "Smartwatch",
"position": 1
},
{
"tag": "Bluetooth",
"position": 2
}
]
i.e my autocomplete search should work on hashTags.tag path.
Already tried running Aggregate search query as below:
{
$search: {
index: 'hashtags',
autocomplete: {
path: 'hashTags.tag',
query: term,
},
},
}
And having created Search index in Mongo at supposed Collection as below:
{
"analyzer": "lucene.standard",
"searchAnalyzer": "lucene.standard",
"mappings": {
"dynamic": false,
"fields": {
"hashTags": {
"fields": {
"tag": {
"analyzer": "lucene.standard",
"type": "autocomplete"
}
},
"type": "document"
}
}
}
}
But no search result so far, mongo returns 0 results. Is autocomplete search even viable on Array of objects in MongoDb? Please guide if there could be any possible syntax issues while creating Search Index in Mongo.