Android 中的 FTS4 查询错误
Posted
技术标签:
【中文标题】Android 中的 FTS4 查询错误【英文标题】:FTS4 query's error in Android 【发布时间】:2015-03-27 05:19:12 【问题描述】:我使用以下方法在 PC 上创建了一个 fts4 表:
CREATE VIRTUAL TABLE main USING fts4(word, definition, notindexed=definition);
在 SQLite Studio 中,我查询了一条运行正常的语句:
SELECT rowid AS _id, word, definition FROM main WHERE word MATCH 'はな*';
当我提取数据库以在我的 android 应用程序中使用时,相同的查询给出以下错误:
03-27 11:22:05.315 6789-6789/com.kradragon.minadictionary E/AndroidRuntime﹕ FATAL EXCEPTION: main
android.database.sqlite.SQLiteException: unrecognized parameter: notindexed=definition (code 1): , while compiling: SELECT rowid AS _id, word, definition FROM main WHERE word MATCH 'はな*';
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:886)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:497)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1314)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1253)
at com.kradragon.minadictionary.model.DictDatabaseHelper.queryWordsMatch(DictDatabaseHelper.java:40)
at com.kradragon.minadictionary.model.DictionaryManager.findWordsMatch(DictionaryManager.java:43)
at com.kradragon.minadictionary.ResultsListFragment$WordListCursorLoader.loadCursor(ResultsListFragment.java:141)
at com.kradragon.minadictionary.model.SqliteCursorLoader.loadInBackground(SqliteCursorLoader.java:24)
at com.kradragon.minadictionary.ResultsListFragment.queryWords(ResultsListFragment.java:47)
at com.kradragon.minadictionary.MainActivity.handleIntent(MainActivity.java:134)
at com.kradragon.minadictionary.MainActivity.onNewIntent(MainActivity.java:188)
at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1156)
at android.app.ActivityThread.deliverNewIntents(ActivityThread.java:2464)
at android.app.ActivityThread.performNewIntents(ActivityThread.java:2477)
at android.app.ActivityThread.handleNewIntent(ActivityThread.java:2486)
at android.app.ActivityThread.access$1400(ActivityThread.java:162)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1435)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5371)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
我在here 中读到了notindexed
感谢您的帮助!
【问题讨论】:
【参考方案1】:在SQLite 3.8.0 中添加了FTS notindexed
选项,而不是version of SQLite used in most Androids。
【讨论】:
以上是关于Android 中的 FTS4 查询错误的主要内容,如果未能解决你的问题,请参考以下文章
如何在android中使用Room Library fts4查询整个表
FTS4 matchinfo 不适用于 android 房间数据库