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

Suggester: No results returned for certain geo precisions #7368

Closed
markharwood opened this Issue Aug 21, 2014 · 0 comments

Comments

Projects
None yet
2 participants
@markharwood
Copy link
Contributor

commented Aug 21, 2014

An encoding issue in GeolocationContextMapping means that certain precision levels are being skipped and consequently cannot be queried.
Partial YAML test here:

setup:
  - do:
      indices.create:
          index: test
          body:
            mappings:
              test:
                "properties":
                  "suggest_geo_multi_level":
                     "type" : "completion"
                     "context":
                        "location":
                            "type" : "geo"
                            "precision" : [1,2,3,4,5,6,7,8,9,10,11,12]
  - do:
      index:
        index: test
        type:  test
        id:    1
        body:
          suggest_geo_multi_level:
            input: "Hotel Marriot in Amsterdam"
            context:
              location:
                lat : 52.22
                lon : 4.53

This call works:

  - do:
      suggest:
        index: test
        body:
          result:
            text: "hote"
            completion:
              field: suggest_geo_multi_level
              context:
                location:
                  lat : 52.22
                  lon : 4.53
                  precision : 3                  
  - length: { result: 1  }

but a precision length of 4 does not. In fact precisions 1,2,3 and 12 work and all others fail.
So there are gaps in the encoding of the data.
The reason is that the encoding logic is given precisions in this order: [12, 3, 10, 6, 2, 1, 7, 11, 9, 5, 4, 8]
and the encoding logic mistakenly truncates the "geohash" string while in this loop:

    for (String geohash : geohashes) {
        for (int p : mapping.precision) {
            int precision = Math.min(p, geohash.length());
            geohash = geohash.substring(0, precision);
            if(mapping.neighbors) {
                GeoHashUtils.addNeighbors(geohash, precision, locations);
            }
            locations.add(geohash);
        }
    }

The required fix is to not change the "geohash" string value in the inner loop which ensures all precisions are then encoded correctly.

@clintongormley clintongormley removed the v1.3.2 label Aug 22, 2014

hkrishna added a commit to hkrishna/pelias-webview that referenced this issue Aug 22, 2014

markharwood added a commit that referenced this issue Aug 29, 2014

Suggest API - bugs with encoding multiple levels of geo precision.
1) One issue reported by a user is due to the truncation of the geohash string. Added Junit test for this scenario
2) Another suspect piece of code was the “toAutomaton” method that only merged the first of possibly many precisions into the result.

Closes #7368

markharwood added a commit that referenced this issue Sep 5, 2014

Suggest API - bugs with encoding multiple levels of geo precision.
1) One issue reported by a user is due to the truncation of the geohash string. Added Junit test for this scenario
2) Another suspect piece of code was the “toAutomaton” method that only merged the first of possibly many precisions into the result.

Closes #7368

@clintongormley clintongormley changed the title Suggest API - no results returned for certain geo precisions Suggester: No results returned for certain geo precisions Sep 8, 2014

markharwood added a commit that referenced this issue Sep 8, 2014

Suggest API - bugs with encoding multiple levels of geo precision.
1) One issue reported by a user is due to the truncation of the geohash string. Added Junit test for this scenario
2) Another suspect piece of code was the “toAutomaton” method that only merged the first of possibly many precisions into the result.

Closes #7368

mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015

Suggest API - bugs with encoding multiple levels of geo precision.
1) One issue reported by a user is due to the truncation of the geohash string. Added Junit test for this scenario
2) Another suspect piece of code was the “toAutomaton” method that only merged the first of possibly many precisions into the result.

Closes elastic#7368
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.