From 03501fd739e616429275ec59ca36fdf956b65cee Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 15 Jan 2020 19:07:51 +0100 Subject: [PATCH] FTS and search --- app/src/main/java/eu/faircode/email/FtsDbHelper.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/FtsDbHelper.java b/app/src/main/java/eu/faircode/email/FtsDbHelper.java index 36f969dbfb..b45411fd2d 100644 --- a/app/src/main/java/eu/faircode/email/FtsDbHelper.java +++ b/app/src/main/java/eu/faircode/email/FtsDbHelper.java @@ -89,7 +89,17 @@ public class FtsDbHelper extends SQLiteOpenHelper { db.delete("message", "rowid = ?", new Object[]{id}); } - static List match(SQLiteDatabase db, Long folder, String search) { + static List match(SQLiteDatabase db, Long folder, String query) { + String[] parts = query.split("\\s+"); + StringBuilder sb = new StringBuilder(); + for (String part : parts) { + if (sb.length() > 0) + sb.append(" AND "); + part = part.replaceAll("\"", "\"\""); + sb.append("\"").append(part).append("\""); + } + + String search = sb.toString(); Log.i("FTS folder=" + folder + " search=" + search); List result = new ArrayList<>(); try (Cursor cursor = db.query(