Skip to content

Commit

Permalink
fix search brands
Browse files Browse the repository at this point in the history
  • Loading branch information
alisa911 committed Dec 12, 2024
1 parent ba113f7 commit 1e6e73a
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,7 @@ private TopIndexMatch matchTopIndex(BinaryMapIndexReader r, SearchPhrase phrase)
List<PoiSubType> poiSubTypes = r.getTopIndexSubTypes();
String lang = phrase.getSettings().getLang();
List<TopIndexMatch> matches = new ArrayList<>();
Collator collator = OsmAndCollator.primaryCollator();
NameStringMatcher nm = new NameStringMatcher(search, CHECK_ONLY_STARTS_WITH);
for (PoiSubType subType : poiSubTypes) {
String topIndexValue = null;
Expand All @@ -1133,14 +1134,13 @@ private TopIndexMatch matchTopIndex(BinaryMapIndexReader r, SearchPhrase phrase)
Collections.sort(possibleValues);
for (String s : possibleValues) {
translate = getTopIndexTranslation(s);
String normalizeBrand = s.toLowerCase(Locale.ROOT);
if (complete) {
CollatorStringMatcher csm = new CollatorStringMatcher(s, StringMatcherMode.CHECK_ONLY_STARTS_WITH);
if (csm.matches(search)) {
if (CollatorStringMatcher.cmatches(collator, search, normalizeBrand, StringMatcherMode.CHECK_ONLY_STARTS_WITH)) {
topIndexValue = s;
break;
} else {
csm = new CollatorStringMatcher(translate, StringMatcherMode.CHECK_ONLY_STARTS_WITH);
if (csm.matches(search)) {
if (CollatorStringMatcher.cmatches(collator, search, translate, StringMatcherMode.CHECK_ONLY_STARTS_WITH)) {
topIndexValue = s;
break;
}
Expand Down Expand Up @@ -1172,7 +1172,7 @@ private TopIndexMatch matchTopIndex(BinaryMapIndexReader r, SearchPhrase phrase)
private String getTopIndexTranslation(String value) {
String key = TopIndexFilter.getValueKey(value);
String translate = types.getPoiTranslation(key);
if (translate.toLowerCase().equals(key)) {
if (translate.toLowerCase(Locale.ROOT).equals(key)) {
translate = value;
}
return translate;
Expand Down

0 comments on commit 1e6e73a

Please sign in to comment.