androidx房间多匹配
androidx room multiple MATCH
我对 androidx.room 有疑问。我正在尝试在查询中使用多个 MATCH
@SuppressWarnings(RoomWarnings.CURSOR_MISMATCH)
@Query("SELECT * FROM tests WHERE task MATCH :words OR task MATCH :words2")
Maybe<List<Test>> getByWordsInTask(String words, String words2);
但它仅适用于 android 8+,在 7 上显示异常
E/SQLiteLog: (1) statement aborts at 7: [SELECT * FROM tests WHERE task MATCH ? OR task MATCH ?] unable to use function MATCH in the requested context
E/SQLiteQuery: exception: unable to use function MATCH in the requested context (code 1); query: SELECT * FROM tests WHERE task MATCH ? OR task MATCH ?
有什么建议吗?
MATCH 是特殊的 function/keyword,除了在 FTS 中使用外没有实现(可以使用 MATCH 的 Room 支持 3 或 4),根据
The MATCH operator is a special syntax for the match()
application-defined function. The default match() function
implementation raises an exception and is not really useful for
anything. But extensions can override the match() function with more
helpful logic.
https://sqlite.org/lang_expr.html#the_like_glob_regexp_and_match_operators
您将需要一个替代方法,也许是 instr 标量函数,也许是 LIKE.
I use FTS 4, all is working good when I use single MATCH, but if I use OR and 2 MATCH operators (I need it for fast, but more extended search) it works only on Android 8 and higher. I can not understand.
尝试"SELECT * FROM tests WHERE task MATCH :allwords"
其中 allwords 是用 OR(或适当的运算符)分隔的所有单词,例如说 words 是 *Fred 和 words2 是 *Mary那么 allwords 将是 Fred OR Mary;
如果可行,则可能是 Room 问题,如果是,则可能将其报告为错误
我对 androidx.room 有疑问。我正在尝试在查询中使用多个 MATCH
@SuppressWarnings(RoomWarnings.CURSOR_MISMATCH)
@Query("SELECT * FROM tests WHERE task MATCH :words OR task MATCH :words2")
Maybe<List<Test>> getByWordsInTask(String words, String words2);
但它仅适用于 android 8+,在 7 上显示异常
E/SQLiteLog: (1) statement aborts at 7: [SELECT * FROM tests WHERE task MATCH ? OR task MATCH ?] unable to use function MATCH in the requested context
E/SQLiteQuery: exception: unable to use function MATCH in the requested context (code 1); query: SELECT * FROM tests WHERE task MATCH ? OR task MATCH ?
有什么建议吗?
MATCH 是特殊的 function/keyword,除了在 FTS 中使用外没有实现(可以使用 MATCH 的 Room 支持 3 或 4),根据
The MATCH operator is a special syntax for the match() application-defined function. The default match() function implementation raises an exception and is not really useful for anything. But extensions can override the match() function with more helpful logic.
https://sqlite.org/lang_expr.html#the_like_glob_regexp_and_match_operators
您将需要一个替代方法,也许是 instr 标量函数,也许是 LIKE.
I use FTS 4, all is working good when I use single MATCH, but if I use OR and 2 MATCH operators (I need it for fast, but more extended search) it works only on Android 8 and higher. I can not understand.
尝试"SELECT * FROM tests WHERE task MATCH :allwords"
其中 allwords 是用 OR(或适当的运算符)分隔的所有单词,例如说 words 是 *Fred 和 words2 是 *Mary那么 allwords 将是 Fred OR Mary;
如果可行,则可能是 Room 问题,如果是,则可能将其报告为错误