Simplified local search

pull/209/head
M66B 2 years ago
parent baea82764d
commit 9bfba36a23

@ -1146,8 +1146,7 @@ This will result in searching like this:
("apple" AND "banana" AND NOT "cherry") OR "nuts" ("apple" AND "banana" AND NOT "cherry") OR "nuts"
``` ```
Search expressions can be used for searching on the device via the search index and for searching on the email server, Search expressions can be used for searching on the email server only, and not for searching on the device.
but not for searching on the device without search index for performance reasons.
Since version 1.1733 it is possible to save searches, which means that a named entry in the navigation menu will be created to repeat the same search later. Since version 1.1733 it is possible to save searches, which means that a named entry in the navigation menu will be created to repeat the same search later.
You can save a search after searching by tapping on the save button in the top action bar. You can save a search after searching by tapping on the save button in the top action bar.

@ -189,62 +189,7 @@ public class Fts4DbHelper extends SQLiteOpenHelper {
Long account, Long folder, long[] exclude, Long account, Long folder, long[] exclude,
BoundaryCallbackMessages.SearchCriteria criteria) { BoundaryCallbackMessages.SearchCriteria criteria) {
String query = breakText(criteria.query); String search = escape(breakText(criteria.query));
List<String> word = new ArrayList<>();
List<String> plus = new ArrayList<>();
List<String> minus = new ArrayList<>();
List<String> opt = new ArrayList<>();
StringBuilder all = new StringBuilder();
for (String w : query.split("\\s+")) {
if (all.length() > 0)
all.append(' ');
if (w.length() > 1 && w.startsWith("+")) {
plus.add(w.substring(1));
all.append(w.substring(1));
} else if (w.length() > 1 && w.startsWith("-")) {
minus.add(w.substring(1));
all.append(w.substring(1));
} else if (w.length() > 1 && w.startsWith("?")) {
opt.add(w.substring(1));
all.append(w.substring(1));
} else {
word.add(w);
all.append(w);
}
}
StringBuilder sb = new StringBuilder();
if (plus.size() + minus.size() + opt.size() > 0) {
if (word.size() > 0)
sb.append(escape(TextUtils.join(" ", word)));
for (String p : plus) {
if (sb.length() > 0)
sb.append(" AND ");
sb.append(escape(p));
}
for (String m : minus) {
if (sb.length() > 0)
sb.append(" NOT ");
sb.append(escape(m));
}
if (sb.length() > 0) {
sb.insert(0, '(');
sb.append(')');
}
for (String o : opt) {
if (sb.length() > 0)
sb.append(" OR ");
sb.append(escape(o));
}
}
String search = (sb.length() > 0 ? sb.toString() : escape(query));
String select = ""; String select = "";
if (account != null) if (account != null)
@ -280,7 +225,7 @@ public class Fts4DbHelper extends SQLiteOpenHelper {
} }
private static String escape(String word) { private static String escape(String word) {
return "\"" + word.replaceAll("\"", "\"\"") + "\""; return "'" + word.replaceAll("'", "''") + "'";
} }
static Cursor getIds(SQLiteDatabase db) { static Cursor getIds(SQLiteDatabase db) {

Loading…
Cancel
Save