Geoip distance query

Hello all,

Ive been taking a look at the geoip distance query and it seems to be working fine. However, I'm looking for help to only return the results that are not within my distance query. So in this case, any results that are not within the 100 miles of my coordinates.

I have tried complementing this with the must_not boolean and also the range query ( on the distance part) but no success

Here is query:

filter: {
"geo_distance" : {
"distance" : "100mi" {
"geoip.location": {
"lat" : 42,
"lon" : 60
}
}
}
}

Update:
using ES 5.6.1:

Found out there is a geo_distance_range filter that has been deprecated in 6.0

I believe that the must not should work. What is the full query at the end?

Thank you for the reply:
Here is the full query, again when I issue this query without the 'must_not' it returns the documents within the 100 miles. But I can't seem to return the results that are not within the 100 miles. Thank you

{
"query": {
    "bool" : {
        "must_not" : {
            "match_all" : {}
        },
        "filter" : {
            "geo_distance" : {
                "distance" : "100mi",
                "geoip.location" : {
                    "lat" : 40,
                    "lon" : -70
                }
            }
        }
    }
}

}

Please format your code using </> icon as explained in this guide. It will make your post more readable.

Or use markdown style like:

```
CODE
```

But you added match all in the must not clause. Why this?

Sorry about that, edited. I believe this is resolved. Here is updated query. Thank you!

"query": {
  "bool" : {
    "must_not" : {
          "geo_distance" : {
              "distance" : "100mi",
              "geoip.location" : {
                  "lat" : 40,
                  "lon" : -70
              }
          }
    }
  }
}

Does it work as expected with this query now?

If not, could you provide a full recreation script as described in

It will help to better understand what you are doing.
Please, try to keep the example as simple as possible.

Thanks for the heads up. And yes, query works great. GEOIP seems to be a bit inaccurate but it is only returning results outside of my mileage threshold set.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.