Fix #5990
This commit is contained in:
parent
10f7576356
commit
a2bd1d4e3f
2 changed files with 18 additions and 10 deletions
|
@ -21,7 +21,8 @@ public class CollatorStringMatcher implements StringMatcher {
|
|||
CHECK_STARTS_FROM_SPACE,
|
||||
CHECK_STARTS_FROM_SPACE_NOT_BEGINNING,
|
||||
CHECK_EQUALS_FROM_SPACE,
|
||||
CHECK_CONTAINS
|
||||
CHECK_CONTAINS,
|
||||
CHECK_ONLY_STARTS_WITH_TRIM
|
||||
}
|
||||
|
||||
public CollatorStringMatcher(String part, StringMatcherMode mode) {
|
||||
|
@ -45,13 +46,15 @@ public class CollatorStringMatcher implements StringMatcher {
|
|||
case CHECK_CONTAINS:
|
||||
return ccontains(collator, base, part);
|
||||
case CHECK_EQUALS_FROM_SPACE:
|
||||
return cstartsWith(collator, base, part, true, true, true);
|
||||
return cstartsWith(collator, base, part, true, true, true, false);
|
||||
case CHECK_STARTS_FROM_SPACE:
|
||||
return cstartsWith(collator, base, part, true, true, false);
|
||||
return cstartsWith(collator, base, part, true, true, false, false);
|
||||
case CHECK_STARTS_FROM_SPACE_NOT_BEGINNING:
|
||||
return cstartsWith(collator, base, part, false, true, false);
|
||||
return cstartsWith(collator, base, part, false, true, false, false);
|
||||
case CHECK_ONLY_STARTS_WITH:
|
||||
return cstartsWith(collator, base, part, true, false, false);
|
||||
return cstartsWith(collator, base, part, true, false, false, false);
|
||||
case CHECK_ONLY_STARTS_WITH_TRIM:
|
||||
return cstartsWith(collator, base, part, true, false, false, true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -110,15 +113,19 @@ public class CollatorStringMatcher implements StringMatcher {
|
|||
* Special check try to find as well in the middle of name
|
||||
*
|
||||
* @param collator
|
||||
* @param searchIn
|
||||
* @param searchInParam
|
||||
* @param theStart
|
||||
* @param trim - trim theStart to searchInParam length if searchInParam non empty
|
||||
* @return true if searchIn starts with token
|
||||
*/
|
||||
public static boolean cstartsWith(Collator collator, String searchInParam, String theStart,
|
||||
boolean checkBeginning, boolean checkSpaces, boolean equals) {
|
||||
boolean checkBeginning, boolean checkSpaces, boolean equals, boolean trim) {
|
||||
String searchIn = searchInParam.toLowerCase(Locale.getDefault());
|
||||
int startLength = theStart.length();
|
||||
int searchInLength = searchIn.length();
|
||||
if (trim && searchInLength > 0 && theStart.length() > searchInLength) {
|
||||
theStart = theStart.substring(0, searchInLength);
|
||||
}
|
||||
int startLength = theStart.length();
|
||||
if (startLength == 0) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -667,7 +667,8 @@ public class SearchCoreFactory {
|
|||
categories = types.getCategories(false);
|
||||
}
|
||||
List<AbstractPoiType> results = new ArrayList<AbstractPoiType>();
|
||||
NameStringMatcher nm = phrase.getNameStringMatcher();
|
||||
NameStringMatcher nm =
|
||||
new NameStringMatcher(phrase.getUnknownSearchPhrase(), StringMatcherMode.CHECK_ONLY_STARTS_WITH_TRIM);
|
||||
for (PoiFilter pf : topVisibleFilters) {
|
||||
if (!phrase.isUnknownSearchWordPresent()
|
||||
|| nm.matches(pf.getTranslation())
|
||||
|
@ -900,7 +901,7 @@ public class SearchCoreFactory {
|
|||
res.preferredZoom = 17;
|
||||
res.file = selected;
|
||||
res.location = object.getLocation();
|
||||
res.priority = hasCustomName ? SEARCH_AMENITY_TYPE_PRIORITY - 1 : SEARCH_AMENITY_BY_TYPE_PRIORITY;
|
||||
res.priority = SEARCH_AMENITY_BY_TYPE_PRIORITY;
|
||||
res.priorityDistance = 1;
|
||||
res.objectType = ObjectType.POI;
|
||||
resultMatcher.publish(res);
|
||||
|
|
Loading…
Reference in a new issue