diff --git a/data/categories.txt b/data/categories.txt index f71add89a5..ece209eaa8 100644 --- a/data/categories.txt +++ b/data/categories.txt @@ -4,7 +4,7 @@ ru:2банкомат|наличка amenity-bank en:bank -ru:банк +ru:1банк amenity-bar|amenity-pub en:1bar|pub|beer diff --git a/search/intermediate_result.cpp b/search/intermediate_result.cpp index 79ecba683c..acf82ed4d7 100644 --- a/search/intermediate_result.cpp +++ b/search/intermediate_result.cpp @@ -37,9 +37,9 @@ IntermediateResult::IntermediateResult(m2::RectD const & viewportRect, m_direction = ResultDirection(viewportRect.Center(), m_rect.Center()); } -IntermediateResult::IntermediateResult(string name, string completionString) +IntermediateResult::IntermediateResult(string name, string completionString, int penalty) : m_str(name), m_completionString(completionString), - m_matchPenalty(0), m_minVisibleScale(0), m_distance(0), m_direction(0), + m_matchPenalty(0), m_minVisibleScale(penalty), m_distance(0), m_direction(0), m_resultType(RESULT_CATEGORY) { } diff --git a/search/intermediate_result.hpp b/search/intermediate_result.hpp index 303f4bea20..af2fee2f32 100644 --- a/search/intermediate_result.hpp +++ b/search/intermediate_result.hpp @@ -28,7 +28,7 @@ public: IntermediateResult(m2::RectD const & viewportRect, double lat, double lon, double precision); // For RESULT_CATEGORY. - IntermediateResult(string name, string completionString); + IntermediateResult(string name, string completionString, int penalty); bool operator < (IntermediateResult const & o) const; diff --git a/search/query.cpp b/search/query.cpp index 4c4b142050..fe9d6fe215 100644 --- a/search/query.cpp +++ b/search/query.cpp @@ -157,8 +157,15 @@ void Query::Search(function const & f) if (matcher.GetPrefixMatchScore() <= GetMaxPrefixMatchScore(m_prefix.size()) && matcher.GetMatchScore() <= GetMaxKeywordMatchScore()) { + int minPrefixMatchLength = 0; + for (vector::const_iterator iName = iCategory->m_synonyms.begin(); + iName != iCategory->m_synonyms.end(); ++iName) + if (iName->m_Name == matcher.GetBestMatchName()) + minPrefixMatchLength = iName->m_prefixLengthToSuggest; + AddResult(IntermediateResult(matcher.GetBestMatchName(), - matcher.GetBestMatchName() + ' ')); + matcher.GetBestMatchName() + ' ', + minPrefixMatchLength)); } } }