Fix search space issue
This commit is contained in:
parent
168740b72e
commit
5e04ec4db0
2 changed files with 41 additions and 36 deletions
|
@ -530,7 +530,7 @@ public class SearchCoreFactory {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (phrase.isNoSelectedType() && phrase.isUnknownSearchWordPresent()
|
if (phrase.isNoSelectedType() && phrase.isUnknownSearchWordPresent()
|
||||||
&& phrase.isUnknownSearchWordComplete() && searchAmenityTypesAPI.hasFoundPoiTypes()) {
|
&& phrase.isUnknownSearchWordComplete() && phrase.hasUnknownSearchWordPoiTypes()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final BinaryMapIndexReader[] currentFile = new BinaryMapIndexReader[1];
|
final BinaryMapIndexReader[] currentFile = new BinaryMapIndexReader[1];
|
||||||
|
@ -653,30 +653,12 @@ public class SearchCoreFactory {
|
||||||
private List<CustomSearchPoiFilter> customPoiFilters = new ArrayList<>();
|
private List<CustomSearchPoiFilter> customPoiFilters = new ArrayList<>();
|
||||||
private TIntArrayList customPoiFiltersPriorites = new TIntArrayList();
|
private TIntArrayList customPoiFiltersPriorites = new TIntArrayList();
|
||||||
private MapPoiTypes types;
|
private MapPoiTypes types;
|
||||||
private List<AbstractPoiType> foundPoiTypes = new ArrayList<>();
|
|
||||||
private SearchPhrase lastSearchedPhrase;
|
|
||||||
|
|
||||||
public SearchAmenityTypesAPI(MapPoiTypes types) {
|
public SearchAmenityTypesAPI(MapPoiTypes types) {
|
||||||
super(ObjectType.POI_TYPE);
|
super(ObjectType.POI_TYPE);
|
||||||
this.types = types;
|
this.types = types;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AbstractPoiType> getFoundPoiTypes() {
|
|
||||||
return foundPoiTypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasFoundPoiTypes() {
|
|
||||||
return foundPoiTypes.size() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SearchPhrase getLastSearchedPhrase() {
|
|
||||||
return lastSearchedPhrase;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastSearchedPhrase(SearchPhrase lastSearchedPhrase) {
|
|
||||||
this.lastSearchedPhrase = lastSearchedPhrase;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearCustomFilters() {
|
public void clearCustomFilters() {
|
||||||
this.customPoiFilters.clear();
|
this.customPoiFilters.clear();
|
||||||
this.customPoiFiltersPriorites.clear();
|
this.customPoiFiltersPriorites.clear();
|
||||||
|
@ -739,8 +721,7 @@ public class SearchCoreFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foundPoiTypes = new ArrayList<>(results);
|
phrase.setUnknownSearchWordPoiTypes(new ArrayList<>(results));
|
||||||
lastSearchedPhrase = phrase;
|
|
||||||
|
|
||||||
if (resultMatcher != null) {
|
if (resultMatcher != null) {
|
||||||
for (AbstractPoiType pt : results) {
|
for (AbstractPoiType pt : results) {
|
||||||
|
@ -852,18 +833,16 @@ public class SearchCoreFactory {
|
||||||
}
|
}
|
||||||
searchPoi(phrase, resultMatcher, obj, null, ptf);
|
searchPoi(phrase, resultMatcher, obj, null, ptf);
|
||||||
} else if (searchAmenityTypesAPI != null) {
|
} else if (searchAmenityTypesAPI != null) {
|
||||||
if (searchAmenityTypesAPI.lastSearchedPhrase == null
|
if (phrase.getUnknownSearchWordPoiTypes() == null) {
|
||||||
|| !searchAmenityTypesAPI.lastSearchedPhrase.getUnknownSearchPhrase().equals(phrase.getUnknownSearchPhrase())) {
|
|
||||||
searchAmenityTypesAPI.search(phrase, null);
|
searchAmenityTypesAPI.search(phrase, null);
|
||||||
}
|
}
|
||||||
List<AbstractPoiType> poiTypes = searchAmenityTypesAPI.getFoundPoiTypes();
|
AbstractPoiType poiType = phrase.getUnknownSearchWordPoiType();
|
||||||
for (AbstractPoiType pt : poiTypes) {
|
if (poiType != null) {
|
||||||
SearchPoiTypeFilter ptf = getPoiTypeFilter(pt);
|
SearchPoiTypeFilter ptf = getPoiTypeFilter(poiType);
|
||||||
String customName = phrase.getPoiNameFilter(pt);
|
String customName = phrase.getPoiNameFilter(poiType);
|
||||||
if (customName != null) {
|
if (customName != null) {
|
||||||
phrase.setUnknownSearchWordPoiType(pt);
|
phrase.setUnknownSearchWordPoiType(poiType);
|
||||||
searchPoi(phrase, resultMatcher, null, customName, ptf);
|
searchPoi(phrase, resultMatcher, null, customName.length() == 0 ? null : customName, ptf);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -939,7 +918,14 @@ public class SearchCoreFactory {
|
||||||
res.priority = SEARCH_AMENITY_BY_TYPE_PRIORITY;
|
res.priority = SEARCH_AMENITY_BY_TYPE_PRIORITY;
|
||||||
res.priorityDistance = 1;
|
res.priorityDistance = 1;
|
||||||
if (phraseMatcher != null) {
|
if (phraseMatcher != null) {
|
||||||
res.unknownPhraseMatches = phraseMatcher.matches(res.localeName) || phraseMatcher.matches(res.otherNames);
|
boolean unknownPhraseMatches = phraseMatcher.matches(res.localeName) || phraseMatcher.matches(res.otherNames);
|
||||||
|
AbstractPoiType unknownSearchWordPoiType = phrase.getUnknownSearchWordPoiType();
|
||||||
|
if (unknownPhraseMatches && unknownSearchWordPoiType != null) {
|
||||||
|
unknownPhraseMatches = !phraseMatcher.matches(unknownSearchWordPoiType.getTranslation())
|
||||||
|
&& !phraseMatcher.matches(unknownSearchWordPoiType.getEnTranslation())
|
||||||
|
&& !phraseMatcher.matches(unknownSearchWordPoiType.getSynonyms());
|
||||||
|
}
|
||||||
|
res.unknownPhraseMatches = unknownPhraseMatches;
|
||||||
}
|
}
|
||||||
res.objectType = ObjectType.POI;
|
res.objectType = ObjectType.POI;
|
||||||
resultMatcher.publish(res);
|
resultMatcher.publish(res);
|
||||||
|
@ -988,7 +974,7 @@ public class SearchCoreFactory {
|
||||||
@Override
|
@Override
|
||||||
public int getSearchPriority(SearchPhrase p) {
|
public int getSearchPriority(SearchPhrase p) {
|
||||||
if ((p.isLastWord(ObjectType.POI_TYPE) && p.getLastTokenLocation() != null)
|
if ((p.isLastWord(ObjectType.POI_TYPE) && p.getLastTokenLocation() != null)
|
||||||
|| (p.isNoSelectedType() && p.isUnknownSearchWordComplete())) {
|
|| (p.isNoSelectedType())) {
|
||||||
return SEARCH_AMENITY_BY_TYPE_PRIORITY;
|
return SEARCH_AMENITY_BY_TYPE_PRIORITY;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class SearchPhrase {
|
||||||
private String rawUnknownSearchPhrase = "";
|
private String rawUnknownSearchPhrase = "";
|
||||||
private String unknownSearchPhrase = "";
|
private String unknownSearchPhrase = "";
|
||||||
private AbstractPoiType unknownSearchWordPoiType;
|
private AbstractPoiType unknownSearchWordPoiType;
|
||||||
|
private List<AbstractPoiType> unknownSearchWordPoiTypes = null;
|
||||||
|
|
||||||
private NameStringMatcher sm;
|
private NameStringMatcher sm;
|
||||||
private SearchSettings settings;
|
private SearchSettings settings;
|
||||||
|
@ -186,7 +187,7 @@ public class SearchPhrase {
|
||||||
|
|
||||||
|
|
||||||
public boolean isUnknownSearchWordComplete() {
|
public boolean isUnknownSearchWordComplete() {
|
||||||
return lastUnknownSearchWordComplete || unknownWords.size() > 0;
|
return lastUnknownSearchWordComplete || unknownWords.size() > 0 || unknownSearchWordPoiType != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLastUnknownSearchWordComplete() {
|
public boolean isLastUnknownSearchWordComplete() {
|
||||||
|
@ -248,6 +249,24 @@ public class SearchPhrase {
|
||||||
return getPoiNameFilter(unknownSearchWordPoiType);
|
return getPoiNameFilter(unknownSearchWordPoiType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasUnknownSearchWordPoiTypes() {
|
||||||
|
return unknownSearchWordPoiTypes != null && unknownSearchWordPoiTypes.size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AbstractPoiType> getUnknownSearchWordPoiTypes() {
|
||||||
|
return unknownSearchWordPoiTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnknownSearchWordPoiTypes(List<AbstractPoiType> unknownSearchWordPoiTypes) {
|
||||||
|
this.unknownSearchWordPoiTypes = unknownSearchWordPoiTypes;
|
||||||
|
for (AbstractPoiType pt : unknownSearchWordPoiTypes) {
|
||||||
|
if (getPoiNameFilter(pt) != null) {
|
||||||
|
setUnknownSearchWordPoiType(pt);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getPoiNameFilter(AbstractPoiType pt) {
|
public String getPoiNameFilter(AbstractPoiType pt) {
|
||||||
String nameFilter = null;
|
String nameFilter = null;
|
||||||
if (pt != null) {
|
if (pt != null) {
|
||||||
|
@ -256,11 +275,11 @@ public class SearchPhrase {
|
||||||
String enTranslation = pt.getEnTranslation();
|
String enTranslation = pt.getEnTranslation();
|
||||||
String translation = pt.getTranslation();
|
String translation = pt.getTranslation();
|
||||||
String synonyms = pt.getSynonyms();
|
String synonyms = pt.getSynonyms();
|
||||||
if (unknownSearchPhrase.length() > enTranslation.length() && nm.matches(enTranslation)) {
|
if (unknownSearchPhrase.length() >= enTranslation.length() && nm.matches(enTranslation)) {
|
||||||
nameFilter = unknownSearchPhrase.substring(enTranslation.length()).trim();
|
nameFilter = unknownSearchPhrase.substring(enTranslation.length()).trim();
|
||||||
} else if (unknownSearchPhrase.length() > translation.length() && nm.matches(translation)) {
|
} else if (unknownSearchPhrase.length() >= translation.length() && nm.matches(translation)) {
|
||||||
nameFilter = unknownSearchPhrase.substring(translation.length()).trim();
|
nameFilter = unknownSearchPhrase.substring(translation.length()).trim();
|
||||||
} else if (unknownSearchPhrase.length() > synonyms.length() && nm.matches(synonyms)) {
|
} else if (unknownSearchPhrase.length() >= synonyms.length() && nm.matches(synonyms)) {
|
||||||
nameFilter = unknownSearchPhrase.substring(synonyms.length()).trim();
|
nameFilter = unknownSearchPhrase.substring(synonyms.length()).trim();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue