This commit is contained in:
crimean 2018-11-28 18:16:46 +03:00
parent f56044a3b6
commit f6ff93bd5b

View file

@ -666,12 +666,15 @@ public class SearchCoreFactory {
List<AbstractPoiType> results = new ArrayList<AbstractPoiType>(); List<AbstractPoiType> results = new ArrayList<AbstractPoiType>();
NameStringMatcher nm = NameStringMatcher nm =
new NameStringMatcher(phrase.getUnknownSearchPhrase(), StringMatcherMode.CHECK_ONLY_STARTS_WITH_TRIM); new NameStringMatcher(phrase.getUnknownSearchPhrase(), StringMatcherMode.CHECK_ONLY_STARTS_WITH_TRIM);
Set<String> filters = new HashSet<>();
for (AbstractPoiType pf : topVisibleFilters) { for (AbstractPoiType pf : topVisibleFilters) {
if (!phrase.isUnknownSearchWordPresent() if (!phrase.isUnknownSearchWordPresent()
|| nm.matches(pf.getTranslation()) || nm.matches(pf.getTranslation())
|| nm.matches(pf.getEnTranslation()) || nm.matches(pf.getEnTranslation())
|| nm.matches(pf.getSynonyms())) { || nm.matches(pf.getSynonyms())) {
results.add(pf); results.add(pf);
filters.add(pf.getTranslation());
} }
} }
if (phrase.isUnknownSearchWordPresent()) { if (phrase.isUnknownSearchWordPresent()) {
@ -681,6 +684,7 @@ public class SearchCoreFactory {
|| nm.matches(c.getEnTranslation()) || nm.matches(c.getEnTranslation())
|| nm.matches(c.getSynonyms()))) { || nm.matches(c.getSynonyms()))) {
results.add(c); results.add(c);
filters.add(c.getTranslation());
} }
} }
Iterator<Entry<String, PoiType>> it = translatedNames.entrySet().iterator(); Iterator<Entry<String, PoiType>> it = translatedNames.entrySet().iterator();
@ -688,7 +692,7 @@ public class SearchCoreFactory {
Entry<String, PoiType> e = it.next(); Entry<String, PoiType> e = it.next();
PoiType pt = e.getValue(); PoiType pt = e.getValue();
if (pt.getCategory() != types.getOtherMapCategory()) { if (pt.getCategory() != types.getOtherMapCategory()) {
if (!results.contains(pt) if (!results.contains(pt) && !filters.contains(pt.getTranslation())
&& (nm.matches(pt.getEnTranslation()) && (nm.matches(pt.getEnTranslation())
|| nm.matches(pt.getTranslation()) || nm.matches(pt.getTranslation())
|| nm.matches(pt.getSynonyms()))) { || nm.matches(pt.getSynonyms()))) {