Search code examples
sqliteandroid-sqlitematchsql-like

SQLlite comma escape in match query


I have a match query for example:

select * from items where itemdesc MATCH (',')

The data that it returns its complete non sense - something that contains semicolons, dots etc.

The like query returns a correct dataset however.

select * from items where itemdesc like ('%,%')

How do correctly return the data in the MATCH query when I have the comma - the same issue persists with apostrophes, not sure if there are more characters that the match query does not like.


Solution

  • SQlite fts4 virtual tables don't handle punctuations and they just get replaced with the space instead...

    https://www.sqlite.org/fts3.html#tokenizer

    so what i did was just declare the tokenchars:

    "tokenize=unicode61" +  " \"" +"tokenchars=.,/?!:;\\"
    

    Your actual search string you have to wrap with quotes as well - MATCH '",*"'

    it doesn't handle quotes though....