diff --git a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchResult.java b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchResult.java index 79d11a3fe0..60269fe5d4 100644 --- a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchResult.java +++ b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchResult.java @@ -55,7 +55,9 @@ public class SearchResult { public double getSumPhraseMatchWeight() { // if result is a complete match in the search we prioritize it higher - boolean match = requiredSearchPhrase.countWords(localeName) <= getSelfWordCount(); + int localWordsMatched = alternateName != null ? + requiredSearchPhrase.countWords(alternateName) : requiredSearchPhrase.countWords(localeName) ; + boolean match = localWordsMatched <= getSelfWordCount(); double res = ObjectType.getTypeWeight(match ? objectType : null); if (parentSearchResult != null) { res = res + parentSearchResult.getSumPhraseMatchWeight() / MAX_TYPE_WEIGHT; diff --git a/OsmAnd-java/src/test/java/net/osmand/search/SearchUICoreTest.java b/OsmAnd-java/src/test/java/net/osmand/search/SearchUICoreTest.java index f3ed25ca0b..07e7339401 100644 --- a/OsmAnd-java/src/test/java/net/osmand/search/SearchUICoreTest.java +++ b/OsmAnd-java/src/test/java/net/osmand/search/SearchUICoreTest.java @@ -80,9 +80,9 @@ public class SearchUICoreTest { if (files != null) { for (File file : files) { String fileName = file.getName(); - if(fileName.endsWith(".json")) { + if (fileName.endsWith(".json")) { String name = fileName.substring(0, fileName.length() - ".json".length()); - arrayList.add(new Object[] {name, file}); + arrayList.add(new Object[] { name, file }); } } } @@ -191,10 +191,10 @@ public class SearchUICoreTest { if (!Algorithms.stringsEqual(expected, present)) { System.out.println(String.format("Phrase: %s", phrase)); System.out.println(String.format("Mismatch for '%s' != '%s'. Result: ", expected, present)); + } for (SearchResult r : searchResults) { System.out.println(String.format("\t\"%s\",", formatResult(false, r, phrase))); } - } Assert.assertEquals(expected, present); } }