# Geo context not working with completion suggester with precision in "mi"

**URL:** <https://discuss.elastic.co/t/geo-context-not-working-with-completion-suggester-with-precision-in-mi/232882>\
**Category:** Elasticsearch\
**Created:** [May 15, 2020, 8:38pm UTC](https://discuss.elastic.co/t/geo-context-not-working-with-completion-suggester-with-precision-in-mi/232882 "2020-05-15T20:38:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Douglas\_Leister](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/douglas_leister/32/50610_2.png) [@Douglas\_Leister](https://discuss.elastic.co/u/Douglas_Leister)\
**Post date:** [May 15, 2020, 8:38pm UTC](https://discuss.elastic.co/t/geo-context-not-working-with-completion-suggester-with-precision-in-mi/232882/1 "2020-05-15T20:38:39Z")

</div>

I'm using ES v.7.6 and am trying to setup an autocomplete to search for businesses and filter out those which lie a variable distance away from the center of the search area.

When specifying precision on the query in terms of an integer, I receive valid results. However, whenever I switch my precision to a unit of distance (i.e. "30mi"), I always receive an empty result set. Any suggestions on what I am missing on my mapping or query? See below for simplified code and results that I am seeing.

**Index Mapping**

```auto
{
  "mappings" : {
    "properties" : {
      "name_suggest": {
        "type": "completion",
        "contexts": [
          {
            "name": "location",
            "type": "geo",
            "path": "coordinates"
          }
        ]
      },
      "coordinates" : {
        "type": "geo_point"
      },
      "name" : {
        "type" : "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      }
    }
  }
}

```

**Document Indexed**

```auto
PUT /business/_doc/1
{
  "name_suggest": ["Aloha", "Aloha Paddle", "Aloha Paddle Sports"],
  "name": "Aloha Paddle Sports",
  "coordinates": {
    "lat": 35.453676,
    "lon": -80.893276
  }
}

```

**Bool Query with Geo Distance Filter**

```auto
{
  "query": {
    "bool": {
      "must": {
        "match": {
          "name": {
            "query": "Aloha"
          }
        }
      },
      "filter": [
        {
          "geo_distance": {
            "distance": "50mi",
            "coordinates": {
              "lat": 35.124,
              "lon": -80.8648
            }
          }
        }
      ]
    }
  }
}

```

**Bool Query Results**

```auto
  "took" : 3,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 0.2876821,
    "hits" : [
      {
        "_index" : "business",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 0.2876821,
        "_source" : {
          "name_suggest" : [
            "Aloha",
            "Aloha Paddle",
            "Aloha Paddle Sports"
          ],
          "name" : "Aloha Paddle Sports",
          "coordinates" : {
            "lat" : 35.453676,
            "lon" : -80.893276
          }
        }
      }
    ]
  }
}

```

**Completion Suggester with Geo Context Query**

```auto
{
  "suggest" : {
    "suggestions" : {
      "prefix" : "Aloha P",
      "completion" : {
        "field" : "name_suggest",
        "size": 10,
        "contexts": {
          "location": [
              {
                "lat":35.124,
                "lon": -80.8648,
                "precision": "50mi"
              }
          ]
        }
      }
    }
  }
}

```

**Completion Suggester with GeoContext Results**

```auto
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 0,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : []
  },
  "suggest" : {
    "suggestions" : [
      {
        "text" : "Aloha P",
        "offset" : 0,
        "length" : 7,
        "options" : []
      }
    ]
  }
}

```

**Completion Suggester results when Changing 'precision' to 2**

```auto
{
  "took" : 3,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 0,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : []
  },
  "suggest" : {
    "suggestions" : [
      {
        "text" : "Aloha P",
        "offset" : 0,
        "length" : 7,
        "options" : [
          {
            "text" : "Aloha Paddle",
            "_index" : "business",
            "_type" : "_doc",
            "_id" : "1",
            "_score" : 1.0,
            "_source" : {
              "name_suggest" : [
                "Aloha",
                "Aloha Paddle",
                "Aloha Paddle Sports"
              ],
              "name" : "Aloha Paddle Sports",
              "coordinates" : {
                "lat" : 35.453676,
                "lon" : -80.893276
              }
            },
            "contexts" : {
              "location" : [
                "dnq3xn"
              ]
            }
          }
        ]
      }
    ]
  }
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 12, 2020, 8:38pm UTC](https://discuss.elastic.co/t/geo-context-not-working-with-completion-suggester-with-precision-in-mi/232882/2 "2020-06-12T20:38:42Z")

</div>

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