Skip to content

Commit

Permalink
feat: add customize flexsearch tokenize feature instruction to docs (#…
Browse files Browse the repository at this point in the history
…322)

* feat: add customize flexsearch tokenize feature instruction to docs

* Update configuration.md

* Update configuration.md

* Update configuration.zh-cn.md

---------

Co-authored-by: loenvom <loenvom@qq.com>
Co-authored-by: Xin <xin@imfing.com>
  • Loading branch information
3 people committed Jun 2, 2024
1 parent 3cba6b9 commit 1313415
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
17 changes: 17 additions & 0 deletions exampleSite/content/docs/guide/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,23 @@ Options for `flexsearch.index`:
- `heading` - level 1 and level 2 headings
- `title` - only include the page title

To customize the search tokenize, set the `params.search.flexsearch.tokenize` parameter in the config file:

```yaml {filename="hugo.yaml"}
params:
# ...
flexsearch:
# full | forward | reverse | strict
tokenize: forward
```

Options for [`flexsearch.tokenize`](https://github.com/nextapps-de/flexsearch/#tokenizer-prefix-search):

- `strict` - index whole words
- `forward` - incrementally index words in forward direction
- `reverse` - incrementally index words in both directions
- `full` - index every possible combination

To exclude a page from the search index, set the `excludeSearch: true` in the front matter of the page:

```yaml {filename="content/docs/guide/configuration.md"}
Expand Down
19 changes: 19 additions & 0 deletions exampleSite/content/docs/guide/configuration.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,25 @@ params:
- `heading` - 一级和二级标题
- `title` - 仅搜索标题

要自定义检索分词,请在配置文件中设置`params.search.flexsearch.tokenize`:

```hugo.yaml
params:
# ...
flexsearch:
# full | forward | reverse | strict
tokenize: forward
```

[`flexsearch.tokenize`](https://github.com/nextapps-de/flexsearch/#tokenizer-prefix-search)的可选项:

- `strict` - 严格单词匹配
- `forward` - 单词前缀匹配
- `reverse` - 单词前后缀匹配
- `full` - 单词子串匹配。

> 在默认的分词逻辑下,中文一句话就是一个“单词”

要从搜索索引中排除页面,更改 front matter 中的 `excludeSearch: true`:

```yaml {filename="content/docs/guide/configuration.md"}
Expand Down

0 comments on commit 1313415

Please sign in to comment.