ft2_relevancy_algorithm¶
The
ft2_relevancy_algorithmsystem variable selects the relevance algorithm used by the FULLTEXT2 engine to rank search results. It defaults toBM25and also acceptsTF-IDF. It is distinct from the classic fulltext engine’sft_relevancy_algorithm.
The ft2_relevancy_algorithm system variable controls how the FULLTEXT2 index engine
scores matching documents. BM25 (the default) and TF-IDF are supported. Membership is
stable across the two algorithms: the set of documents that match a query does not change,
only their relative ranking does.
Syntax¶
SET SESSION ft2_relevancy_algorithm = ‘TF-IDF’; SET SESSION ft2_relevancy_algorithm = ‘BM25’;
Query the current value:
SHOW VARIABLES LIKE ‘ft2_relevancy_algorithm’; SELECT @@ft2_relevancy_algorithm;
Arguments¶
Property |
Value |
|---|---|
Variable Type |
|
Scope |
|
Dynamic |
|
Default Value |
|
Optional Value |
|
Examples¶
DROP DATABASE IF EXISTS ft2_relevancy_demo;
CREATE DATABASE ft2_relevancy_demo;
USE ft2_relevancy_demo;
SELECT @@ft2_relevancy_algorithm;
SET ft2_relevancy_algorithm = 'TF-IDF';
SELECT @@ft2_relevancy_algorithm;
SET ft2_relevancy_algorithm = 'BM25';
DROP DATABASE ft2_relevancy_demo;
Constraints¶
ft2_relevancy_algorithmapplies only to the FULLTEXT2 engine. The classic fulltext engine has its ownft_relevancy_algorithmvariable.Changing the algorithm changes document ranking, not the set of matching documents.