forked from organicmaps/organicmaps
[search] Do not show results with >= 2 unmatched tokens in viewport.
This commit is contained in:
parent
e03990ef9c
commit
f316f8c2da
3 changed files with 11 additions and 2 deletions
|
@ -258,10 +258,15 @@ void PreRanker::ClearCaches()
|
|||
void PreRanker::FilterForViewportSearch()
|
||||
{
|
||||
auto const & viewport = m_params.m_viewport;
|
||||
size_t tokensNumber = 0;
|
||||
strings::Tokenize(m_params.m_query, " ",
|
||||
[&tokensNumber](auto const & /* token */) { ++tokensNumber; });
|
||||
|
||||
base::EraseIf(m_results, [&viewport](PreRankerResult const & result) {
|
||||
base::EraseIf(m_results, [&viewport, &tokensNumber](PreRankerResult const & result) {
|
||||
auto const & info = result.GetInfo();
|
||||
return !viewport.IsPointInside(info.m_center);
|
||||
if (!viewport.IsPointInside(info.m_center))
|
||||
return true;
|
||||
return result.GetMatchedTokensNumber() + 1 < tokensNumber;
|
||||
});
|
||||
|
||||
SweepNearbyResults(m_params.m_minDistanceOnMapBetweenResults, m_prevEmit, m_results);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <optional>
|
||||
#include <random>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
|
@ -52,6 +53,8 @@ public:
|
|||
|
||||
bool m_viewportSearch = false;
|
||||
bool m_categorialRequest = false;
|
||||
|
||||
std::string m_query;
|
||||
};
|
||||
|
||||
PreRanker(DataSource const & dataSource, Ranker & ranker);
|
||||
|
|
|
@ -750,6 +750,7 @@ void Processor::InitPreRanker(Geocoder::Params const & geocoderParams,
|
|||
params.m_limit = max(SearchParams::kPreResultsCount, searchParams.m_maxNumResults);
|
||||
params.m_viewportSearch = viewportSearch;
|
||||
params.m_categorialRequest = geocoderParams.IsCategorialRequest();
|
||||
params.m_query = searchParams.m_query;
|
||||
|
||||
m_preRanker.Init(params);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue