I am using sqlite FTS3 database, with my Android application.
public Cursor getWordMatches(String query, String[] columns) {
String selection = KEY_WORD + " MATCH ?";
String[] selectionArgs = new String[] {query+"*"};
return query(selection, selectionArgs, columns);
}
.....
private Cursor query(String selection, String[] selectionArgs, String[] columns) {
SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
builder.setTables(FTS_VIRTUAL_TABLE);
builder.setProjectionMap(mColumnMap);
Cursor cursor = builder.query(mDatabaseOpenHelper.getReadableDatabase(),
columns, selection, selectionArgs, null, null, null);
if (cursor == null) {
return null;
} else if (!cursor.moveToFirst()) {
cursor.close();
return null;
}
return cursor;
}
If I make a query and search for 'house' I will get:
household
house
apartment house
big house
(I am getting everything that has house in it, in regex house)
How can I get this kind of result for my query?
household
house
(So i only want results that start with house, in regex house*)
My android application FORCE CLOSES if I use LIKE statement(maybe because db has 200000 rows). So should I somehow combine MATCH and LIKE statement? Is it even possible to do this on Android, if it is not maybe I should try to run some regex on cursor after I get it from this query?