Skip to content
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

Get exact result for ht parameter and not the first one #12

Open
danceb opened this issue Oct 25, 2023 · 11 comments
Open

Get exact result for ht parameter and not the first one #12

danceb opened this issue Oct 25, 2023 · 11 comments

Comments

@danceb
Copy link
Contributor

danceb commented Oct 25, 2023

It is a little bit complicated to zoom to a feature by only passing the search text with the ht parameter, if the search term results in more than one entry. The map will zoom to the first entry of the result list and not to the one with the exact search phrase.

Examples with our system:
https://kartenportal.jena.de/?hp=kartenportal_qwc_adressen_v&ht=Markt%207
Searching for "Markt 7" will result in this list in our case:

  • Holzmarkt 7
  • Markt 7
  • Markt 17
  • ...

As "Holzmarkt 7" ist the first entry, the map will zoom to the related feature and not to the one for "Markt 7"

The workaround is, to pass the phrase additional in the hf parameter, like:
https://kartenportal.jena.de/?hp=kartenportal_qwc_adressen_v&hf=[["display"%2C"%3D"%2C"Markt%207%20(Adresse)"]]&ht=Markt%207%20

While this is a little bit bulky, wouldn't it be a better way, to zoom to the element with the exact phrase if there is one?

@danceb
Copy link
Contributor Author

danceb commented Feb 6, 2025

I came across this issue again. Is there a fast to fix solution for this?

@manisandro
Copy link
Member

manisandro commented Feb 6, 2025

In theory it should only zoom if there is an exact match, see [1] (ht being equal to st here)

[1] https://github.com/qgis/qwc2/blob/master/utils/SearchProviders.js#L425

Edit: exact match => only one result

@danceb
Copy link
Contributor Author

danceb commented Feb 6, 2025

I think this is not an issue with the SearchProviders from the qwc2 app as the fulltext search service gives me more than one result:
https://kartenportal.jena.de/api/v2/search/?searchtext=Markt%207&filter=kartenportal_qwc_adressen_v

From this results the first entry is than passed to the SearchProviders for zooming - and at this point this is the "exact match".

@manisandro
Copy link
Member

So you mean that with limit=1, the fulltext search provider returns the first item instead of the one with an exact match?

@danceb
Copy link
Contributor Author

danceb commented Feb 6, 2025

Yes, that's exactly the behavior.

@manisandro
Copy link
Member

This is ultimately the behaviour of solr, not the qwc-fulltext-search-service. The fulltext search service sends rows [1] to solr according to the passed limit, and it passes sort=score desc, sort asc by default (although this is configurable via search_result_sort). Try enabling debug logging on the fulltext-search-service container (FLASK_DEBUG=1), and then you can see which request is sent to the solr service. You can try tweaking the solr query to see if you can obtain a better result, and in case it could be evaluated whether the such parameters could be either generated or passed as custom configuration from the fulltext-search-service.

[1] https://solr.apache.org/guide/6_6/common-query-parameters.html#CommonQueryParameters-TherowsParameter

@danceb
Copy link
Contributor Author

danceb commented Feb 6, 2025

I see the complexity here ... Actually I thought about a solution, where not the first search result, which is get with limit=1 is passed, rather than the one with matching display attribute. So at the moment:

Requesting
https://kartenportal.jena.de/?hp=kartenportal_qwc_adressen_v&ht=Markt%207
leads to
https://kartenportal.jena.de/api/v2/search/?searchtext=Markt%207&filter=kartenportal_qwc_adressen_v&limit=1
I assume the feature_id is extracted and send to
https://kartenportal.jena.de/api/v2/search/geom/kartenportal_qwc_adressen_v/?filter=[["gid","=",140175]]
coordinates/bbox is extracted from the result and used as input for zooming the map to this geometry.

What about something like passing the ht parameter directly first:

Requesting
https://kartenportal.jena.de/?hp=kartenportal_qwc_adressen_v&ht=Markt%207
leads directly to
https://kartenportal.jena.de/api/v2/search/geom/kartenportal_qwc_adressen_v/?filter=[[%22display%22,%22=%22,%22Markt%207%20(Adresse)%22]]
coordinates/bbox is extracted from the result and used as input for zooming the map to this geometry.

And if this result is empty (ht and display not matching), in the second step
https://kartenportal.jena.de/api/v2/search/?searchtext=Markt%207&filter=kartenportal_qwc_adressen_v&limit=1
is requested.

@manisandro
Copy link
Member

This won't work because display is in general only a column returned by the facet search query in the solr configuration, but there is no guarantee that it exists under that name in the DB record.

@danceb
Copy link
Contributor Author

danceb commented Feb 7, 2025

Mh, so there is no good solution for this. Indeed it is possible to zoom to the exact result using both hf and ht, so there is a possibility for doing this. It is just not that handy for editors to maintain the links.

@danceb danceb closed this as completed Feb 7, 2025
@danceb
Copy link
Contributor Author

danceb commented Feb 7, 2025

I couldn't leave it behind ... ;-)

If the Solr is set up following the documentation [1] actually there should exist a display field within the DB record! The service uses this field for displaying the search results in the search box field.

So as this field should be part of the db and the entity configuration, it could be used as suggested above. And if the field is missing for some reason, there would be the fall back to use the limit=1 filter by id.

[1] https://qwc-services.github.io/master/topics/Search/#fulltext-search-with-solr-backend

@danceb danceb reopened this Feb 7, 2025
@manisandro
Copy link
Member

No, the display field is just retuned by the configured query for solr use. The filter hf ultimately operates via data-service, so it accesses the data directly as stored in the database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants