I tried using the near operator to find company near certain coordinates however I am not receiving any documents.
The query i am using:
I created the index also. Like that:
{
“mappings”: {
“dynamic”: false,
“fields”: {
“about”: {
“analyzer”: “lucene.standard”,
“type”: “string”
},
“address”: {
“fields”: {
“location”: {
“indexShapes”: true,
“type”: “geo”
}
},
“type”: “document”
},
“keywords”: {
“analyzer”: “lucene.standard”,
“type”: “string”
},
“name”: {
“analyzer”: “lucene.standard”,
“type”: “string”
}
}
}
}
I also created this:
Also my schema:
The $geoNear is working in the aggregation and i am getting the correct documents, however as you can see in the aggregation query, i need to do a search on other fields also.
Because $geoNear needs to be the first stage in the aggregation pipeline i cannot do a $search with fuzzy on other fields like ‘name’, because the $search also needs to be the first stage in the aggregation pipeline. SO i cannot use $geoNear and $search in the same aggregation pipeline.
This is where the near operator comes in. However even though it is the correct syntax i am not getting any documents. The above aggregation pipeline uses the near operator.
What am I missing here?