Настройка пользовательской функции ранжирования

Здравствуйте.

Я использую следующую функцию для ранжирования: ranker=expr(‘(sum(lcs+4*exact_hit)*1000/(1+sum(word_count)))’), но она плохо справляется, когда у документа короткий заголовок. Например, при запросе: “закон о связи”, документ с заголовком “О внесении изменений в Федеральный закон “О связи”” - ранжируется выше, чем документ “О связи”, каким образом можно модифицировать функцию с помощью показателей, предложенных здесь: Manticore Search Manual: Searching > Sorting and ranking, чтобы документ ранжировался выше?

Здравствуйте. Попробуйте Manticore Search Manual: Creating a table > NLP and tokenization > Low-level tokenization

Сравните:

mysql> drop table if exists t; create table t(f text) index_field_lengths='1'; insert into t values(1, 'a'),(2, 'a a'); select *, weight() from t where match('a') option ranker=expr('bm25f(1.2, 0.75)*1000');
--------------
drop table if exists t
--------------

Query OK, 0 rows affected (0.01 sec)

--------------
create table t(f text) index_field_lengths='1'
--------------

Query OK, 0 rows affected (0.00 sec)

--------------
insert into t values(1, 'a'),(2, 'a a')
--------------

Query OK, 2 rows affected (0.00 sec)

--------------
select *, weight() from t where match('a') option ranker=expr('bm25f(1.2, 0.75)*1000')
--------------

+------+------+-------+----------+
| id   | f    | f_len | weight() |
+------+------+-------+----------+
|    1 | a    | 1     |      184 |
|    2 | a a  | 2     |      161 |
+------+------+-------+----------+
2 rows in set (0.00 sec)
--- 2 out of 2 results in 0ms ---

mysql> drop table if exists t; create table t(f text) index_field_lengths='0'; insert into t values(1, 'a'),(2, 'a a'); select *, weight() from t where match('a') option ranker=expr('bm25f(1.2, 0.75)*1000');
--------------
drop table if exists t
--------------

Query OK, 0 rows affected (0.01 sec)

--------------
create table t(f text) index_field_lengths='0'
--------------

Query OK, 0 rows affected (0.00 sec)

--------------
insert into t values(1, 'a'),(2, 'a a')
--------------

Query OK, 2 rows affected (0.01 sec)

--------------
select *, weight() from t where match('a') option ranker=expr('bm25f(1.2, 0.75)*1000')
--------------

+------+------+----------+
| id   | f    | weight() |
+------+------+----------+
|    1 | a    |      500 |
|    2 | a a  |      500 |
+------+------+----------+
2 rows in set (0.00 sec)
--- 2 out of 2 results in 0ms ---

Работает, спасибо!