Geo spatial, large amount geo distance filter

Hi everyone,

I'm working around with ES and geospatial search.
I see a lot of exemple with this case :

  • 1person
  • looking for restaurant around with a distance

My case is a little bit different, in a different context, I can have something like 1k to 100k person.
So I tried something like this:

"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"or": {
"filters": [
{
"geo_distance": {
"distance" : "0.6km",
"pin": {
"lat": 48.853,
"lon": 2.35
}
}
},
{
"geo_distance": {
"distance" : "0.6km",
"pin": {
"lat": 48.853,
"lon": 2.35
}
}
}
]
}
}
}
}
}

But when you have a large set of geo_distance it's pretty difficult to construct and don't seem the way ES must working.
Moreover, if i want to combine this request with searching an other type, for example if an hotel has restaurant around with a distance and a person with a different distance, the request is not really pretty and take a lot of time.

actually all calculations of distance are made in back, and obviously it is not very efficient...

I'm trying to do all of this in one request. At this point I can select person, restaurant and hotel (each are a different type) but I have no idea what to do after. Playing with agg ?

Any advice ? At this point I don't know if my request is possible.

Have a nice day,
Stan

In your example, you're looking for items with a pin field within 0.6km of the same lat/lon in both filters;.

What are you trying to achieve?

Ah ye, just copy a bad example, the second pin location must be different from first.

I got some different type of point, ex pointA (pA), pointB(pB) and pointC(pC).
I try to achieve this:

I want all pA that are in range 0.6km to pB, and in range 0.8km to pC.
The problem is for a request, it is possible to have 30k pA, 30k pB, 30k pC.

To explain my exemple, I can have pA that are in range 0.6km of pB. But as I said, if I have 30k pB, I must give every pB pin location.

Do you think, it is possible to achieve this in one request ?

I did an other exemple

 GET _search
 {
   "size": 0,
   "aggs": {
     "has_pointB": {
       "filter" : {
         "bool" : {
           "must" : {
               "term" : { "_type" : "pointB" }
           },
           "filter" : {
               "geo_distance" : {
                   "distance" : "10km",
                   "pin" : {
                       "lat" : 41.390487,
                       "lon" : 2.170532
                   }
               }
           }
         }
       }
     },
     "has_pointC": {
       "filter" : {
         "bool" : {
           "must" : {
               "term" : { "_type" : "pointC" }
           },
           "filter" : {
             "geo_distance" : {
                 "distance" : "10km",
                 "pin" : {
                     "lat" : 41.390487,
                     "lon" : 2.170532
                 }
             }
           }
         }
       }
     }
   }
 }

Coordinate s in location are pointA location. With doc_count in aggs, I can know if I have pointB and poinC around my pointA.

The second part is now to get do a request to have all my pointA doing this request.
I will update if I find something interesting.