Slightly limit additional poi categoreis
This commit is contained in:
parent
b540b5b2e7
commit
4727143bbe
1 changed files with 14 additions and 9 deletions
|
@ -710,7 +710,7 @@ public class SearchCoreFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, PoiTypeResult> getPoiTypeResults(NameStringMatcher nm, boolean includeAdditionals) {
|
public Map<String, PoiTypeResult> getPoiTypeResults(NameStringMatcher nm, NameStringMatcher nmAdditional) {
|
||||||
Map<String, PoiTypeResult> results = new LinkedHashMap<>();
|
Map<String, PoiTypeResult> results = new LinkedHashMap<>();
|
||||||
for (AbstractPoiType pf : topVisibleFilters) {
|
for (AbstractPoiType pf : topVisibleFilters) {
|
||||||
PoiTypeResult res = checkPoiType(nm, pf);
|
PoiTypeResult res = checkPoiType(nm, pf);
|
||||||
|
@ -718,16 +718,16 @@ public class SearchCoreFactory {
|
||||||
results.put(res.pt.getKeyName(), res);
|
results.put(res.pt.getKeyName(), res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (includeAdditionals) {
|
if (nmAdditional != null) {
|
||||||
addAditonals(nm, results, types.getOtherMapCategory());
|
addAditonals(nmAdditional, results, types.getOtherMapCategory());
|
||||||
}
|
}
|
||||||
for (PoiCategory c : categories) {
|
for (PoiCategory c : categories) {
|
||||||
PoiTypeResult res = checkPoiType(nm, c);
|
PoiTypeResult res = checkPoiType(nm, c);
|
||||||
if(res != null) {
|
if(res != null) {
|
||||||
results.put(res.pt.getKeyName(), res);
|
results.put(res.pt.getKeyName(), res);
|
||||||
}
|
}
|
||||||
if (includeAdditionals) {
|
if (nmAdditional != null) {
|
||||||
addAditonals(nm, results, c);
|
addAditonals(nmAdditional, results, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Iterator<Entry<String, PoiType>> it = translatedNames.entrySet().iterator();
|
Iterator<Entry<String, PoiType>> it = translatedNames.entrySet().iterator();
|
||||||
|
@ -739,8 +739,8 @@ public class SearchCoreFactory {
|
||||||
if(res != null) {
|
if(res != null) {
|
||||||
results.put(res.pt.getKeyName(), res);
|
results.put(res.pt.getKeyName(), res);
|
||||||
}
|
}
|
||||||
if (includeAdditionals) {
|
if (nmAdditional != null) {
|
||||||
addAditonals(nm, results, pt);
|
addAditonals(nmAdditional, results, pt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -821,6 +821,7 @@ public class SearchCoreFactory {
|
||||||
public boolean search(SearchPhrase phrase, SearchResultMatcher resultMatcher) throws IOException {
|
public boolean search(SearchPhrase phrase, SearchResultMatcher resultMatcher) throws IOException {
|
||||||
boolean showTopFiltersOnly = !phrase.isUnknownSearchWordPresent();
|
boolean showTopFiltersOnly = !phrase.isUnknownSearchWordPresent();
|
||||||
NameStringMatcher nm = phrase.getFirstUnknownNameStringMatcher();
|
NameStringMatcher nm = phrase.getFirstUnknownNameStringMatcher();
|
||||||
|
|
||||||
initPoiTypes();
|
initPoiTypes();
|
||||||
if (showTopFiltersOnly) {
|
if (showTopFiltersOnly) {
|
||||||
for (AbstractPoiType pt : topVisibleFilters) {
|
for (AbstractPoiType pt : topVisibleFilters) {
|
||||||
|
@ -832,7 +833,9 @@ public class SearchCoreFactory {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
boolean includeAdditional = !phrase.hasMoreThanOneUnknownSearchWord();
|
boolean includeAdditional = !phrase.hasMoreThanOneUnknownSearchWord();
|
||||||
Map<String, PoiTypeResult> poiTypes = getPoiTypeResults(nm, includeAdditional);
|
NameStringMatcher nmAdditional = includeAdditional ?
|
||||||
|
new NameStringMatcher(phrase.getFirstUnknownSearchWord(), StringMatcherMode.CHECK_EQUALS_FROM_SPACE) : null;
|
||||||
|
Map<String, PoiTypeResult> poiTypes = getPoiTypeResults(nm, nmAdditional);
|
||||||
for (PoiTypeResult ptr : poiTypes.values()) {
|
for (PoiTypeResult ptr : poiTypes.values()) {
|
||||||
boolean match = !phrase.isFirstUnknownSearchWordComplete();
|
boolean match = !phrase.isFirstUnknownSearchWordComplete();
|
||||||
if (!match) {
|
if (!match) {
|
||||||
|
@ -972,8 +975,10 @@ public class SearchCoreFactory {
|
||||||
nameFilter = phrase.getUnknownSearchPhrase();
|
nameFilter = phrase.getUnknownSearchPhrase();
|
||||||
} else if (searchAmenityTypesAPI != null && phrase.isFirstUnknownSearchWordComplete()) {
|
} else if (searchAmenityTypesAPI != null && phrase.isFirstUnknownSearchWordComplete()) {
|
||||||
NameStringMatcher nm = phrase.getFirstUnknownNameStringMatcher();
|
NameStringMatcher nm = phrase.getFirstUnknownNameStringMatcher();
|
||||||
|
NameStringMatcher nmAdditional = new NameStringMatcher(phrase.getFirstUnknownSearchWord(),
|
||||||
|
StringMatcherMode.CHECK_EQUALS_FROM_SPACE) ;
|
||||||
searchAmenityTypesAPI.initPoiTypes();
|
searchAmenityTypesAPI.initPoiTypes();
|
||||||
Map<String, PoiTypeResult> poiTypeResults = searchAmenityTypesAPI.getPoiTypeResults(nm, true);
|
Map<String, PoiTypeResult> poiTypeResults = searchAmenityTypesAPI.getPoiTypeResults(nm, nmAdditional);
|
||||||
// find first full match only
|
// find first full match only
|
||||||
for (PoiTypeResult poiTypeResult : poiTypeResults.values()) {
|
for (PoiTypeResult poiTypeResult : poiTypeResults.values()) {
|
||||||
for (String foundName : poiTypeResult.foundWords) {
|
for (String foundName : poiTypeResult.foundWords) {
|
||||||
|
|
Loading…
Reference in a new issue