-
Notifications
You must be signed in to change notification settings - Fork 284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow searching on osm_key and osm_value #68
Comments
I have the same request. need the ability to filter based on multiple osm_key and osm_value (and also on absence of certain keys or values) |
if someone provides me a hint where this code is, I can try forking and changing this code. |
you will want to extend the request handling taking the new query parameters into account. api request handling is done here: https://github.com/komoot/photon/blob/master/src/main/java/de/komoot/photon/importer/App.java#L118 changing how es is queried could be done here: https://github.com/komoot/photon/blob/master/src/main/java/de/komoot/photon/importer/elasticsearch/Searcher.java#L62 let me know if you have further question / problems! good luck |
Bump! |
I am working on this issue. I added a few new PhotonDocs into the setup of the QueryStateTest. These new PhotonDocs have multiple arbitrary tags in the "extratags" constructor parameter. I expected these extratags to be in the result on line 52 - but none showed up. What am I doing wrong? Or - is the test index not setup to have the extra tags? Please let me know if my question does not make sense. Thanks |
I committed an example on my fork. See comments on that commit: sdole/photon@16b0a33 |
In extratags we save some additional data that is coming from nominatim's db column, here is an example place: http://nominatim.openstreetmap.org/details.php?place_id=167287581 We added it in the beginning but we have never used it so far. We should be very careful about what information we store in the elasticsearch index. We have more than 100.000.000 documents, every little detail we add will have a big impact on the index size. The information in extratags are not important enough to be stored. If you want to save this information for your needs, you need to adopt this util function: https://github.com/komoot/photon/blob/master/src/main/java/de/komoot/photon/Utils.java#L24 It defines how a photon doc is converted into a elasticsearch doc. Btw: you do not need extratags to allow filtering on osm_key and osm_value |
Maybe there is an option where one can enable this functionality? |
My mistake. The correct questions I should have asked are:
Thank you.
|
every photon doc has a tag key and a tag value. There is already an ES filter, you can extend it here: https://github.com/sdole/photon/blob/master/es/query.json#L70 you should not forget to adopt key and value in the index. otherwise you cannot query for them. see https://github.com/sdole/photon/blob/master/es/mappings.json#L19 |
I see. So, the ES data model has the "Type" tag from nominatim stored as "tagKey" and "tagValue"? Got it! Then, I don't need to filter on extratags. However, I have a question: what an element has more than one tag? What will be held in tagKey and tagValue? I have another question: how do you feel about using es java api instead of the json syntax? Thanks |
When one osm object has several types, nominatim creates multiple places. That means in photon we can have multiple docs with different tagKey/tagValue but with the same osm_id. We opted to use json as it is easier to read and can be used by other implementations. We are using a small python implementation for developing but you can also use it with this chrome extension for example. By the way, this plugin is super helpful for creating a new filter! |
Understood. I will checkout that plugin. Thanks.
|
Christoph, I need more help. I am using that sense chrome extension from the link you sent. It shows me some data about photon index making me believe that I have ES going into the right index. Secondly, I debugged the photon code in my IDE to copy the json with replaced parameters and pasted that into the sense chrome extension. When I run this, I get the following error. What am I not doing right?
|
@sdole can you paste the full query and the full traceback? (Seems that you are missing the index to query on, but just guessing.) |
Here is the query followed by the result
and result
|
I meant through a pastebin ;) Try |
You need a first |
ah! so what should the query json object look like if I am searching for the word "berlin"? I can look at documentation, but, I want to mimic what happens in photon as nearly as possible. thank you for this! |
I think I found it. Can you please take a look at my latest query and tell me if it looks right? It does seem to match what I can get from photon for the same query. |
I have not been able to make much progress on this one yet. I need to learn the query dsl. I will report back when I get this done. If you have suggestions or ideas for me to pursue, please let me know. Thanks for support so far. |
It looks like the osm_key field is not indexed as per the mapping. If that is the case, how do we filter on the key? I am able to construct a filter for the osm_value, but not on osm_key. I suspect it is because osm_key is not indexed in the mapping. Do you concur?
|
yes, we need to index them before. that's what i meant here |
Got it. Now, as I understand, this indexing can only be done at import Please suggest/advise.
|
I can send you some sample data if you want, but probably it is even easier to develop that feature with test cases. this is an example: This way, you can create some sample documents and write test for the filters. |
Awesome. I will check that out and go with test data. Thanks.
|
I created a pull request. This is my proposal of course, please let me know if this will not work for any reason or if you want me to improve this further before it can be used. Thanks! |
@christophlingg As soon as I started coding for using this new feature I realized that I am going to need multiple osm_key and osm_value instead of just one as I have coded. So, I might even need to get something like
I will have to think about this a little more and possibly do some more coding. I will first communicate my proposal to you and then code for it. I will also try to do the java API coding when I do this. I assume that you will see the value in this - not just for my use case, but possibly for others who might use this. I will try to not make this very complex, for users of photon. |
I understand, in some more advanced scenarios you might want to filter on multiple tags. Thinking even more generic you might want to exclude some results, like every kind of object but no business stations and letter boxes... that's just a quick idea I had: ?osm_tag=key:value&osm_tag=key&osm_tag=!key:value Anyway it should be well thought |
@christophlingg your idea looks great. I am starting to implement it. |
Just a heads up, I am almost done with a fix for a new filter. I just want to test it with the latest data file. I will be opening up a new pull request someday soon. If you want to get a preview, please see the fork: https://github.com/sdole/photon |
Good to know! |
Done. Please see pull request #146 |
cool @sdole, your feature is up and running. works like a charm:
|
great to hear. I will watch for bug reports if anyone files any. On Fri, Mar 6, 2015 at 7:11 AM, Christoph Lingg [email protected]
President | Genvega Inc. | www.genvega.com | tel: 630.290.2561 |
@sdole I'm not sure if you'd know or not but I was wondering if you had come across a list of the tags/value/both that could be used to decide if a result is a venue or not (eg anything from a theatre to a football stadium). |
I am sorry, I don't. I would have thought about it the same way you seem
|
There should be another filter parameter in the API to search in a specific area (bounding box) for a specific tag combination or even a set of combinations ('I want food').
For that osm_key and osm_value have to be indexed in the mapping. Or maybe we make this configurable if this increases size too much.
The text was updated successfully, but these errors were encountered: