Further search POI fixes

This commit is contained in:
PaulStets 2017-09-16 13:04:22 +03:00
parent 77c91467ca
commit 0aa2d1a61a
2 changed files with 8 additions and 6 deletions

View file

@ -405,13 +405,12 @@ public class BinaryMapIndexReader {
}
String ls = rg.get(0);
if (ls.lastIndexOf('_') != -1) {
if (!ls.endsWith(".obf")) {
if (!ls.endsWith(".obf") || !ls.matches(".*\\d+.*")) {
return ls.substring(0, ls.lastIndexOf('_')).replace('_', ' ');
} else {
} else if (ls.matches("[a-zA-Z_-]+([0-9]+_*){3}[.a-z]+")){
String res = ls.substring(0, (ls.length() - 13));
return res.substring(0, res.lastIndexOf('_')).replace('_', ' ');
}
}
return ls;
}

View file

@ -572,6 +572,8 @@ public class SearchPhrase {
if (diffsByRegion.get(currFile.getRegionName()) != null) {
finalSort.addAll(diffsByRegion.get(currFile.getRegionName()));
finalSort.add(currFile);
} else {
finalSort.add(currFile);
}
}
indexes.clear();
@ -582,8 +584,9 @@ public class SearchPhrase {
private Map<String, List<BinaryMapIndexReader>> getDiffsByRegion() {
Map<String, List<BinaryMapIndexReader>> result = new HashMap<>();
List<BinaryMapIndexReader> listCopy = new ArrayList<>(indexes);
for (BinaryMapIndexReader r : listCopy) {
Iterator<BinaryMapIndexReader> it = indexes.iterator();
while (it.hasNext()) {
BinaryMapIndexReader r = it.next();
if (r.getFile().getName().matches("[a-zA-Z_-]+([0-9]+_*){3}[.a-z]+")) {
String currRegionName = r.getRegionName();
if (result.containsKey(currRegionName)) {
@ -591,7 +594,7 @@ public class SearchPhrase {
} else {
result.put(currRegionName, new ArrayList<>(Arrays.asList(r)));
}
indexes.remove(r);
it.remove();
}
}
return result;