Search the FirstSpirit Knowledge Base
Hello community,
has anybody experience in generating and using a geospatial-index inside of the CaaS and want to share?
Usecase:
We store the data (address, opening times, location, latitude, longitude,...) of our branch-offices inside the Caas and our mobile app consumes the data. Now there should be some kind of proximity search to get the next X offices around my current location.
We expanded our data and stored a GeoJson-Object additionally, but now the big question is, how to generate the geospatial-index. Helpdesk says, basically the Rest-Api leverages MongoDB's geospatial support but we have currently no Idea, how to start generating the index.
Any ideas to that out there ?
Thanks in advance for any suggestion,
Best regards,
Marco
Kind regards,
Nico
Kind regards,
Nico
Hi @MBischof ,
did the answer from @NMc help? If not I might suggest a slightly different payload for the curl request:
curl --location --request PUT 'https://${customer}-${stage}caas-api.e-spirit.cloud/${tenant-id}/${project-uuid}.preview.content/_indexes/my-geospatial-index' \
--header 'authorization: apikey="*****************"' \
--header 'Content-Type: application/json' \
--data-raw '{
"keys": {
"<fieldname>": "2dsphere"
}
}'
Based on these resources:
Would love to get some feedback if your issue could be solved.
Best regards, Chris
HI @NMc,
thanks for your reply. Based on your suggestions we found a working solution for us.
The basic things like the data-structure (Geo-Json Object) were correct before, the missing thing was to use a PUT-Statement to create the index over the correct field. Once this was done, getting the correct data with a $near-Operator was easy...
So again thanks for you help and best regards,
Marco