diff --git a/OsmAnd-java/src/main/java/net/osmand/search/core/ObjectType.java b/OsmAnd-java/src/main/java/net/osmand/search/core/ObjectType.java index 9844f52646..c14d5cff07 100644 --- a/OsmAnd-java/src/main/java/net/osmand/search/core/ObjectType.java +++ b/OsmAnd-java/src/main/java/net/osmand/search/core/ObjectType.java @@ -55,11 +55,11 @@ public enum ObjectType { return 4; case STREET: return 3; - case POI: - return 2; case CITY: case VILLAGE: case POSTCODE: + return 2; + case POI: return 1; default: return 1; 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 c72dd84079..79d11a3fe0 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 @@ -49,13 +49,14 @@ public class SearchResult { // maximum corresponds to the top entry public double getUnknownPhraseMatchWeight() { - // if result is a complete match in the search we prioritize it highers + // if result is a complete match in the search we prioritize it higher return getSumPhraseMatchWeight() / Math.pow(MAX_TYPE_WEIGHT, getDepth() - 1); } public double getSumPhraseMatchWeight() { - // if result is a complete match in the search we prioritize it highers - double res = ObjectType.getTypeWeight(objectType); + // if result is a complete match in the search we prioritize it higher + boolean match = requiredSearchPhrase.countWords(localeName) <= getSelfWordCount(); + double res = ObjectType.getTypeWeight(match ? objectType : null); if (parentSearchResult != null) { res = res + parentSearchResult.getSumPhraseMatchWeight() / MAX_TYPE_WEIGHT; } @@ -70,6 +71,14 @@ public class SearchResult { } public int getFoundWordCount() { + int inc = getSelfWordCount(); + if (parentSearchResult != null) { + inc += parentSearchResult.getFoundWordCount(); + } + return inc; + } + + private int getSelfWordCount() { int inc = 0; if (firstUnknownWordMatches) { inc = 1; @@ -77,9 +86,6 @@ public class SearchResult { if (otherWordsMatch != null) { inc += otherWordsMatch.size(); } - if (parentSearchResult != null) { - inc += parentSearchResult.getFoundWordCount(); - } return inc; }