diff --git a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java index 138cf9ca01..3eccfaaf1c 100644 --- a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java +++ b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java @@ -203,7 +203,9 @@ public class SearchCoreFactory { } } if (!leftUnknownSearchWords.isEmpty() && api != null && api.isSearchAvailable(phrase)) { - SearchPhrase nphrase = phrase.selectWord(res, leftUnknownSearchWords, phrase.isLastUnknownSearchWordComplete()); + SearchPhrase nphrase = phrase.selectWord(res, leftUnknownSearchWords, + phrase.isLastUnknownSearchWordComplete() || + !leftUnknownSearchWords.contains(phrase.getLastUnknownSearchWord())); SearchResult prev = resultMatcher.setParentSearchResult(publish ? res : resultMatcher.getParentSearchResult()); api.search(nphrase, resultMatcher); diff --git a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchPhrase.java b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchPhrase.java index b7050cd943..7306d2e48d 100644 --- a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchPhrase.java +++ b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchPhrase.java @@ -526,7 +526,7 @@ public class SearchPhrase { public NameStringMatcher getFirstUnknownNameStringMatcher() { if (firstUnknownNameStringMatcher == null) { - firstUnknownNameStringMatcher = getNameStringMatcher(firstUnknownSearchWord, lastUnknownSearchWordComplete); + firstUnknownNameStringMatcher = getNameStringMatcher(firstUnknownSearchWord, isFirstUnknownSearchWordComplete()); } return firstUnknownNameStringMatcher; } @@ -792,6 +792,13 @@ public class SearchPhrase { } return r; } + + public String getLastUnknownSearchWord() { + if(otherUnknownWords.size() > 0) { + return otherUnknownWords.get(otherUnknownWords.size() - 1); + } + return firstUnknownSearchWord; + } public int getRadiusSearch(int meters, int radiusLevel) { @@ -877,4 +884,6 @@ public class SearchPhrase { + + }