SQLite Forum

Offsets function for FTS5, any ready-to-use or sample implementation?
Login
> I read from the SQLite document that the offsets function might be added in the future, so what's the estimated time frame, if any?

Huh. Where does it say that?

> Anyone can point me to any custom offsets implementations for FTS5 so that i can port it to my language?

I don't know of one. You would need to create a function like this one:

[](https://sqlite.org/fts5.html#custom_auxiliary_functions)

That uses the xInstCount(), xInst(), xColumnText() and xTokenize() methods to figure out the byte offsets of each matching phrase:

[](https://sqlite.org/fts5.html#xTokenize)

I think the implementation would have a lot in common with the implementation of the built-in highlight() function:

[](https://sqlite.org/src/info/f558e1fb9f0?ln=108-247)