This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

OpenStreetMap Nominatim API limit parameter behaving erratically, returns inconsistent numbers of results

0

I am trying to use the Nominatim API to geocode cities, with simple HTTP GET requests. I want to receive a specific number of possible matches, when available. The documentation indicates this is possible by using the "limit" parameter:

limit=integer
Limit the number of returned results.

This works as expected for most queries. For example, if I request limit=2, I get the top 2 results and if I request limit=3, I get the top 3 results. But the limit parameter behaves erratically for some queries. For example, with Sonoma California:

  • If I request limit=1, I get 1 result
  • But if I request limit=2, I still get just 1 result
  • And if I request limit=3, I suddenly get 2 results

If 2 results are available when I request limit=3, why didn't I get 2 results when I requested limit=2?

As another example, with Petaluma California:

  • If I request limit=1, I get 1 result
  • But if I request limit=2, I still get just 1 result
  • And if I request limit=3, I get 3 results this time

Why am I inconsistently not receiving as many results as I am requesting, and how can I make sure to receive the exact number I request?

asked 28 Sep '16, 06:03

gboeing's gravatar image

gboeing
1366613
accept rate: 0%


One Answer:

1

Sometimes you have several objects in OSM identifying the same place or object in reality. The simplest case is a street being split in many different OSM ways due to different characteristics. Nominatim will attempt to detect such duplicates and only return one match; this is controlled by the dedupe parameter which defaults to 1. Since the limit is, for reasons of efficiency, enforced before and not after de-duplicating, it is possible that de-duplicating leaves you with less results than requested.

In your "Sonoma" case, when limit=2 and dedupe=0 are set, Nominatim returns the ways 33162431 and 33162426 (it should return https://www.openstreetmap.org/relation/113172 instead and I don't know why it doesn't).

answered 28 Sep '16, 07:21

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

Thanks. Yes the dedupe parameter used in conjunction with the limit parameter does appear to give me the number of results I request, each time. However, like you mentioned in the last sentence that is an odd result.

(06 Oct '16, 18:48) gboeing

Source code available on GitHub .