diff options
author | tatiana-yan <tatiana.kondakova@gmail.com> | 2018-08-20 18:52:07 +0300 |
---|---|---|
committer | mpimenov <mpimenov@users.noreply.github.com> | 2018-08-29 17:23:19 +0300 |
commit | d681afd8833c3986f577b3d02402edd63d22d915 (patch) | |
tree | d4fb0d7eb64a94dc9219cf6a11bcddea39681098 /search | |
parent | cf75e55bc6d96f3488af9d5977c4bee422a366c3 (diff) |
[search] Use exact preferred categories for categorial request.
Diffstat (limited to 'search')
-rw-r--r-- | search/processor.cpp | 17 | ||||
-rw-r--r-- | search/processor.hpp | 1 |
2 files changed, 10 insertions, 8 deletions
diff --git a/search/processor.cpp b/search/processor.cpp index f5ea907089..9737bbb8a7 100644 --- a/search/processor.cpp +++ b/search/processor.cpp @@ -275,8 +275,12 @@ void Processor::SetQuery(string const & query) // Get preferred types to show in results. m_preferredTypes.clear(); - ForEachCategoryType(QuerySliceOnRawStrings<decltype(m_tokens)>(m_tokens, m_prefix), - [&](size_t, uint32_t t) { m_preferredTypes.push_back(t); }); + auto const tokenSlice = QuerySliceOnRawStrings<decltype(m_tokens)>(m_tokens, m_prefix); + m_isCategorialRequest = FillCategories(tokenSlice, GetCategoryLocales(), m_categories, m_preferredTypes); + + if (!m_isCategorialRequest) + ForEachCategoryType(tokenSlice, [&](size_t, uint32_t t) { m_preferredTypes.push_back(t); }); + my::SortUnique(m_preferredTypes); } @@ -501,13 +505,10 @@ void Processor::InitParams(QueryParams & params) const params.GetTypeIndices(i).push_back(index); }; auto const tokenSlice = QuerySliceOnRawStrings<decltype(m_tokens)>(m_tokens, m_prefix); - vector<uint32_t> types; - bool const isCategorialRequest = - FillCategories(tokenSlice, GetCategoryLocales(), m_categories, types); - params.SetCategorialRequest(isCategorialRequest); - if (isCategorialRequest) + params.SetCategorialRequest(m_isCategorialRequest); + if (m_isCategorialRequest) { - for (auto const type : types) + for (auto const type : m_preferredTypes) { uint32_t const index = c.GetIndexForType(type); for (size_t i = 0; i < tokenSlice.Size(); ++i) diff --git a/search/processor.hpp b/search/processor.hpp index a62ab42f5a..152056343b 100644 --- a/search/processor.hpp +++ b/search/processor.hpp @@ -122,6 +122,7 @@ protected: std::string m_query; QueryTokens m_tokens; strings::UniString m_prefix; + bool m_isCategorialRequest; std::vector<uint32_t> m_preferredTypes; m2::RectD m_viewport; |