mercredi 2 mars 2016

SQLite full text search, sorting by bm25 auxiliary function

Using the FTS5 extension in SQLite, I'm trying to implement sorting using the bm25 auxiliary function as mentioned here in the SQLite docs: http://ift.tt/1p0bLrm.

The docs state that:

The first argument passed to bm25() following the table name is the weight assigned to the leftmost column of the FTS5 table. The second is the weight assigned to the second leftmost column, and so on. If there are not enough arguments for all table columns, remaining columns are assigned a weight of 1.0.

but it's not clear about unindexed columns.

For example, if I create a a full text search table with the following SQL statement:

CREATE VIRTUAL TABLE email USING fts5(sender unindexed, title, body, foo);

Do I then still need to list the unindexed column in the bm25 function? For example, lets say I wanted to give the body column a weight of 4.0, would I still need to list the sender column like this:

SELECT * FROM email WHERE email MATCH ? ORDER BY bm25(email, 1.0, 1.0, 4.0);

Or can I ignore the unindexed column like this:

SELECT * FROM email WHERE email MATCH ? ORDER BY bm25(email, 1.0, 4.0);

Aucun commentaire:

Enregistrer un commentaire