maptiler/maptiler-geocoding-control

[BUG] Results not ordered by relevance

Closed this issue · 3 comments

wpf500 commented

Describe the bug

The geocoding API results don't always seem to be returned with the most relevant results at the top. I'm not sure if this is a bug in the API or if the geocoding control should be doing some sort of results.sort(result => result.relevance)? Either way it means that sometimes less relevant results appear lower down in the list.

To Reproduce

API response: https://api.maptiler.com/geocoding/5%20frie.json?proximity=7.098955%2C50.736281&fuzzyMatch=true&key=xxx

Or load a map, navigate somewhere and search for the results

Expected behavior

The most relevant results should be at the top

Screenshots

image

Simplified API response for relevant bits:

[
  {
    "place_name": "Fries 5, 6641NR Beuningen, Netherlands",
    "relevance": 0.916667
  },
  {
    "place_name": "Furie 5, 3144DS Maassluis, Netherlands",
    "relevance": 0.916667
  },
  {
    "place_name": "Frei 5, 4681 Frei, Rottenbach, Austria",
    "relevance": 0.88
  },
  {
    "place_name": "Grie 5a, 31141 Hildesheim, Germany",
    "relevance": 0.88
  },
  {
    "place_name": "Frik 5, 1704DT Heerhugowaard, Netherlands",
    "relevance": 0.88
  },
  {
    "place_name": "Friedensplatz 5, 53111 Bonn, Germany",
    "relevance": 1
  },
  {
    "place_name": "Friedrichstraße 5, 53111 Bonn, Germany",
    "relevance": 1
  },
  {
    "place_name": "Friedrich-Wilhelm-Straße 5, 53113 Bonn, Germany",
    "relevance": 1
  },
  {
    "place_name": "Friedenstraße 5, 53229 Bonn, Germany",
    "relevance": 1
  },
  {
    "place_name": "Friedlandstraße 5, 53117 Bonn, Germany",
    "relevance": 1
  }
]

wpf500 commented

@zdila do you have any updates on this? This means the geocoding results aren't very helpful at the moment. I'm happy to submit a PR to sort the results by relevance if that's the right fix, but it seems strange that the API is returning the results in the wrong order?

zdila commented

Hi @wpf500. This is caused by combining non-autocomplete results with autocomplete results. We plan to remove this feature soon.

zdila commented

We have removed combining of non-autocomplete and autocomplete results which should improve the order. Further improvements are planned in the near future.