Fix poi types search
This commit is contained in:
parent
e1fb0245c6
commit
d1c2064bba
4 changed files with 22 additions and 18 deletions
|
@ -319,7 +319,7 @@ public class SearchUICore {
|
|||
SearchAmenityTypesAPI searchAmenityTypesAPI = new SearchAmenityTypesAPI(poiTypes);
|
||||
apis.add(searchAmenityTypesAPI);
|
||||
apis.add(new SearchCoreFactory.SearchAmenityByTypeAPI(poiTypes, searchAmenityTypesAPI));
|
||||
apis.add(new SearchCoreFactory.SearchAmenityByNameAPI(searchAmenityTypesAPI));
|
||||
apis.add(new SearchCoreFactory.SearchAmenityByNameAPI());
|
||||
SearchBuildingAndIntersectionsByStreetAPI streetsApi =
|
||||
new SearchCoreFactory.SearchBuildingAndIntersectionsByStreetAPI();
|
||||
apis.add(streetsApi);
|
||||
|
@ -841,7 +841,9 @@ public class SearchUICore {
|
|||
|
||||
@Override
|
||||
public int compare(SearchResult o1, SearchResult o2) {
|
||||
if (!ObjectType.isTopVisible(o1.objectType) && !ObjectType.isTopVisible(o2.objectType)) {
|
||||
boolean topVisible1 = ObjectType.isTopVisible(o1.objectType);
|
||||
boolean topVisible2 = ObjectType.isTopVisible(o2.objectType);
|
||||
if ((!topVisible1 && !topVisible2) || (topVisible1 && topVisible2)) {
|
||||
if (o1.isUnknownPhraseMatches() != o2.isUnknownPhraseMatches()) {
|
||||
return o1.isUnknownPhraseMatches() ? -1 : 1;
|
||||
} else if (o1.getFoundWordCount() != o2.getFoundWordCount()) {
|
||||
|
|
|
@ -316,6 +316,7 @@ public class SearchCoreFactory {
|
|||
String word = phrase.getUnknownWordToSearch();
|
||||
NameStringMatcher nm = phrase.getNameStringMatcher(word, phrase.isUnknownSearchWordComplete());
|
||||
NameStringMatcher wordEqualsMatcher = phrase.getNameStringMatcher(word, true);
|
||||
boolean firstUnknownWordMatches = word.equals(phrase.getUnknownSearchWord());
|
||||
resArray.clear();
|
||||
resArray = townCitiesQR.queryInBox(bbox, resArray);
|
||||
int limit = 0;
|
||||
|
@ -337,8 +338,8 @@ public class SearchCoreFactory {
|
|||
if (phrase.isEmptyQueryAllowed() && phrase.isEmpty()) {
|
||||
resultMatcher.publish(res);
|
||||
} else if (nm.matches(res.localeName) || nm.matches(res.otherNames)) {
|
||||
res.firstUnknownWordMatches = word.equals(phrase.getUnknownSearchWord());
|
||||
res.unknownPhraseMatches = wordEqualsMatcher.matches(res.localeName) || wordEqualsMatcher.matches(res.otherNames);
|
||||
res.firstUnknownWordMatches = firstUnknownWordMatches;
|
||||
res.unknownPhraseMatches = wordEqualsMatcher.matches(res.localeName);
|
||||
subSearchApiOrPublish(phrase, resultMatcher, res, cityApi);
|
||||
}
|
||||
if (limit++ > LIMIT * phrase.getRadiusLevel()) {
|
||||
|
@ -465,6 +466,7 @@ public class SearchCoreFactory {
|
|||
|
||||
String wordToSearch = phrase.getUnknownWordToSearch();
|
||||
NameStringMatcher wordEqualsMatcher = phrase.getNameStringMatcher(wordToSearch, true);
|
||||
boolean firstUnknownWordMatches = wordToSearch.equals(phrase.getUnknownSearchWord());
|
||||
while (offlineIterator.hasNext() && wordToSearch.length() > 0) {
|
||||
BinaryMapIndexReader r = offlineIterator.next();
|
||||
currentFile[0] = r;
|
||||
|
@ -478,8 +480,8 @@ public class SearchCoreFactory {
|
|||
}
|
||||
r.searchAddressDataByName(req);
|
||||
for (SearchResult res : immediateResults) {
|
||||
res.firstUnknownWordMatches = wordToSearch.equals(phrase.getUnknownSearchWord());
|
||||
res.unknownPhraseMatches = wordEqualsMatcher.matches(res.localeName) || wordEqualsMatcher.matches(res.otherNames);
|
||||
res.firstUnknownWordMatches = firstUnknownWordMatches;
|
||||
res.unknownPhraseMatches = wordEqualsMatcher.matches(res.localeName);
|
||||
if (res.objectType == ObjectType.STREET) {
|
||||
City ct = ((Street) res.object).getCity();
|
||||
phrase.countUnknownWordsMatch(res,
|
||||
|
@ -501,11 +503,9 @@ public class SearchCoreFactory {
|
|||
private static final int BBOX_RADIUS = 500 * 1000;
|
||||
private static final int BBOX_RADIUS_INSIDE = 10000 * 1000; // to support city search for basemap
|
||||
private static final int FIRST_WORD_MIN_LENGTH = 3;
|
||||
private SearchAmenityTypesAPI searchAmenityTypesAPI;
|
||||
|
||||
public SearchAmenityByNameAPI(SearchAmenityTypesAPI searchAmenityTypesAPI) {
|
||||
public SearchAmenityByNameAPI() {
|
||||
super(ObjectType.POI);
|
||||
this.searchAmenityTypesAPI = searchAmenityTypesAPI;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -574,7 +574,7 @@ public class SearchCoreFactory {
|
|||
}
|
||||
sr.priority = SEARCH_AMENITY_BY_NAME_PRIORITY;
|
||||
if (phraseMatcher != null) {
|
||||
sr.unknownPhraseMatches = phraseMatcher.matches(sr.localeName) || phraseMatcher.matches(sr.otherNames);
|
||||
sr.unknownPhraseMatches = phraseMatcher.matches(sr.localeName);
|
||||
}
|
||||
phrase.countUnknownWordsMatch(sr);
|
||||
sr.objectType = ObjectType.POI;
|
||||
|
@ -663,7 +663,7 @@ public class SearchCoreFactory {
|
|||
}
|
||||
List<AbstractPoiType> results = new ArrayList<AbstractPoiType>();
|
||||
NameStringMatcher nm =
|
||||
new NameStringMatcher(phrase.getUnknownSearchPhrase(), StringMatcherMode.CHECK_ONLY_STARTS_WITH_TRIM);
|
||||
new NameStringMatcher(phrase.getUnknownSearchPhrase(), StringMatcherMode.CHECK_STARTS_FROM_SPACE);
|
||||
for (AbstractPoiType pf : topVisibleFilters) {
|
||||
if (!phrase.isUnknownSearchWordPresent()
|
||||
|| nm.matches(pf.getTranslation())
|
||||
|
@ -710,6 +710,8 @@ public class SearchCoreFactory {
|
|||
phrase.setUnknownSearchWordPoiTypes(new ArrayList<>(results));
|
||||
|
||||
if (resultMatcher != null) {
|
||||
String word = phrase.getUnknownSearchWord();
|
||||
NameStringMatcher startMatch = new NameStringMatcher(word, StringMatcherMode.CHECK_ONLY_STARTS_WITH);
|
||||
for (AbstractPoiType pt : results) {
|
||||
SearchResult res = new SearchResult(phrase);
|
||||
res.localeName = pt.getTranslation();
|
||||
|
@ -717,6 +719,7 @@ public class SearchCoreFactory {
|
|||
res.priority = SEARCH_AMENITY_TYPE_PRIORITY;
|
||||
res.priorityDistance = 0;
|
||||
res.objectType = ObjectType.POI_TYPE;
|
||||
res.firstUnknownWordMatches = startMatch.matches(res.localeName);
|
||||
resultMatcher.publish(res);
|
||||
}
|
||||
for (int i = 0; i < customPoiFilters.size(); i++) {
|
||||
|
@ -909,7 +912,7 @@ public class SearchCoreFactory {
|
|||
res.priority = SEARCH_AMENITY_BY_TYPE_PRIORITY;
|
||||
res.priorityDistance = 1;
|
||||
if (phraseMatcher != null) {
|
||||
boolean unknownPhraseMatches = phraseMatcher.matches(res.localeName) || phraseMatcher.matches(res.otherNames);
|
||||
boolean unknownPhraseMatches = phraseMatcher.matches(res.localeName);
|
||||
AbstractPoiType unknownSearchWordPoiType = phrase.getUnknownSearchWordPoiType();
|
||||
if (unknownPhraseMatches && unknownSearchWordPoiType != null) {
|
||||
unknownPhraseMatches = !phraseMatcher.matches(unknownSearchWordPoiType.getTranslation())
|
||||
|
@ -1033,7 +1036,7 @@ public class SearchCoreFactory {
|
|||
phrase.getNameStringMatcher().matches(res.localeName) ||
|
||||
phrase.getNameStringMatcher().matches(res.otherNames);
|
||||
if (phraseMatcher != null) {
|
||||
res.unknownPhraseMatches = phraseMatcher.matches(res.localeName) || phraseMatcher.matches(res.otherNames);
|
||||
res.unknownPhraseMatches = phraseMatcher.matches(res.localeName);
|
||||
}
|
||||
res.localeRelatedObjectName = c.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
|
||||
res.object = object;
|
||||
|
|
|
@ -222,7 +222,7 @@ public class SearchCoreUITest {
|
|||
});
|
||||
if (files != null) {
|
||||
for (File f : files) {
|
||||
//testSearchImpl(f);
|
||||
testSearchImpl(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
},
|
||||
"phrase": "parking",
|
||||
"results": [
|
||||
"Park (Leisure)",
|
||||
"Parking (Filter)",
|
||||
"Parking (Personal transport)",
|
||||
"Parking entrance (Personal transport)",
|
||||
"Parking fee (Charging station / Transportation)",
|
||||
"Parking fee: no (Charging station / Transportation)",
|
||||
|
@ -21,8 +20,8 @@
|
|||
"Parking tickets (Vending machine / Store)",
|
||||
"Parking tickets (Vending machine / Store)",
|
||||
"Parking time limit (Parking / Personal transport)",
|
||||
"Parking",
|
||||
"Parking",
|
||||
"Bicycle parking (Bicycle transport)",
|
||||
"Motorcycle parking (Personal transport)",
|
||||
"Parking",
|
||||
"Parking",
|
||||
"Parking",
|
||||
|
|
Loading…
Reference in a new issue