Tuesday, 15 January 2013

full text search - SQLite FTS4 with preferred language -


I have a SQLite table that was produced using the FTS4 module. Each entry is listed at least twice as different languages, but still shares a unique ID (int column, not indexed). What I want to do here: I want to find words in a favorite language. I want to use the second language using the same word for a search result union. For the second search, however, I want to ignore all the entries (identified by their ID) which I previously found during the lookup. So basically I want to do this:

  with term_search1 AS (SELECT * FROM MYFTS WHERE MYFTS MATCH 'word' and language ID = 1) SELECT * to select the term_sachel1 union * MYFTS From where the MYFTS MATCH 'word' and the language id = 2 and the id is not (the word select from serial 1) ID  

The problem here is that the term_seach1 query will be executed twice. Is there a way to possibly make my results?

I also tried to use recursive questions, something like:

  plus augmented term_search1 as (SELECT * MyFts where MYFTS MATCH 'word' and language id = 1 Union All Select M. * MYFTS to M Bounger Over Terminal_Train 1T (MID = TID) where MYFTS MATCH 'term' and m.languageId = 2 and T.id IS Null Select from) * Term_ser 1 to  

This did not work either. Obviously he performed two searches for linguid 2 (is this a bug?).

Thank you in advance :)

You can count myFts to the number of queries Use temparary tables to reduce:

  create template table result (ID primary primary); Please include my favorite mate 'word' and the language id = 1 in my Feet by SELECT ID; Select my FTS from my FTS SELECT id from my FTS matte 'term' and the language id = 2 and no id (selection ID from the result); SELECT * MYFTS to WHERE ID (Results SELECT ID); Drop table results;  

If it is possible to change the schema, then you should only place text data in the FTS table. This way you will avoid the wrong result when you are searching for numbers and rows, should not match languageId to non-text data (like id and LanguageId ) and filter the row by including rowid against myFts . This way you should only ask the FTS table - Use the temporary table to store the FTS table results so order them using the meta table.


No comments:

Post a Comment