| 1 |
.. -*- rst -*- |
| 2 |
|
| 3 |
.. groonga-command |
| 4 |
.. database: scorer_tf_at_most |
| 5 |
|
| 6 |
``scorer_tf_at_most`` |
| 7 |
===================== |
| 8 |
|
| 9 |
.. note:: |
| 10 |
|
| 11 |
This scorer is an experimental feature. |
| 12 |
|
| 13 |
.. versionadded:: 5.0.1 |
| 14 |
|
| 15 |
Summary |
| 16 |
------- |
| 17 |
|
| 18 |
``scorer_tf_at_most`` is a scorer based on TF (term frequency). |
| 19 |
|
| 20 |
TF based scorer includes TF-IDF based scorer has a problem for the |
| 21 |
following case: |
| 22 |
|
| 23 |
If document contains many same keywords such as "They are keyword, |
| 24 |
keyword, keyword ... and keyword", the document has high score. It's |
| 25 |
not expected. Search engine spammer may use the technique. |
| 26 |
|
| 27 |
``scorer_tf_at_most`` is a TF based scorer but it can solve the case. |
| 28 |
|
| 29 |
``scorer_tf_at_most`` limits the maximum score value. It means that |
| 30 |
``scorer_tf_at_most`` limits effect of a match. |
| 31 |
|
| 32 |
If document contains many same keywords such as "They are keyword, |
| 33 |
keyword, keyword ... and keyword", ``scorer_tf_at_most(column, 2.0)`` |
| 34 |
returns at most ``2`` as score. |
| 35 |
|
| 36 |
.. include:: ../scoring_note.rst |
| 37 |
|
| 38 |
Syntax |
| 39 |
------ |
| 40 |
|
| 41 |
This scorer has two parameters:: |
| 42 |
|
| 43 |
scorer_tf_at_most(column, max) |
| 44 |
scorer_tf_at_most(index, max) |
| 45 |
|
| 46 |
Usage |
| 47 |
----- |
| 48 |
|
| 49 |
This section describes how to use this scorer. |
| 50 |
|
| 51 |
Here are a schema definition and sample data to show usage. |
| 52 |
|
| 53 |
Sample schema: |
| 54 |
|
| 55 |
.. groonga-command |
| 56 |
.. include:: ../../example/reference/scorers/scorer_tf_at_most/usage_setup_schema.log |
| 57 |
.. table_create Logs TABLE_NO_KEY |
| 58 |
.. column_create Logs message COLUMN_SCALAR Text |
| 59 |
.. |
| 60 |
.. table_create Terms TABLE_PAT_KEY ShortText \ |
| 61 |
.. --default_tokenizer TokenBigram \ |
| 62 |
.. --normalizer NormalizerAuto |
| 63 |
.. column_create Terms message_index COLUMN_INDEX|WITH_POSITION Logs message |
| 64 |
|
| 65 |
Sample data: |
| 66 |
|
| 67 |
.. groonga-command |
| 68 |
.. include:: ../../example/reference/scorers/scorer_tf_at_most/usage_setup_data.log |
| 69 |
.. load --table Logs |
| 70 |
.. [ |
| 71 |
.. {"message": "Notice"}, |
| 72 |
.. {"message": "Notice Notice"}, |
| 73 |
.. {"message": "Notice Notice Notice"}, |
| 74 |
.. {"message": "Notice Notice Notice Notice"}, |
| 75 |
.. {"message": "Notice Notice Notice Notice Notice"} |
| 76 |
.. ] |
| 77 |
|
| 78 |
You specify ``scorer_tf_at_most`` in :ref:`select-match-columns` like |
| 79 |
the following: |
| 80 |
|
| 81 |
.. groonga-command |
| 82 |
.. include:: ../../example/reference/scorers/scorer_tf_at_most/usage_no_weight.log |
| 83 |
.. select Logs \ |
| 84 |
.. --match_columns "scorer_tf_at_most(message, 3.0)" \ |
| 85 |
.. --query "Notice" \ |
| 86 |
.. --output_columns "message, _score" \ |
| 87 |
.. --sort_keys "-_score" |
| 88 |
|
| 89 |
If a document has three or more ``Notice`` terms, its score is ``3``. |
| 90 |
Because the ``select`` specify ``3.0`` as the max score. |
| 91 |
|
| 92 |
If a document has one or two ``Notice`` terms, its score is ``1`` or |
| 93 |
``2``. Because the score is less than ``3.0`` specified as the max score. |
| 94 |
|
| 95 |
Parameters |
| 96 |
---------- |
| 97 |
|
| 98 |
This section describes all parameters. |
| 99 |
|
| 100 |
Required parameters |
| 101 |
^^^^^^^^^^^^^^^^^^^ |
| 102 |
|
| 103 |
There is only one required parameter. |
| 104 |
|
| 105 |
``column`` |
| 106 |
"""""""""" |
| 107 |
|
| 108 |
The data column that is match target. The data column must be indexed. |
| 109 |
|
| 110 |
``index`` |
| 111 |
""""""""" |
| 112 |
|
| 113 |
The index column to be used for search. |
| 114 |
|
| 115 |
Optional parameters |
| 116 |
^^^^^^^^^^^^^^^^^^^ |
| 117 |
|
| 118 |
There is no optional parameter. |
| 119 |
|
| 120 |
Return value |
| 121 |
------------ |
| 122 |
|
| 123 |
This scorer returns score as :ref:`builtin-type-float`. |
| 124 |
|
| 125 |
:doc:`/reference/commands/select` returns ``_score`` as ``Int32`` not |
| 126 |
``Float``. Because it casts to ``Int32`` from ``Float`` for keeping |
| 127 |
backward compatibility. |
| 128 |
|
| 129 |
Score is computed as TF with limitation. |
| 130 |
|
| 131 |
See also |
| 132 |
-------- |
| 133 |
|
| 134 |
* :doc:`../scorer` |