Skip to content

Probably a bug in GeoShape filter #776

@mikeerrecart

Description

@mikeerrecart

Hi, Not sure where the bug lies but here's what i came into.
The following code (a GeoShape filtered query) :

List<List<double>> gs_polygone_quiberon = new List<List<double>>() { 
                new List<double>() {-3.183515, 47.542491} 
                , new List<double>(){-3.095624, 47.537624} 
                , new List<double>(){-3.026788, 47.478487}
                , new List<double>() {-3.190896, 47.452956}
                , new List<double>() {-3.183515, 47.542491} 
            };

var results = client
    .Search<Elastic_Oi>(s =>
        s
        .AllIndices()
        .From(0)
        .AllTypes()
        .Size(10)
        .Query(q => q.Filtered(
                    f => f.Filter(x =>
                        x.GeoShape("GeoShapeLocation", d => d.Type("polygon").Coordinates(gs_polygone_quiberon))
                        )
                    )
        )
    );

generates the following JSon :

{
  "from": 0,
  "size": 10,
  "query": {
    "filtered": {
      "filter": {
        "geo_shape": {
          "GeoShapeLocation": {
            "shape": {
              "type": "polygon",
              "coordinates": [
                [
                  -3.183515,
                  47.542491
                ],
                [
                  -3.095624,
                  47.537624
                ],
                [
                  -3.026788,
                  47.478487
                ],
                [
                  -3.190896,
                  47.452956
                ],
                [
                  -3.183515,
                  47.542491
                ]
              ]
            }
          }
        }
      }
    }
  }
}

and an 400 error in NEST.

Executing the Json directly in ES generates a null pointer exception. To be able to execute the query i have to add an indentation level in the "coordinates" field like in the following Json (i wrapped all the "coordinates" field value in []

{
  "from": 0,
  "size": 10,
  "query": {
    "filtered": {
      "filter": {
        "geo_shape": {
          "GeoShapeLocation": {
            "shape": {
              "type": "polygon",
              "coordinates": [[
                [
                  -3.183515,
                  47.542491
                ],
                [
                  -3.095624,
                  47.537624
                ],
                [
                  -3.026788,
                  47.478487
                ],
                [
                  -3.190896,
                  47.452956
                ],
                [
                  -3.183515,
                  47.542491
                ]
              ]]
            }
          }
        }
      }
    }
  }
}

This query works like a charm, but is impossible to reproduce using Nest, the Coordinates method of the GeoShape filter takes a IEnumerable<IEnumerable<double>> parameter, not a IEnumerable<IEnumerable<IEnumerable<double>>> parameter.

Is the bug in Nest ? My code ? ES ?

Thanks in advance !

Mike

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions