I have a SQLite FTS5 virtual table and am trying to highlight text in my prefix query results. I am aware of the highlight() and snippet() auxiliary functions, however they don't seem to support exactly what I am trying to do. If my data looks like:
fts.my_data
-----------
John
Mike
Bill
Jane
and I want to query using a prefix match such as
select * from fts where fts match 'j*';
The highlight and snippet functions (assuming <b>...</b>
tags) will return
<b>John</b>
<b>Jane</b>
But I only want to highlight the exact part of the prefix that was matched, before the wildcard:
<b>J</b>ohn
<b>J</b>ane
There does not seem to be any way to do this using the existing FTS5 auxiliary functions. I realize FTS5 offers an API so that you can create your own auxiliary functions. I might also be able to implement the solution in application code (I am using Swift), although I suspect this problem has the potential for a lot of issues trying to implement in application code (for example, how to handle stemming). Does anyone know if what I am trying to do is actually possible using the existing highlight and/or snippet functions before I go to the trouble of implementing my own solution? If so, could you explain how?
Also, I have observed several other existing apps (Contacts+ for example) offer this capability so I know it is possible somehow, and am also wondering how they do it if anyone knows how.