diff --git a/search/processor.cpp b/search/processor.cpp index 3f67a94166..09d998219b 100644 --- a/search/processor.cpp +++ b/search/processor.cpp @@ -314,12 +314,10 @@ void Processor::SetQuery(string const & query, bool categorialRequest /* = false } } - RemoveStopWordsIfNeeded(m_tokens, m_prefix); + QuerySliceOnRawStrings const tokenSlice(m_tokens, m_prefix); // Get preferred types to show in results. m_preferredTypes.clear(); - auto const tokenSlice = QuerySliceOnRawStrings(m_tokens, m_prefix); - m_isCategorialRequest = categorialRequest; auto const locales = GetCategoryLocales(); @@ -334,6 +332,9 @@ void Processor::SetQuery(string const & query, bool categorialRequest /* = false } } + // Remove stopwords *after* FillCategories call (it makes exact tokens match). + RemoveStopWordsIfNeeded(m_tokens, m_prefix); + if (!m_isCategorialRequest) { // Assign tokens and prefix to scorer. diff --git a/search/search_integration_tests/processor_test.cpp b/search/search_integration_tests/processor_test.cpp index 45ce3bbbee..2c660d2d18 100644 --- a/search/search_integration_tests/processor_test.cpp +++ b/search/search_integration_tests/processor_test.cpp @@ -2337,7 +2337,7 @@ UNIT_CLASS_TEST(ProcessorTest, StreetNumberEnriched) } } -UNIT_CLASS_TEST(ProcessorTest, Postbox) +UNIT_CLASS_TEST(ProcessorTest, PostcodesErrorTest) { string const countryName = "Wonderland"; @@ -3053,4 +3053,37 @@ UNIT_CLASS_TEST(ProcessorTest, BurgerStreet) } } */ + +UNIT_CLASS_TEST(ProcessorTest, PostCategoryTest) +{ + string const countryName = "Wonderland"; + + TestPOI office({0, 0}, "PO", "default"); + office.SetTypes({{"amenity", "post_office"}}); + + TestPOI box({1, 1}, "PB", "default"); + box.SetTypes({{"amenity", "post_box"}}); + + TestPOI locker({2, 2}, "PL", "default"); + locker.SetTypes({{"amenity", "parcel_locker"}}); + + auto countryId = BuildCountry(countryName, [&](TestMwmBuilder & builder) + { + builder.Add(office); + builder.Add(box); + builder.Add(locker); + }); + + SetViewport(m2::RectD(0, 0, 3, 3)); + + { + Rules rules{ExactMatch(countryId, office), ExactMatch(countryId, box), ExactMatch(countryId, locker)}; + TEST(ResultsMatch("Oficina de correos", "es", rules), ()); + } + + { + Rules rules{ExactMatch(countryId, office), ExactMatch(countryId, box), ExactMatch(countryId, locker)}; + TEST(CategoryMatch("Oficina de correos", rules, "es"), ()); + } +} } // namespace processor_test