Actually the documentation indicate that it is possible to get an highlight on a feature from a searchprovider using the parameter st=.
But in fact when I test using nominatim on the demo app for example and a st that returns only one parameters it put the text in the textbox, but doesnt detect that the search only returns one parameter nor apply the search.
Investigating upon the searchbox.jsx component I was able to modify the addsearchresults method to do that with a nominatim search
addSearchResults = (searchSession, searchId, results) => {
this.setState((state) => {
if (searchSession !== state.searchSession) {
return {};
}
const pendingSearches = state.pendingSearches.filter(entry => entry !== searchId);
const searchResults = {...state.searchResults, [searchId]: results};
if (isEmpty(pendingSearches)) {
const uniqueResults = Object.entries(searchResults).filter(([key, value]) => value.tot_result_count === 1);
// If a single result is returned, select it immediately if it is a feature or provider result
if (uniqueResults.length === 1) {
const uniqueResult = uniqueResults[0];
if (uniqueResult[0] === "__fulltext" && uniqueResult[1].feature) {
this.selectFeatureResult(uniqueResult[1].feature);
this.blur();
} else if (uniqueResults[0] !== "__fulltext" && uniqueResults[0][1]['results'][0].items[0].bbox) {
this.selectProviderResult(uniqueResults[0], uniqueResults[0][1]['results'][0].items[0], uniqueResult[0]);
this.blur();
}
}
}
But now it applies the search automatically when there is only one search results even if it does not comes from an st= in the url.
To do so I also have to modify the componentdidupdate to treat the st parameters more like ht hp and hf and retriggering a search with startSearch().
Maybe i'm doing something wrong and it is already possible to trigger the search with an st=x only. I don't Know I would like to have your insight on this if possible.
I think being capable of trigerring a search provider using st directly will help a lot in being able to call QWC from others applications without having to rely on the fulltextsearch infrastructure.
I will continue to work on this, let me know if there is a better an easier solution.
Actually the documentation indicate that it is possible to get an highlight on a feature from a searchprovider using the parameter st=.
But in fact when I test using nominatim on the demo app for example and a st that returns only one parameters it put the text in the textbox, but doesnt detect that the search only returns one parameter nor apply the search.
Investigating upon the searchbox.jsx component I was able to modify the addsearchresults method to do that with a nominatim search
But now it applies the search automatically when there is only one search results even if it does not comes from an st= in the url. To do so I also have to modify the componentdidupdate to treat the st parameters more like ht hp and hf and retriggering a search with startSearch().
Maybe i'm doing something wrong and it is already possible to trigger the search with an st=x only. I don't Know I would like to have your insight on this if possible.
I think being capable of trigerring a search provider using st directly will help a lot in being able to call QWC from others applications without having to rely on the fulltextsearch infrastructure.
I will continue to work on this, let me know if there is a better an easier solution.
Thanks in advance, Regards, Clément.