diff --git a/generator/search_index_builder.cpp b/generator/search_index_builder.cpp index c87c28f6bb..10692d7575 100644 --- a/generator/search_index_builder.cpp +++ b/generator/search_index_builder.cpp @@ -18,6 +18,7 @@ #include "indexer/features_vector.hpp" #include "indexer/ftypes_matcher.hpp" #include "indexer/postcodes_matcher.hpp" +#include "indexer/road_shields_parser.hpp" #include "indexer/search_delimiters.hpp" #include "indexer/search_string_utils.hpp" #include "indexer/trie_builder.hpp" @@ -40,15 +41,15 @@ #include "base/string_utils.hpp" #include "base/timer.hpp" +#include "defines.hpp" + #include #include #include #include +#include #include #include -#include - -#include "defines.hpp" using namespace std; @@ -322,8 +323,12 @@ public: return; // Road number. - if (hasStreetType && !f.GetParams().ref.empty()) - inserter(StringUtf8Multilang::kDefaultCode, f.GetParams().ref); + if (hasStreetType && !f.GetRoadNumber().empty()) + { + auto const shields = ftypes::GetRoadShields(f); + for (auto const & shield : shields) + inserter(StringUtf8Multilang::kDefaultCode, shield.m_name); + } if (ftypes::IsAirportChecker::Instance()(types)) { diff --git a/indexer/road_shields_parser.cpp b/indexer/road_shields_parser.cpp index f6f92e4dc4..9bb8504791 100644 --- a/indexer/road_shields_parser.cpp +++ b/indexer/road_shields_parser.cpp @@ -537,7 +537,14 @@ std::set GetRoadShields(FeatureType & f) // Find out country name. std::string mwmName = f.GetID().GetMwmName(); - ASSERT_NOT_EQUAL(mwmName, FeatureID::kInvalidFileName, ()); + + // |mwmName| may be empty when GetRoadShields is called from generator. + if (mwmName == FeatureID::kInvalidFileName) + { + return SimpleRoadShieldParser(roadNumber, SimpleRoadShieldParser::ShieldTypes()) + .GetRoadShields(); + } + auto const underlinePos = mwmName.find('_'); if (underlinePos != std::string::npos) mwmName = mwmName.substr(0, underlinePos); diff --git a/search/search_integration_tests/processor_test.cpp b/search/search_integration_tests/processor_test.cpp index 82304b02ef..d5373b4bcd 100644 --- a/search/search_integration_tests/processor_test.cpp +++ b/search/search_integration_tests/processor_test.cpp @@ -2375,6 +2375,30 @@ UNIT_CLASS_TEST(ProcessorTest, StreetNumber) } } +UNIT_CLASS_TEST(ProcessorTest, StreetNumberEnriched) +{ + string const countryName = "Wonderland"; + + TestStreet street(vector{m2::PointD(-1.0, -1.0), m2::PointD(1.0, 1.0)}, "Нева", "ru"); + street.SetRoadNumber("M-11;ru:national/M-11"); + + auto countryId = + BuildCountry(countryName, [&](TestMwmBuilder & builder) { builder.Add(street); }); + + SetViewport(m2::RectD(m2::PointD(0.0, 0.0), m2::PointD(1.0, 2.0))); + { + Rules rules = {ExactMatch(countryId, street)}; + TEST(ResultsMatch("M-11 ", rules), ()); + } + + SetViewport(m2::RectD(m2::PointD(0.0, 0.0), m2::PointD(1.0, 2.0))); + { + Rules rules = {}; + TEST(ResultsMatch("ru ", rules), ()); + TEST(ResultsMatch("national ", rules), ()); + } +} + UNIT_CLASS_TEST(ProcessorTest, Postbox) { string const countryName = "Wonderland";