Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An extra field geo_box is added to the query. #146

Open
berkes opened this issue Apr 25, 2020 · 1 comment
Open

An extra field geo_box is added to the query. #146

berkes opened this issue Apr 25, 2020 · 1 comment

Comments

@berkes
Copy link

berkes commented Apr 25, 2020

I'm not sure if I understand the code correct, so I may be using it all wrong.

I'm trying to implement a geo bounding box on a field called coord.

let bbox = Query::build_geo_bounding_box("coord", ((50.5, -10.5), (50.0, -10.0))).build();
let query = Query::build_bool().with_filter(bbox).build();

let mut search_query = rubber.es_client.search_query();

let search_query = search_query
        .with_ignore_unavailable(true)
        .with_query(&query);

let result = search_query.send()?;

This fails with an error from ES:

 "failed to parse [geo_bbox] query. unexpected field [geo_box]"

Probably, because there is no field geo_bbox. Examining the JSON sent to ES gives me:

{
  "query": {
    "bool": {
      "filter": {
        "geo_bounding_box": {
          "coord": {
            "geo_box": {
              "bottom_right": {
                "lat": 50,
                "lon": -10
              },
              "top_left": {
                "lat": 50.5,
                "lon": -10.5
              }
            }
          }
        }
      }
    }
  }

The offending extra geo_box is nested in coords.

The correct JSON, If I understand the ES2 Bounding box DSL correctly, should be:

{
  "query": {
    "bool": {
      "filter": {
        "geo_bounding_box": {
          "coord": {
            "bottom_right": {
              "lat": 50,
              "lon": -10
            },
            "top_left": {
              "lat": 50.5,
              "lon": -10.5
            }
          }
        }
      }
    }
  }

I'm not sure where that extra geo_bbox comex from, and if it is configurable. From reading the code with my limited understanding of rust, I see no way to disable this, configure this, or otherwise remove that part. Did I miss something?

@berkes
Copy link
Author

berkes commented May 5, 2020

I've tried to fix the issue , in PR #147.

Due to lack of experience with Rust and ES, I get stuck on the test-data that needs to become geo_point and not geo_shape for these documents to be returned.

Also not implemented is the with_coerce, with_ignore_malformed and with_type inner fields; since my hack no longer has inner fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant