What Can't I Use "10m" precisions in context queries?


(William Gottschalk) #1

I'm running on Elasticsearch 5.5
I have a document with the following mapping

"mappings": {
  "shops": {
    "properties": {
      "locations": {
        "type": "geo_point"
      },
      "name": {
        "type": "keyword"
      },
      "suggest": {
        "type": "completion",
        "contexts": [
          {
            "name": "location",
            "type": "GEO",
            "precision": "10m",
            "path": "locations"
          }
        ]
      }
    }
  }

I'll add a document as follows:

PUT my_index/shops
{  
  "name":"random shop",
  "suggest":{  
    "input":"random shop"
  },
  "locations":[  
    {  
      "lat":42.38471212,
      "lon":-71.12612357
    }
  ]
}

I try to query for the document with the follow JSON call

GET my_shops/_search
{
  "suggest": {
    "result": {
      "prefix": "random",
      "completion": {
        "field": "suggest",
        "size": 5,
        "fuzzy": true,
        "contexts": {
         "location": [{
            "lat": 42.38471212,
            "lon": -71.12612357,
            "precision": "10mi"
          }]
        }
     }
    }
  }
}

I get the following errors:

image

But when I change the "precision" field to an int, I get the intended search results.
I'm confused on two fronts.

  1. Why is there a context error? The documentation seems to say that this is ok
    https://www.elastic.co/guide/en/elasticsearch/reference/5.5/suggester-context.html

  2. Why can't I use string values for the precision values?
    At the bottom of the page, I see that the precision values can take either distances or numeric values.


(William Gottschalk) #2

Is this a known bug? I can't seem to find it on github issues.


(system) #3

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