Domanda

I am trying to create an android like application and want to allow for quick searches so was looking into FTS for sqlite for Android. I see how to create it, but was wondering a couple of things:

Table_words - my table for words

  1. If I create a new FTS table i.e. Table_words_fts - does it replace table_words, is it added as just another table?

  2. If added as another table do I add the data at the same time to the FTS table as I do to the table_words through my code?

  3. If so can I omit some columns which are not necessary and include others that are not in the table_words table?

  4. If I am just replacing the table in number 1, then does it affect regular queries?

  5. If I am not replacing it, but do not need to store data in the new FTS table then is it just added to be able to read the table faster?

My understanding so far is the following, it is a separate table, add I add the data to it throughout my code, and I can omit some columns but not add new ones. Also, the way I would store the data would be the exact same way I add it to the other tables...

Here is my idea of working with it... Creating the table:

// create FTS tables for quicker matches for search
db.execSQL("CREATE VIRTUAL TABLE " + TABLE_WORDS_FTS + " USING fts3("
    + KEY_ID + ", " + KEY_DICTIONARYID + ", " + KEY_WORD1 + " , "
    + KEY_WORD2 + " , " + KEY_WORD3 + ", " + KEY_WORD4 + " " + ");");

Create Regular Table as well:

// Words table create statement
private static final String CREATE_TABLE_WORDS = "CREATE TABLE "
    + TABLE_WORDS + "(" + KEY_ID + " INTEGER PRIMARY KEY,"
    + KEY_DICTIONARYID + " INTEGER," + KEY_WORD1 + " TEXT," + KEY_WORD2
    + " TEXT," + KEY_WORD3 + " TEXT," + KEY_WORD4 + " TEXT" + ")";
db.execSQL(CREATE_TABLE_WORDS);

The rest I will be doing the regular way... but to recap: Trying to figure out if the Table is created additionally to the Table? If data is stored regularly in it as well?

È stato utile?

Soluzione

  1. Yes, it acts like a regular table, it does not replace existing ones.

  2. Yes, you need to add the data separately to the FTS table, but you could do with via a trigger if you want.

  3. Yes, you can have different columns.

  4. You are not replacing the original table, so it does not affect those queries. You can run regular queries against the FTS table, of course.

  5. Yes, you can create a FTS table with the content somwhere else; see Contentless FTS Tables for details.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top