[Photon] Location bias and typo tolerance
Geneviève Bastien
genevieve.bastien at polymtl.ca
Thu Mar 10 14:01:53 UTC 2022
Hi Sarah,
Thanks for your response.
I was able to modify the code and try different stuff to get results
closer to what we want. The code is easy to understand and modify,
that's awesome!
I'll continue to play around with the queries until we're fully
satisfied, then we can discuss further if/how there's anything that can
be contributed upstream for the benefit of the community. I'll be back!
Cheers,
Geneviève
Le 3/9/22 à 16:14, Sarah Hoffmann via Photon a écrit :
> Hi Geneviève,
>
> your observation is correct. Photon first tries with a perfect match of
> the data and does not look further if it finds one. Usually this is what
> you want because a global geodataset tends to give you quickly too many
> false positives with immedidate spelling correction.
>
> There is no commandline or query switch to change this behviour but you
> can play with the query building in the code to see for yourself.
>
> If you look in the search handler here
> https://github.com/komoot/photon/blob/7e822c0f59855290167217d5218fb54bf48ffed3/src/main/java/de/komoot/photon/elasticsearch/ElasticsearchSearchHandler.java#L30
>
> you'll see that buildQuery() is called first in strict mode and then
> only if that leads to no result in lenient mode. You can change the code
> to see, if directly using lenient mode works better for you. Also note
> that strict mode requires an exact match while lenient mode allows a
> typo and leaving out a word. If might be worth toying with a setup that
> already allows spelling errors in the strict round and only adds leaving
> out words in the lenient round. The code is around here:
> https://github.com/komoot/photon/blob/7e822c0f59855290167217d5218fb54bf48ffed3/src/main/java/de/komoot/photon/elasticsearch/PhotonQueryBuilder.java#L58
>
> The code is all query-side, so you can toy around with it without
> needing to reimport anything.
>
> Sarah
>
>
> On Wed, Mar 09, 2022 at 10:06:57AM -0500, Geneviève Bastien via Photon wrote:
>> Hi photon community!
>>
>> I'm on a journey to convince partner organisations to invest in
>> OpenStreetMap data instead of spend on Google API. We need to prove that
>> there's a way to query openStreetMap data with similar results as Google.
>> Photon looks very much this tool, it works great for most queries.
>>
>> But since our application will be public facing, the query tool needs to be
>> typo tolerant and still return expected result. Here's one example where
>> results are unexpected:
>>
>> Let's say the map is centered around Montréal and we're looking for a 'Jean
>> coutu' pharmacy. The following query without typo works fine:
>>
>> https://photon.komoot.io/api/?q=jean
>> coutu&limit=5&lat=45.52294660989206&lon=-73.62765846541139
>>
>> Now, if we make a typo in 'jean coutu' and write 'jean couti' instead, I'd
>> expect to get some of the results from the first query:
>>
>> https://photon.komoot.io/api/?q=jean
>> couti&limit=5&lat=45.52294660989206&lon=-73.62765846541139
>>
>> Yet it rather returns exact matches in France, thousands of kilometers away.
>> And no matter if I set the `zoom` or `location_bias_scale` parameters. On my
>> local instance with only Quebec data, then I get the expected result as the
>> exact matches are not in the database. The query seems to prefer exact
>> matches, even if they are far away, rather than close matches, closer to the
>> location.
>>
>> I would expect results to be weighted by closeness to the queried string,
>> but also by proximity to the location, such that the returned results would
>> contain the locations with typo close by, and exact matches only if they are
>> not too far away.
>>
>> Are my expectations correct? Is there any parameter I can tweak to achieve
>> this? If desirable, I can contribute this feature.
>>
>> Thanks for the great work!
>>
>> Geneviève
>>
>>
>> _______________________________________________
>> Photon mailing list
>> Photon at openstreetmap.org
>> https://lists.openstreetmap.org/listinfo/photon
> _______________________________________________
> Photon mailing list
> Photon at openstreetmap.org
> https://lists.openstreetmap.org/listinfo/photon
>
More information about the Photon
mailing list