When performing searches that yield multiple results, I've noticed what looks like an intuitive ordering in the output. For instance, searching London yields the English capital as first result, as opposed to the London county in Ontario, Canada or the city in Arkansas, USA; searching Manhattan gives the New York City municipality as first result, as opposed to the city in Kansas, USA or the locality in Poland; searching Berlin yields the German capital as first result as opposed to any of the (surprisingly numerous) cities named Berlin in the US.

I've also noticed that the Geopy Nominatim client, when configured to return exactly one result, seems to always return the first one.

Is it true that results are ordered according to certain criteria? In that case, are the criteria documented? It would actually be helpful for me if this was the case, but I'd love to understand if this is a feature provided by design, a best-effort kind of thing that is provided but isn't guaranteed by the API, or mere coincidence.


asked 13 May, 23:01

Shai's gravatar image

accept rate: 0%

Thanks to both, it doesn't seem like I'm able to upvote your answers :( but I appreciate the help.

(14 May, 17:42) Shai

(Can't seem to add a comment).

The default settings are in settings/address-levels.json and for points-of-interest types there's also a frequency list in lib/ClassTypes.php.

When you install Nominatim yourself, and added the wikipedia ranking file (described in the install instructions), it will be almost the same as nominatim.openstreetmap.org.

There's a difference searching via a browser (e.g. on openstreetmap.org) and via a script (e.g. geopy): a browser will send your preferred language, and the website usually the current viewpoint of the map. That gives additional hints to the ranking. For example if the map is zoomed a London in the United States then London, UK is less relevant. You can set those with the accept-language and viewbox API parameters.

permanent link

answered 14 May, 17:27

mtmail's gravatar image

accept rate: 31%

OK, now having a look at settings/address-levels.json I'm getting an idea of the criteria. Thanks. In my installation I haven't used the Wikipedia ranking file, so I suppose I'm getting the results based on the default settings.

(14 May, 17:41) Shai

Yes, results are ordered and this is documented in Nominatim's documentation. Of special interest are probably the chapter on Place Ranking and Wikipedia & Wikidata.

permanent link

answered 14 May, 08:08

Jochen%20Topf's gravatar image

Jochen Topf
accept rate: 32%

Great, thank you Jochen, I totally missed that section.

So, Place Ranking section describes how places are ranked using search ranks and address ranks, which it states are assigned to places on import. It then explains how may one go about configuring ranks. However, I haven't configured any ranks when I imported data into my database, and judging by the intuition I explained in the original post, ranks definitely seem to have been assigned automatically. In that case, do we know with what criteria? Also, is it the same as the online Nominatim?

Thanks again.

(14 May, 14:29) Shai
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 13 May, 23:01

question was seen: 232 times

last updated: 15 May, 07:14

powered by OSQA