pelias / api

HTTP API for Pelias Geocoder
http://pelias.io
MIT License
219 stars 163 forks source link

Is there documentation for `/search` endpoint middlewares? #1067

Open tadjik1 opened 6 years ago

tadjik1 commented 6 years ago

Hi there, there are bunch of middlewares that are used in /search endpoint. For our purposes we want to modify them a bit, but we realized that it's quite difficult to understand what actually these middlewares are used for and how they all are working with each other.

Do you have documentation for this logic?

Something like:

1. sanitize parameters (convert comma-separated values to arrays, validate country code, etc.)
2. validate language parameter if exists (use https://github.com/florrain/locale library)
3. validate size parameter if exists
4. libpostal middleware
    execute 
       if there are no errors in request
       if source parameter is not "whosonfirst"
    perform "parse_text" function and return hash with categorized query terms, for example:
    "ettlinger strasse 10" => { street: "ettlinger strasse", "number": 10 }
5. ...
missinglink commented 6 years ago

@trescube will be able to answer this, we try to document as much as we can but sometimes the internal APIs are difficult and time-consuming to document, we should still try to do it so we can encourage external contributions.

Diana did a big refactor recently https://github.com/pelias/api/pull/1057 to clean up the controller code

tadjik1 commented 6 years ago

@missinglink @trescube can you please describe why there are 2 placeholder middlewares: geodisambiguation and idslookup (what's the difference between them) and what they bring to the chain. exactly the same question about 3 ES queries: search_with_ids, cascading_fallback and search_original. What's the difference between them?