Search code examples
sqlitefull-text-searchfts4

FTS query similar to LIKE 'a%'?


Is it possible to leverage SQLite FTS index capabilities to get result similar to LIKE 'a%' query? There is MATCH 'a*' but its not the same, for example:

'hello world'
'say hello'

LIKE 'he%' would return only first record (this is what I need)

MATCH 'he*' would return both records

Is it possible to tell MATCH somehow to compare only beginnings of attributes?


Solution

  • When compiled with the enhanced query syntax, SQLite can search for the beginning of the entire string with ^, i.e., MATCH '^he*'.