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

Error using miles for percision in Geo Location Context #24807

Closed
KellyBennett opened this issue May 19, 2017 · 4 comments
Closed

Error using miles for percision in Geo Location Context #24807

KellyBennett opened this issue May 19, 2017 · 4 comments
Assignees
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes >bug

Comments

@KellyBennett
Copy link

KellyBennett commented May 19, 2017

Elasticsearch version:
5.1.2

Description of the problem including expected versus actual behavior:
Here is the search I want to run:

POST stores_search/_search?
{
  "suggest": {
    "store-suggest": {
      "prefix": "Combs",
      "completion": {
        "field": "suggest",
        "fuzzy": {
          "fuzziness": "AUTO",
          "transpositions": true
        },
        "size": 100,
        "contexts": {
          "location": [
            {
              "lat": 47.6062,
              "lon": -122.3321,
              "precision": "100m"
            }
          ]
        }
      }
    }
  }
}

I need to provide my precision in distance. The docs state this is possible:

The precision of the geohash to encode the query geo point. This can be specified as a distance value (5m, 10km etc.), or as a raw geohash precision (1..12). Defaults to index time precision level.

But instead of getting stores within that geo location, I get this error response:

{
  "error": {
    "root_cause": [
      {
        "type": "parsing_exception",
        "reason": "[geo] failed to parse field [precision]",
        "line": 1,
        "col": 57
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query_fetch",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "stores_search",
        "node": "Se4Iz_2cS4OGdz33kndgGg",
        "reason": {
          "type": "parsing_exception",
          "reason": "[geo] failed to parse field [precision]",
          "line": 1,
          "col": 57,
          "caused_by": {
            "type": "number_format_exception",
            "reason": "For input string: \"1000mi\""
          }
        }
      }
    ],
    "caused_by": {
      "type": "parsing_exception",
      "reason": "[geo] failed to parse field [precision]",
      "line": 1,
      "col": 57,
      "caused_by": {
        "type": "number_format_exception",
        "reason": "For input string: \"1000mi\""
      }
    }
  },
  "status": 400
}

If i change precision to 1 (or any number in (1..12)), my search completes with no errors.

Steps to reproduce:

  1. Create a mapping as an example try:
PUT place
{
    "mappings": {
        "shops" : {
            "properties" : {
                "suggest" : {
                    "type" : "completion",
                    "contexts": [
                        { 
                            "name": "place_type",
                            "type": "category",
                            "path": "cat"
                        },
                        { 
                            "name": "location",
                            "type": "geo",
                            "precision": 4
                        }
                    ]
                }
            }
        }
    }
}
  1. Put some documents in the new index, as an example:
PUT place/shops/1
{
    "suggest": {
        "input": "timmy's",
        "contexts": {
            "location": [
                {
                    "lat": 43.6624803,
                    "lon": -79.3863353
                },
                {
                    "lat": 43.6624718,
                    "lon": -79.3873227
                }
            ]
        }
    }
}
  1. Do a lil' query:
POST place/_suggest?pretty
{
    "suggest" : {
        "prefix" : "tim",
        "completion" : {
            "field" : "suggest",
            "size": 10,
            "contexts": {
                "location": [ 
                    {
                        "lat": 43.6624803,
                        "lon": -79.3863353,
                        "precision": "2m"
                    },
                    {
                        "context": {
                            "lat": 43.6624803,
                            "lon": -79.3863353
                        },
                        "boost": 2
                    }
                 ]
            }
        }
    }
}

result:

{
  "error": {
    "root_cause": [
      {
        "type": "parsing_exception",
        "reason": "[geo] failed to parse field [precision]",
        "line": 1,
        "col": 62
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "place",
        "node": "Se4Iz_2cS4OGdz33kndgGg",
        "reason": {
          "type": "parsing_exception",
          "reason": "[geo] failed to parse field [precision]",
          "line": 1,
          "col": 62,
          "caused_by": {
            "type": "number_format_exception",
            "reason": "For input string: \"2m\""
          }
        }
      }
    ],
    "caused_by": {
      "type": "parsing_exception",
      "reason": "[geo] failed to parse field [precision]",
      "line": 1,
      "col": 62,
      "caused_by": {
        "type": "number_format_exception",
        "reason": "For input string: \"2m\""
      }
    }
  },
  "status": 400
}

Provide logs (if relevant):

@ywelsch ywelsch added the :Analytics/Geo Indexing, search aggregations of geo points and shapes label May 22, 2017
@javanna javanna added the >bug label May 23, 2017
@dbgrey44
Copy link

dbgrey44 commented Aug 29, 2017

Any update on this? I am also facing the same issue.
I am also trying to query in a similar fashion as @KellyBennett.

From the logs it looks like the 'precision' field can only be numeric type and thus fails when a string is parsed into it.

Is the documentation incorrect or am I providing a wrong query here. Any help will be greatly appreciated.

@wgottschalk
Copy link

I'm also noticing this bug on 5.5 as well.

imotov added a commit to imotov/elasticsearch that referenced this issue Mar 28, 2018
Adds support for distance measure, such as "4km", "5m" in the precision
field of the geo location context in context suggesters.

Fixes elastic#24807
imotov added a commit that referenced this issue Apr 4, 2018
Adds support for distance measure, such as "4km", "5m" in the precision
field of the geo location context in context suggesters.

Fixes #24807
imotov added a commit that referenced this issue Apr 4, 2018
Adds support for distance measure, such as "4km", "5m" in the precision
field of the geo location context in context suggesters.

Fixes #24807
@vandanachadha
Copy link

I am using ES version 6,2.0, but still getting the same parsing error for "precision" if value is "5m" etc. Works ok if integer.

@imotov
Copy link
Contributor

imotov commented Jul 11, 2018

@vandanachadha it was fixed by #29273 As you can see from labels on the issue it was fixed only in 6.3.0 and above. So, it is expected to get the same parsing error in 6.2.0, which was released 2 months before the issue was fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes >bug
Projects
None yet
Development

No branches or pull requests

8 participants