When querying a db with fulltext search, are the returned rows always returned in order of search relevance? And is that order stable across pagination? Iām experimenting with using datalevin as a simple file backed database for a product search service, and pagination support is quite high on the list of business requirements. š
fulltextfunction does return in the order of relevance, however, Datalog query results are sets.
Iām really enjoying how simple datalevin makes implementing search functionality, and database access in general. Next on my list of databases to try is SQLite, but that looks quite a lot more work for something that is ultimately less customisable.
after the joins, the order may have changed. Unless there's no further joins.
good thing is that fulltext function call normally execute late in the pipline, so it might be ok if you don't have other complicated query functions that involves multiple variables.
so, it really depends on your query.
Does that mean that it is important which position the fulltext has in the where clauses, or that I cannot control it? If I keep the query and inputs stable and only update the :offset value, the set of returned rows should preferably be the next page of search results as ordered by the fulltext search.
if you don't use your fulltext result variables in other clauses, and just return it, you probably can preserve the order.
no, clause order doesn't matter
you don't have control
fulltext function call will be inside variable bound clause, so it is always executed late.
Thank you, I will have to ponder this and make some experiments.
the question is, are you going to use those variables in other clauses or not
:offset will be working on the cached results, so basically it's the same results
unless you have a transaction happened in between
then cache is destroyed. However, if data is the same, the output rows are in the same order
there's no randomess
just try it
Nice! Will do. I think I want to use pull in the :find part of the query to get data about the entities returned by the fulltext, but from how I read your answers that should be fine, as long as I am not using the results from fulltext in other where clauses.
Thank you for the speedy replies! š
let me know how it goes.