Hello,
I tried to create a first Atlas Search index with a “geo” type of field according to this syntax:
{
"mappings": {
"dynamic": true,
"fields": {
"LOKATION": {
"type": "geo"
} } } }
The index, incidentally, is named “geo4”.
The data in the underlying database contains about 1000 documents, each of which has the following structure (most fields omitted – content mainly cut+pasted from Compass JSON view of a document:
{
"_id": {
"$oid": "..."
},
"ID": 1,
"COLL": 0,
"GROUP": 0,
"INDUSTRY": "ABB",
<... other fields ...>,
"LOKATION": {
"type": "Point",
"coordinates": [{
"$numberDecimal": "12.071365000000000"
}, {
"$numberDecimal": "45.781243000000000"
}]
},
<... other fields ...>
}
I’ve tried many different queries (esp with “circle”), all returning 0 – the following is the last one, tried both from Compass and from the mongodb shell – the parameters may seem quite extreme, but I was trying to make sure I’d hit at least one document, as the one partially reported above:
[
{
'$search': {
'index': 'geo4',
'geoWithin': {
'box': {
'bottomLeft': {
'type': 'Point',
'coordinates': [
0, 0
]
},
'topRight': {
'type': 'Point',
'coordinates': [
90, 90
]
}
},
'path': 'LOKATION'
}
}
}
]
Note that from Atlas, the search index is shown to have 100% of documents indexed.
Note also that I have previously created a 2dsphere index on a previous version of the LOKATION field where the field was an Array of lon, lat values, as required – it worked just fine on the same data.
Anyone has a hint of what’s going wrong?
Thanks
stefano-