forked from organicmaps/organicmaps
[search] Require full match for postcodes.
This commit is contained in:
parent
9e250bb3ae
commit
859c32edf2
2 changed files with 11 additions and 18 deletions
|
@ -329,18 +329,13 @@ void MatchPostcodesInTrie(TokenSlice const & slice, trie::Iterator<ValueList> co
|
|||
impl::OffsetIntersector<Filter, Value> intersector(filter);
|
||||
for (size_t i = 0; i < slice.Size(); ++i)
|
||||
{
|
||||
if (slice.IsPrefix(i))
|
||||
{
|
||||
std::vector<PrefixDFAModifier<UniStringDFA>> dfas;
|
||||
slice.Get(i).ForEach([&dfas](UniString const & s) { dfas.emplace_back(UniStringDFA(s)); });
|
||||
MatchInTrie(dfas, TrieRootPrefix<ValueList>(*postcodesRoot, edge), intersector);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<UniStringDFA> dfas;
|
||||
slice.Get(i).ForEach([&dfas](UniString const & s) { dfas.emplace_back(s); });
|
||||
MatchInTrie(dfas, TrieRootPrefix<ValueList>(*postcodesRoot, edge), intersector);
|
||||
}
|
||||
// Full match required even for prefix token. Reasons:
|
||||
// 1. For postcode every symbol is important, partial matching can lead to wrong results.
|
||||
// 2. For prefix match query like "streetname 40" where |streetname| is located in 40xxx
|
||||
// postcode zone will give all street vicinity as the result which is wrong.
|
||||
std::vector<UniStringDFA> dfas;
|
||||
slice.Get(i).ForEach([&dfas](UniString const & s) { dfas.emplace_back(s); });
|
||||
MatchInTrie(dfas, TrieRootPrefix<ValueList>(*postcodesRoot, edge), intersector);
|
||||
|
||||
intersector.NextStep();
|
||||
}
|
||||
|
|
|
@ -728,12 +728,10 @@ UNIT_CLASS_TEST(ProcessorTest, TestPostcodes)
|
|||
}
|
||||
|
||||
{
|
||||
string const kQueries[] = {"london WC2H 7BX", "london WC2H 7", "london WC2H ", "london WC"};
|
||||
for (auto const & query : kQueries)
|
||||
{
|
||||
Rules rules{ExactMatch(countryId, building1)};
|
||||
TEST(ResultsMatch(query, rules), (query));
|
||||
}
|
||||
Rules rules{ExactMatch(countryId, building1)};
|
||||
TEST(ResultsMatch("london WC2H 7BX", rules), ());
|
||||
TEST(!ResultsMatch("london WC2H 7", rules), ());
|
||||
TEST(!ResultsMatch("london WC", rules), ());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue