0

I have the following scenario: I have an index with all possible ads of my platform. These ads contain an object with coordinates (latitude/longitude).

{
  "id": "123",
  "slug": "my-ad-slug",
  "location": {
    "coordinates": {
      "latitude": 1.123456,
      "longitude": 1.987654
    }
  }

I also have another index with some locations and their polygons and shapes for geolocation searches.

{
  "id": "456",
  "name": "my location",
  "geo_location": {
    "type": "Polygon",
    "coordinates": [...]
  }
}

My question is: how can I query all ads that are within a certain polygon, since I have two different indexes in this case? Do you see an easy way on doing so?

Thanks y'all!

Kiwanax
  • 1,265
  • 1
  • 22
  • 41
  • Yes, you can do it as explained in this thread provided that `location` is of type `geo_point` (which I don't think it is in your case): https://stackoverflow.com/a/42249514/4604579 – Val May 23 '22 at 13:38
  • Thanks, @Val, but my case is slightly different. I want to match the on my `ads` index, under `location.coordinates` path to a boundary within `locations`, under `geo_location`. The query is not allowing me to move forward nor compare both data. – Kiwanax May 24 '22 at 08:58
  • If you have your shapes correctly indexed in index A, then you can use them in queries on index B – Val May 24 '22 at 09:00

0 Answers0