diff options
author | Anatoly Serdtcev <serdtcev@maps.me> | 2019-03-07 13:54:37 +0300 |
---|---|---|
committer | Anatoly Serdtcev <serdtcev@maps.me> | 2019-03-07 13:54:37 +0300 |
commit | ea4788da28f8f2053fbc8881e115336bc6e471f7 (patch) | |
tree | d03ed2d50b79cefdef1ca41be642baccee1caaf9 /geocoder | |
parent | 8fdaabf36155e4631a25feb330798229dda8bc77 (diff) |
[geocoder] Add shuffle match ('Аэропортовская 1-я' and '1-я Аэропортовская')
Diffstat (limited to 'geocoder')
-rw-r--r-- | geocoder/index.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/geocoder/index.cpp b/geocoder/index.cpp index 21b30be043..acf9b1e5e6 100644 --- a/geocoder/index.cpp +++ b/geocoder/index.cpp @@ -8,6 +8,7 @@ #include "base/logging.hpp" #include "base/string_utils.hpp" +#include <algorithm> #include <atomic> #include <cstddef> #include <mutex> @@ -43,7 +44,12 @@ Index::Doc const & Index::GetDoc(DocId const id) const // static string Index::MakeIndexKey(Tokens const & tokens) { - return strings::JoinStrings(tokens, " "); + if (tokens.size() == 1 || std::is_sorted(begin(tokens), end(tokens))) + return strings::JoinStrings(tokens, " "); + + auto indexTokens = tokens; + std::sort(begin(indexTokens), end(indexTokens)); + return strings::JoinStrings(indexTokens, " "); } void Index::AddEntries() |