{"action":"created","issue":{"url":"https://api.github.com/repos/pelias/api/issues/221","labels_url":"https://api.github.com/repos/pelias/api/issues/221/labels{/name}","comments_url":"https://api.github.com/repos/pelias/api/issues/221/comments","events_url":"https://api.github.com/repos/pelias/api/issues/221/events","html_url":"https://github.com/pelias/api/pull/221","id":104962585,"number":221,"title":"Add source parameter","user":{"login":"orangejulius","id":111716,"avatar_url":"https://avatars.githubusercontent.com/u/111716?v=3","gravatar_id":"","url":"https://api.github.com/users/orangejulius","html_url":"https://github.com/orangejulius","followers_url":"https://api.github.com/users/orangejulius/followers","following_url":"https://api.github.com/users/orangejulius/following{/other_user}","gists_url":"https://api.github.com/users/orangejulius/gists{/gist_id}","starred_url":"https://api.github.com/users/orangejulius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orangejulius/subscriptions","organizations_url":"https://api.github.com/users/orangejulius/orgs","repos_url":"https://api.github.com/users/orangejulius/repos","events_url":"https://api.github.com/users/orangejulius/events{/privacy}","received_events_url":"https://api.github.com/users/orangejulius/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pelias/api/labels/in%20progress","name":"in progress","color":"ededed"}],"state":"open","locked":false,"assignee":{"login":"orangejulius","id":111716,"avatar_url":"https://avatars.githubusercontent.com/u/111716?v=3","gravatar_id":"","url":"https://api.github.com/users/orangejulius","html_url":"https://github.com/orangejulius","followers_url":"https://api.github.com/users/orangejulius/followers","following_url":"https://api.github.com/users/orangejulius/following{/other_user}","gists_url":"https://api.github.com/users/orangejulius/gists{/gist_id}","starred_url":"https://api.github.com/users/orangejulius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orangejulius/subscriptions","organizations_url":"https://api.github.com/users/orangejulius/orgs","repos_url":"https://api.github.com/users/orangejulius/repos","events_url":"https://api.github.com/users/orangejulius/events{/privacy}","received_events_url":"https://api.github.com/users/orangejulius/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2015-09-04T20:13:16Z","updated_at":"2015-09-08T18:47:04Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/pelias/api/pulls/221","html_url":"https://github.com/pelias/api/pull/221","diff_url":"https://github.com/pelias/api/pull/221.diff","patch_url":"https://github.com/pelias/api/pull/221.patch"},"body":"This adds the source parameter described #181. It allows limiting search results to only those matching a particular data source (geonames, quattroshapes, openaddresses, and openstreetmap are the currently available sources).\r\n\r\nThe filtering done with this parameter is _cumulative_ with the layers parameter, and it is possible to specify combinations of layers and source parameters that can't possibly return any results, such as source=quattroshapes&layers=address. Additionally, the address parser uses some logic to determine when it is safe to query only the admin layer for performance improvement (for example, queries with a text parameter only a few characters long).\r\n\r\nFor that reason, this branch also contains a major refactoring to all code relating to layers, as well as the address parser. It splits the address parser functionality into two sections, one dealing with the actual address parsing, and one dealing with determining when the search results can be constrained to the admin layer. It also refactors address parsing and layer parameter handling code to simply submit a requested list of types, rather than directly manipulating the list of types sent to Elasticsearch.\r\nFinally, new logic is added in middleware/types and helpers/types to look at types specified by the layers parameter, the source parameter, and the address parser, and decide how to combine them.\r\n\r\nThe types middleware detects when a combination of layers and source parameter won't return any results, and provides a friendly error message. This allows the full power of layers and source to be used in combination when it makes sense, while ensuring combinations that don't make sense are discoverable quickly.\r\n\r\nFixes #181"},"comment":{"url":"https://api.github.com/repos/pelias/api/issues/comments/138666113","html_url":"https://github.com/pelias/api/pull/221#issuecomment-138666113","issue_url":"https://api.github.com/repos/pelias/api/issues/221","id":138666113,"user":{"login":"dianashk","id":5446511,"avatar_url":"https://avatars.githubusercontent.com/u/5446511?v=3","gravatar_id":"","url":"https://api.github.com/users/dianashk","html_url":"https://github.com/dianashk","followers_url":"https://api.github.com/users/dianashk/followers","following_url":"https://api.github.com/users/dianashk/following{/other_user}","gists_url":"https://api.github.com/users/dianashk/gists{/gist_id}","starred_url":"https://api.github.com/users/dianashk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dianashk/subscriptions","organizations_url":"https://api.github.com/users/dianashk/orgs","repos_url":"https://api.github.com/users/dianashk/repos","events_url":"https://api.github.com/users/dianashk/events{/privacy}","received_events_url":"https://api.github.com/users/dianashk/received_events","type":"User","site_admin":false},"created_at":"2015-09-08T18:47:04Z","updated_at":"2015-09-08T18:47:04Z","body":"```javascript\r\n{\r\n   \"geocoding\":{\r\n      \"version\":\"0.1\",\r\n      \"attribution\":\"http://pelias.mapzen.com/attribution\",\r\n      \"query\":{\r\n         \"input\":\"boston\",\r\n         \"parsed_input\":{\r\n            \"regions\":[\r\n               \"boston\"\r\n            ],\r\n            \"target_data_sources\":[\r\n               \"geoname\",\r\n               \"osmnode\",\r\n               \"osmway\",\r\n               \"admin0\",\r\n               \"admin1\",\r\n               \"admin2\",\r\n               \"neighborhood\",\r\n               \"locality\",\r\n               \"local_admin\"\r\n            ]\r\n         },\r\n         \"layers\":[\r\n               \"osmaddress\",\r\n               \"openaddresses\"\r\n         ],\r\n         \"sources\":[\r\n            \"osmaddress\",\r\n            \"osmnode\",\r\n            \"osmway\"\r\n         ],\r\n         \"size\":10,\r\n         \"details\":true,\r\n         \"type\":[\r\n            \"osmaddress\"\r\n         ]\r\n      },\r\n      \"engine\":{\r\n         \"name\":\"Pelias\",\r\n         \"author\":\"Mapzen\",\r\n         \"version\":\"1.0\"\r\n      },\r\n      \"timestamp\":1441737741825\r\n   },\r\n...\r\n```"}}