Skip to content

Commit c17bee0

Browse files
committed
feat: add CREATE TABLE profile defaults for relevance
1 parent 365a297 commit c17bee0

37 files changed

Lines changed: 1005 additions & 53 deletions

File tree

manual/chinese/Creating_a_table/Local_tables/Plain_and_real-time_table_settings.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,29 @@ table <table name> {
6565

6666
### 普通表和实时表的通用设置
6767

68+
#### 配置方案
69+
70+
`profile` 只在 `CREATE TABLE` 中可用,是一个仅限 SQL 的快捷方式,用来应用一组预定义的表设置。`ALTER TABLE` 不支持它。配置方案名称本身**不会**存储在表元数据中;Manticore 只会保存展开后的设置,因此 `SHOW CREATE TABLE` 打印的是最终选项,而不是 `profile=...`
71+
72+
当前支持的值:
73+
74+
* `relevance` - 展开为:
75+
* [`min_infix_len='2'`](../../Creating_a_table/NLP_and_tokenization/Wildcard_searching_settings.md#min_infix_len)
76+
* [`index_field_lengths='1'`](../../Creating_a_table/NLP_and_tokenization/Low-level_tokenization.md#index_field_lengths)
77+
* [`ranker=expr('1000*bm25a(1.2,0.75,256)')`](../../Searching/Options.md#ranker)
78+
* [`morphology='stem_en'`](../../Creating_a_table/NLP_and_tokenization/Morphology.md#morphology)
79+
* [`boolean_mode='or'`](../../Searching/Options.md#boolean_mode)
80+
81+
`relevance` 配置文件可以提升许多英文全文检索工作负载的排序质量和召回率,但它也会增加索引和查询时的计算量,因此相比默认值可能会额外消耗 CPU、存储和内存。
82+
83+
如果你也显式指定了这些选项中的某一个,`profile` 会遵循与普通 `CREATE TABLE` 设置相同的重复选项语义:第一个出现的值生效。由于配置方案在创建时会展开为普通设置,`profile='relevance' ranker='bm25'` 会保留配置方案里的 ranker,而完全展开后的显式写法也一样。同样,`ranker='bm25' profile='relevance'` 会保留 `ranker='bm25'`
84+
85+
扩展后的设置会存储在表元数据中。查询级别的 `OPTION ranker=...` 仍然会覆盖任何已存储的表排序器。如果一个查询搜索多个表且没有指定排序器,每个表都会继续使用各自存储的默认排序器,包括本地和远程分布式表。在这种情况下,Manticore 会使用原始返回权重合并结果;它**不会**在不同排序器或表达式之间归一化权重,因此混用不同的按表排序器可能会产生不可比较的全局顺序。
86+
87+
```sql
88+
CREATE TABLE products(title text) profile='relevance';
89+
```
90+
6891
#### type
6992

7093
```ini
@@ -83,7 +106,7 @@ type = rt
83106
path = path/to/table
84107
```
85108

86-
表将被存储或定位的路径,可以是绝对路径或相对路径,不带扩展名
109+
表将被存储或定位的路径,可以是绝对路径或相对路径,不包含扩展名
87110

88111
值:表的路径,**必填**
89112

@@ -994,6 +1017,7 @@ table products {
9941017
* [bigram_index](../../Creating_a_table/NLP_and_tokenization/Low-level_tokenization.md#bigram_index)
9951018
* [blend_chars](../../Creating_a_table/NLP_and_tokenization/Low-level_tokenization.md#blend_chars)
9961019
* [blend_mode](../../Creating_a_table/NLP_and_tokenization/Low-level_tokenization.md#blend_mode)
1020+
* [boolean_mode](../../Searching/Options.md#boolean_mode)
9971021
* [charset_table](../../Creating_a_table/NLP_and_tokenization/Low-level_tokenization.md#charset_table)
9981022
* [dict](../../Creating_a_table/NLP_and_tokenization/Low-level_tokenization.md#dict)
9991023
* [embedded_limit](../../Creating_a_table/NLP_and_tokenization/Low-level_tokenization.md#embedded_limit)

manual/chinese/Listing_tables.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ data for the following examples:
418418
419419
DROP TABLE IF EXISTS tbl;
420420
CREATE TABLE tbl(title text indexed stored) charset_table='non_cont,cont' morphology='icu_chinese';
421-
-->
421+
-->
422422

423423
<!-- example name_table -->
424424
您还可以通过执行查询 `select * from <table_name>.@table` 查看表模式。此方法的优点是您可以使用 `WHERE` 子句进行过滤:
@@ -481,6 +481,8 @@ SHOW CREATE TABLE table_name [ OPTION output_words = 'list' | 'file' ]
481481

482482
打印用于创建指定表的 `CREATE TABLE` 语句。
483483

484+
如果该表是使用 SQL `profile=...` 快捷方式创建的,`SHOW CREATE TABLE` 打印的是展开后的设置,而不是 profile 名称本身。
485+
484486
`output_words` 选项允许您控制外部文件设置(如 `stopwords``exceptions``wordforms``hitless_words`)的显示方式:
485487

486488
* `'list'`(默认):使用 `*_list` 选项(例如 `stopwords_list='word1; word2'`)以内联列表形式显示文件内容。

manual/chinese/Node_info_and_management/Table_settings_and_status/SHOW_TABLE_SETTINGS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ SHOW TABLE table_name[.N | CHUNK N] SETTINGS
2020

2121
输出类似于 [indextool](../../Miscellaneous_tools.md#indextool) 工具的 [--dumpconfig](../../Miscellaneous_tools.md#indextool) 选项。该报告详细列出了所有表设置,包括分词器和词典选项。
2222

23+
如果表是通过 SQL `profile=...` 快捷方式创建或修改的,`SHOW TABLE SETTINGS` 显示的是展开后的已存储设置(例如 `ranker``boolean_mode`),而不是配置文件名称本身。
24+
2325
<!-- intro -->
2426
##### SQL:
2527
<!-- request SQL -->

manual/chinese/Searching/Full_text_matching/Basic_usage.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 匹配
22

3-
`MATCH` 子句允许对文本字段进行全文检索。输入的查询字符串会使用与索引时应用于文本相同的设置进行 [分词](../../Creating_a_table/NLP_and_tokenization/Data_tokenization.md)除了对输入文本进行分词之外,查询字符串还支持多种 [全文运算符](../../Searching/Full_text_matching/Operators.md)用于强制规定关键字应如何形成有效匹配
3+
`MATCH` 子句允许对文本字段进行全文搜索。输入的查询字符串会使用与索引时应用于文本的相同设置进行 [分词](../../Creating_a_table/NLP_and_tokenization/Data_tokenization.md)除了对输入文本进行分词外,查询字符串还支持多种 [全文运算符](../../Searching/Full_text_matching/Operators.md)用于约束关键词应如何构成有效匹配。对于没有显式布尔运算符的多关键词查询,SQL 和 HTTP JSON 的默认行为不同:SQL 遵循 [`boolean_mode`](../../Searching/Options.md#boolean_mode),其默认值为 `and`,除非按表或按查询覆盖;而 JSON `match` 查询的默认值为 `or`,除非你显式设置 `"operator"`
44

55
全文匹配子句可以与属性 [过滤器](../../Searching/Filters.md) 结合使用,作为 AND 布尔运算。**全文匹配和属性过滤器之间的 OR 关系不被支持**
66

@@ -31,6 +31,7 @@ MATCH('search query' [, table_name])
3131

3232
[SELECT](../../Searching/Full_text_matching/Basic_usage.md#SQL) 语句使用 [MATCH](../../Searching/Full_text_matching/Basic_usage.md) 子句进行全文搜索,该子句必须位于 WHERE 之后。`MATCH()` 接受一个输入字符串,在该字符串中可用所有 [全文操作符](../../Searching/Full_text_matching/Operators.md)
3333

34+
关于 SQL 特定的默认关键词组合行为,请参见 [`boolean_mode`](../../Searching/Options.md#boolean_mode)
3435

3536
<!-- intro -->
3637
##### SQL:

manual/chinese/Searching/Full_text_matching/Operators.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
查询字符串可以包含特定的操作符,用于定义查询字符串中的单词应该如何匹配的条件。
44

5+
关于**不使用**显式运算符的多关键字查询默认行为,请参见 [`boolean_mode`](../../Searching/Options.md#boolean_mode)
6+
57
### 布尔操作符
68

79
#### AND 操作符
@@ -215,7 +217,7 @@ REGEX(/t.?e/)
215217

216218
[通配符操作符](../../Searching/Full_text_matching/Operators.md#Wildcard-operators)类似,REGEX操作符尝试找到所有匹配所提供模式的词项,每个扩展都作为匹配命中记录。注意,这可能对查询搜索时间产生显著影响,因为会扫描整个字典,字典中每个词项都要与REGEX模式进行匹配。
217219

218-
模式应遵循[RE2 语法](https://github.com/google/re2/wiki/Syntax)。REGEX表达式的定界符是开括号后的第一个符号。换句话说,开括号后跟定界符与定界符和闭括号之间的所有文本都被视为RE2表达式。
220+
模式应遵循[RE2 语法](https://github.com/google/re2/wiki/Syntax)。REGEX表达式的定界符是开括号后的第一个符号。换句话说,开括号后跟定界符与定界符和闭括号之间的所有文本都被视为RE2表达式。
219221
请注意,存储在字典中的词项会经过 `charset_table` 转换,这意味着例如如果所有字符根据 `charset_table`(默认)被转为小写,REGEX 可能无法匹配大写字符。要成功用 REGEX 表达式匹配词项,模式必须对应整个词项。若要实现部分匹配,请在模式开头和/或结尾添加 `.*`
220222

221223
```sql

manual/chinese/Searching/Options.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,24 @@ WHERE match('machine learning') AND knn(vec, 5, (0.1, 0.1, 0.1, 0.1))
420420
OPTION fusion_method='rrf', rank_constant=10;
421421
```
422422
423+
### boolean_mode
424+
425+
```sql
426+
OPTION boolean_mode='or';
427+
```
428+
429+
控制 SphinxQL 全文查询中**没有显式布尔运算符**的多关键词 `MATCH()` 表达式如何被解释。
430+
431+
可从以下值中选择:
432+
* `and` - 所有关键词都必须匹配
433+
* `or` - 任意关键词都可以匹配
434+
435+
`OPTION boolean_mode=...` 只对当前查询生效。你也可以通过 `CREATE TABLE ... boolean_mode='...'`,或者使用表 [profile](../Creating_a_table/Local_tables/Plain_and_real-time_table_settings.md#profile),把默认布尔模式存储在表元数据中。如果两者都存在,以查询选项为准。如果都未指定,SQL 默认使用 `and`。
436+
437+
它只影响相邻关键词或子表达式之间**隐式**的组合方式,前提是这些表达式本身没有显式的全文运算符。像 `|`、`!`/`-`、短语、quorum、`NEAR` 和 `<<` 这类显式运算符会保持各自的语义。
438+
439+
HTTP JSON 在 `match` 查询上有自己对应的设置,通过 `"operator"` 属性实现,默认是 `or`,除非显式设置。
440+
423441
### ranker
424442
从以下选项中选择:
425443
* `proximity_bm25`
@@ -435,6 +453,8 @@ OPTION fusion_method='rrf', rank_constant=10;
435453
436454
有关每个排序器的更多详细信息,请参阅[搜索结果排序](../Searching/Sorting_and_ranking.md#Available-built-in-rankers)。
437455
456+
`OPTION ranker=...` 只为当前查询设置 ranker。你也可以通过 `CREATE TABLE ... ranker='...'`,或者使用表 [profile](../Creating_a_table/Local_tables/Plain_and_real-time_table_settings.md#profile),把默认 ranker 存储在表元数据中。如果两者都存在,以查询选项为准。如果一个查询目标是多个表且未指定 `OPTION ranker=...`,则每个表都会使用自己保存的默认 ranker,包括本地和远程分布式表。最终合并会直接使用返回的原始权重,不做跨 ranker 归一化,因此只有当参与的表使用相同的 ranker 语义时,全局排序才可以可靠比较。
457+
438458
### rand_seed
439459
允许您为`ORDER BY RAND()`查询指定特定的整数种子值,例如:`... OPTION rand_seed=1234`。默认情况下,每个查询都会自动生成一个新的且不同的种子值。
440460

manual/chinese/Searching/Sorting_and_ranking.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,8 @@ searchRequest.SetSort(sort)
10431043
10441044
所以,Manticore 中的排名是可配置的。它有一个所谓的**ranker**(排名器)的概念。排名器可以形式化定义为一个接受文档和查询作为输入,并输出相关性值的函数。通俗来说,排名器控制着 Manticore 将如何(使用哪种具体算法)给文档分配权重。
10451045
1046+
可以通过 [`OPTION ranker=...`](../Searching/Options.md#ranker) 为每个查询选择一个 ranker,也可以在 `CREATE TABLE ... ranker='...'` 中将其存为表级默认值(也可通过表 [profile](../Creating_a_table/Local_tables/Plain_and_real-time_table_settings.md#profile) 设置)。两者同时存在时,以查询选项为准。当一个查询同时搜索多张表且没有显式指定查询级 ranker 时,每张表会继续使用自己保存的默认 ranker,包括本地和远程分布式表。最终合并时比较的是原始返回权重;系统不会提供自动归一化层来让不同的 ranker 或自定义表达式在数值上可直接比较。
1047+
10461048
## 内置排名器
10471049
10481050
Manticore 提供了几种适用于不同用途的内置排名器。它们中的许多使用两个因素:短语接近度(也称为LCS)和BM25。短语接近度根据关键词位置工作,而BM25根据关键词频率工作。基本上,文档和查询之间的短语匹配程度越高,短语接近度越高(当文档包含查询的完整逐字引用时达到最大值)。而当文档包含更多罕见词时,BM25分值越高。详细讨论稍后进行。

manual/english/Creating_a_table/Local_tables/Plain_and_real-time_table_settings.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,29 @@ table <table name> {
6565

6666
### Common plain and real-time tables settings
6767

68+
#### profile
69+
70+
`profile` is a SQL-only shortcut for applying a predefined bundle of table settings in `CREATE TABLE` only. It is not supported in `ALTER TABLE`. The profile name itself is **not** stored in table metadata; Manticore stores only the expanded settings, so `SHOW CREATE TABLE` prints the resulting options rather than `profile=...`.
71+
72+
Currently supported values:
73+
74+
* `relevance` - expands to:
75+
* [`min_infix_len='2'`](../../Creating_a_table/NLP_and_tokenization/Wildcard_searching_settings.md#min_infix_len)
76+
* [`index_field_lengths='1'`](../../Creating_a_table/NLP_and_tokenization/Low-level_tokenization.md#index_field_lengths)
77+
* [`ranker=expr('1000*bm25a(1.2,0.75,256)')`](../../Searching/Options.md#ranker)
78+
* [`morphology='stem_en'`](../../Creating_a_table/NLP_and_tokenization/Morphology.md#morphology)
79+
* [`boolean_mode='or'`](../../Searching/Options.md#boolean_mode)
80+
81+
The `relevance` profile can improve ranking and recall for many English full-text workloads, but it also increases work done at indexing and query time, so it may cost extra CPU, storage, and memory compared to the defaults.
82+
83+
If you also specify one of these options explicitly, `profile` follows the same duplicate-option semantics as ordinary `CREATE TABLE` settings: the first occurrence wins. Because the profile expands into ordinary settings at create time, `profile='relevance' ranker='bm25'` keeps the profile ranker, and the fully expanded explicit form does the same. Likewise, `ranker='bm25' profile='relevance'` keeps `ranker='bm25'`.
84+
85+
The expanded settings are stored in table metadata. Query-level `OPTION ranker=...` still overrides any stored table ranker. If a query searches multiple tables and does not specify a ranker, each table keeps using its own stored default ranker, including local and remote distributed tables. In that case, Manticore merges results using the raw returned weights; it does **not** normalize weights across different rankers or expressions, so mixing different per-table rankers can produce non-comparable global ordering.
86+
87+
```sql
88+
CREATE TABLE products(title text) profile='relevance';
89+
```
90+
6891
#### type
6992

7093
```ini
@@ -994,6 +1017,7 @@ The following settings are supported. They are all described in section [NLP and
9941017
* [bigram_index](../../Creating_a_table/NLP_and_tokenization/Low-level_tokenization.md#bigram_index)
9951018
* [blend_chars](../../Creating_a_table/NLP_and_tokenization/Low-level_tokenization.md#blend_chars)
9961019
* [blend_mode](../../Creating_a_table/NLP_and_tokenization/Low-level_tokenization.md#blend_mode)
1020+
* [boolean_mode](../../Searching/Options.md#boolean_mode)
9971021
* [charset_table](../../Creating_a_table/NLP_and_tokenization/Low-level_tokenization.md#charset_table)
9981022
* [dict](../../Creating_a_table/NLP_and_tokenization/Low-level_tokenization.md#dict)
9991023
* [embedded_limit](../../Creating_a_table/NLP_and_tokenization/Low-level_tokenization.md#embedded_limit)

manual/english/Listing_tables.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,8 @@ SHOW CREATE TABLE table_name [ OPTION output_words = 'list' | 'file' ]
481481

482482
Prints the `CREATE TABLE` statement used to create the specified table.
483483

484+
If the table was created using a SQL `profile=...` shortcut, `SHOW CREATE TABLE` prints the expanded settings instead of the profile name itself.
485+
484486
The `output_words` option allows you to control how external file settings (such as `stopwords`, `exceptions`, `wordforms`, `hitless_words`) are displayed:
485487

486488
* `'list'` (default): Displays the content of the files as inline lists using the `*_list` options (e.g. `stopwords_list='word1; word2'`).

manual/english/Node_info_and_management/Table_settings_and_status/SHOW_TABLE_SETTINGS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ SHOW TABLE table_name[.N | CHUNK N] SETTINGS
2020

2121
The output resembles the [--dumpconfig](../../Miscellaneous_tools.md#indextool) option of the [indextool](../../Miscellaneous_tools.md#indextool) utility. The report provides a breakdown of all table settings, including tokenizer and dictionary options.
2222

23+
If a table was created or altered with a SQL `profile=...` shortcut, `SHOW TABLE SETTINGS` displays the expanded stored settings (for example `ranker` and `boolean_mode`), not the profile name itself.
24+
2325
<!-- intro -->
2426
##### SQL:
2527
<!-- request SQL -->

0 commit comments

Comments
 (0)