select * from documents where timestamp=today() order by similarity(embedding, query_vector)
In this case the query planner should be smart enough such that it first filters by timestamp and within those records remaining it does the HNSW search. I'm unsure whether SQLite's extension interface is flexible enough to support this.
You can do it, but you need to manually filter from the main table then subquery the fts index, or use a join, etc. It's powerful but the interface isn't as friendly as it could be in that way.
The sqlite extension system is powerful enough that an extension could unify the behaviors as you describe. It's just not how the fts5 extension interface is exposed, and afaik no one has written an extension on top of it to make it easier to use.
I think it is, if I've understood your requirements correctly. e.g. from the datasette-faiss docs:
with related as (
select value from json_each(
faiss_search(
'intranet',
'embeddings',
(select embedding from embeddings where id = :id),
5
)
)
)
select id, title from articles, related
where id = valueMore info: https://www.sqlite.org/vtab.html#the_xbestindex_method