| 306 | |
| 307 | template <typename ValueList, typename Filter, typename ToDo> |
| 308 | void MatchPostcodesInTrie(TokenSlice const & slice, trie::Iterator<ValueList> const & trieRoot, Filter const & filter, |
| 309 | ToDo && toDo) |
| 310 | { |
| 311 | using namespace strings; |
| 312 | using Value = typename ValueList::Value; |
| 313 | |
| 314 | uint32_t langIx = 0; |
| 315 | if (!impl::FindLangIndex(trieRoot, search::kPostcodesLang, langIx)) |
| 316 | return; |
| 317 | |
| 318 | auto const & edge = trieRoot.m_edges[langIx].m_label; |
| 319 | auto const postcodesRoot = trieRoot.GoToEdge(langIx); |
| 320 | |
| 321 | impl::OffsetIntersector<Filter, Value> intersector(filter); |
| 322 | for (size_t i = 0; i < slice.Size(); ++i) |
| 323 | { |
| 324 | // Full match required even for prefix token. Reasons: |
| 325 | // 1. For postcode every symbol is important, partial matching can lead to wrong results. |
| 326 | // 2. For prefix match query like "streetname 40" where |streetname| is located in 40xxx |
| 327 | // postcode zone will give all street vicinity as the result which is wrong. |
| 328 | std::vector<UniStringDFA> dfas; |
| 329 | slice.Get(i).ForOriginalAndSynonyms([&dfas](UniString const & s) { dfas.emplace_back(s); }); |
| 330 | MatchInTrie(dfas, TrieRootPrefix<ValueList>(*postcodesRoot, edge), intersector); |
| 331 | |
| 332 | intersector.NextStep(); |
| 333 | } |
| 334 | |
| 335 | intersector.ForEachResult(toDo); |
| 336 | } |
| 337 | } // namespace search |
no test coverage detected