Hello, I’m need to execte a custom query for getting data around a specific area, when I say area, I mean in terms of latitude and longitude, my dataset has these two fields and I would like to filter data by a specific area, I was wondering if this is possible and how it could be done, I am using the querying data specified in the documentation, so any help is welcome
Quering in a specific area using latitude and longitude
Well is always helpful to add a code snippet if you can, but answering your question , this should be easy if you already know the latitudes and longitudes that form a square in the area you need, and in order to do that kind of queries you have to use the bbox
filter and the location
property in your query like this example:
cf.provider('your_provider')
.source('your_source')
.fields([cf.Field("company"), cf.Field("payment_type")])
.location('location_field')
.bbox({
topLeft: {
lat: 41.8990,
lng: -87.6448
},
bottomRight: {
lat: 41.8836,
lng: -87.6050
}})
.limit(100)
.element(`dummy`)
.execute().then(data => console.log(data.data))
You just have to add the location
and bbox
properties in your query, and that should work, and also you can check the documentation for this feature here.
And just remember that the location
property could be a string with the geopoint field when using elasticsearch or an array with the latitude and longitude fields when using SQL providers
Thank you so much, it works good for me, i tried and it is perfect.
And, actually, my query looks similar to this one, but no worries, i got it, next time i will include my code