Fixed searching for words containing a plus/minus sign

pull/209/head
M66B 2 years ago
parent 1d435368ba
commit 2a8dae7caa

@ -839,28 +839,17 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
return false; return false;
text = Fts4DbHelper.breakText(text); text = Fts4DbHelper.breakText(text);
query = Fts4DbHelper.breakText(query);
boolean plus = false;
boolean minus = false;
List<String> word = new ArrayList<>(); List<String> word = new ArrayList<>();
for (String w : query.trim().split("\\s+")) for (String w : query.trim().split("\\s+"))
if ("+".equals(w)) if (w.length() > 1 && w.startsWith("+")) {
plus = true; if (!text.contains(Fts4DbHelper.preprocessText(w.substring(1))))
else if ("-".equals(w))
minus = true;
else {
if (plus) {
if (!text.contains(w))
return false; return false;
} else if (minus) { } else if (w.length() > 1 && w.startsWith("-")) {
if (!html && text.contains(w)) if (!html && text.contains(Fts4DbHelper.preprocessText(w.substring(1))))
return false; return false;
} else } else
word.add(w); word.addAll(Arrays.asList(Fts4DbHelper.breakText(w).split("\\s+")));
plus = false;
minus = false;
}
if (word.size() == 0) if (word.size() == 0)
return true; return true;

@ -134,7 +134,7 @@ public class Fts4DbHelper extends SQLiteOpenHelper {
db.delete("message", "rowid = ?", new String[]{Long.toString(id)}); db.delete("message", "rowid = ?", new String[]{Long.toString(id)});
} }
private static String preprocessText(String text) { static String preprocessText(String text) {
return Normalizer.normalize(text.trim().toLowerCase(), Normalizer.Form.NFKD) return Normalizer.normalize(text.trim().toLowerCase(), Normalizer.Form.NFKD)
.replaceAll("[\\p{InCombiningDiacriticalMarks}]", ""); .replaceAll("[\\p{InCombiningDiacriticalMarks}]", "");
} }

Loading…
Cancel
Save