回到首页Meilisearch 的标志
返回文章
2022年5月9日

v0.27 版本有什么新功能

本月发布的版本带来了对嵌套字段、拼写容错自定义以及新搜索参数的支持。

Shivay Lamba
Shivay LambaMeilisearch 团队
What's new in v0.27

本文介绍了部分主要和重大变更,您可以在此处查看完整的变更日志

新功能:支持嵌套字段

Meilisearch 现在完全支持嵌套文档字段,允许您使用点表示法来访问这些字段。
让我们举个例子。如果您有一个图书商店索引,您可能希望搜索结果可以通过作者的姓氏进行筛选,但不能通过名字进行筛选。

curl 
  -X POST 'http://localhost:7700/indexes/books/settings/filterable-attributes' 
  -H 'Content-Type: application/json' 
  --data-binary '[
  	"author.surname"
  ]'

在 Meilisearch 中,您可以在任何使用属性的地方使用点表示法来访问对象属性。例如,您可以访问索引设置,如可排序属性 (sortable attributes) 和可搜索属性 (searchable attributes),或搜索参数,如 attributesToHighlight

新功能:自定义拼写容错

Meilisearch 具有拼写容错能力!这意味着即使您的搜索包含拼写错误或拼写不正确,我们的引擎也能解释您的搜索。在 v0.27 中,您可以使用新的更新拼写容错端点或现有的更新设置端点来自定义索引的拼写容错设置。

新的拼写容错 API 端点接受一个 typoTolerance 对象,该对象具有以下属性:

  • enabled:拼写容错功能是否启用。默认为 true。
  • disableOnAttributes:禁用特定文档属性的拼写容错。默认情况下,拼写容错在所有属性上都启用。
  • disableOnWords:禁用搜索时给定的一组查询词的拼写容错。默认情况下,拼写容错不会忽略任何单词。
  • minWordSizeForTypos:Meilisearch 只接受超过特定大小的单词中的拼写错误。
  • oneTypo:自定义接受一个拼写错误的最小单词大小。默认为 5 个字符。
  • twoTypos:自定义接受两个拼写错误的最小单词大小。默认为 9 个字符。

假设您有一个包含许多角色名称的 movie 索引。您可能希望 Meilisearch 永远不要在某些单词中查找拼写错误,但对其他所有内容都更宽松。

curl --location --request POST 'http://localhost:7700/indexes/children-movies/settings/typo-tolerance' 
--header 'Authorization: Bearer <API_KEY>' 
--header 'Content-Type: application/json' 
--data-raw '{
    "enabled": true,
    "minWordLengthForTypo": {
        "oneTypo": 3,
        "twoTypos": 7
    },
    "disableOnWords": ["Shrek"],
    "disableOnAttributes": []
}'

您可以在此处阅读更多关于拼写容错的信息。

新功能:改进的突出显示和裁剪搜索参数

本次发布带来了三个新的搜索参数:highlightPreTaghighlightPostTagcropMarker。前两个允许您进一步自定义突出显示搜索词的外观,而最后一个应与 attributesToCrop 结合使用。
当使用 attributesToHighlight 时,Meilisearch 默认会将匹配的词项用 <em> 标签和字符串括起来。您现在可以使用 highlightPreTaghighlightPostTag 将这些值配置为包含任何字符串。顾名思义,highlightPreTag 指定突出显示的查询词项之前的标签,而 highlightPostTag 指定突出显示的查询词项之后的标签。
同样,当使用 attributesToCrop 时,您现在可以将默认的 “…” cropMarker 更改为任何字符串,用于标记裁剪边界。
在设计一个允许用户搜索电影数据库的应用程序时,您可能希望更改 cropMarker 和突出显示标签以匹配您的设计。

curl --location --request POST '<http://localhost:7700/indexes/movies/search>' \
--header 'Authorization: Bearer <API_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "q":"shifu",
    "attributesToCrop":["overview"],
    "attributesToHighlight":["overview"],
    "cropLength":10,
    "highlightPreTag":"<span class=’highlight’>",
    "highlightPostTag":"</span>",
    "cropMarker":"[…]"
}'

使用上述查询,搜索词 shifu 将被标签括起来,并且裁剪的文本将由 […] 标记。

{
  "id": "50393",
  "title": "Kung Fu Panda Holiday",
  "overview": "The Winter Feast is Po's favorite holiday. Every year he and his father hang decorations, cook together, and serve noodle soup to the villagers. But this year Shifu informs Po that as Dragon Warrior, it is his duty to host the formal Winter Feast at the Jade Palace. Po is caught between his obligations as the Dragon Warrior and his family traditions: between Shifu and Mr. Ping.",
  "_formatted": {
    "id": "50393",
    "title": "Kung Fu Panda Holiday",
    **"overview": "[…]the villagers. But this year <span class=’highlight’>Shifu</span> informs Po that as[…]"**
  }
}

欲了解更多信息,请查看我们关于搜索参数的指南。

重大变更:`cropLength` 行为

cropLength 搜索参数现在以单词数而非字符数指定。
让我们看一个示例查询:

curl --location --request POST '<http://localhost:7700/indexes/movies/search>' \
	--header 'Authorization: Bearer <API_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "q":"shifu",
    "attributesToCrop":["overview"],
    "cropLength":10
}'

Meilisearch v0.27 返回:

{
  "id": "50393",
  "title": "Kung Fu Panda Holiday",
  "overview": "The Winter Feast is Po's favorite holiday. Every year he and his father hang decorations, cook together, and serve noodle soup to the villagers. But this year Shifu informs Po that as Dragon Warrior, it is his duty to host the formal Winter Feast at the Jade Palace. Po is caught between his obligations as the Dragon Warrior and his family traditions: between Shifu and Mr. Ping.",
  "_formatted": {
    "id": "50393",
    "title": "Kung Fu Panda Holiday",
    **"overview": "…the villagers. But this year Shifu informs Po that as…",**
  }
}

重大变更:改进的 Docker 工作流程

Docker 现在从不同的工作目录 /meili_data 启动。这简化了您可能希望与 Docker 一起使用快照和数据转储的情况。
用法基本保持不变,但别忘了更新数据路径。

docker run -it --rm \
-p 7700:7700 \
-v $(pwd)/meili_data:/meili_data \
getmeili/meilisearch:latest

通过此更改,数据转储和快照功能应能与 Docker 开箱即用。它将所有 Meilisearch 数据挂载到 meili_data 目录中,而不是挂载单独的卷。
此更改的另一个结果是 meilisearch 二进制文件已移动到新位置。现在,当使用实例选项配置 Meilisearch 时,您必须使用 meilisearch/meilisearch/bin/meilisearch,而不是 `./meilisearch`。不过,我们建议使用 meilisearch
更新后的命令是:

docker run -it --rm -p 7700:7700 getmeili/meilisearch:latest **meilisearch** --master-key="foobar"

其他变更

  1. 单词首字母的拼写错误将计为两个拼写错误。这缩小了拼写容错的搜索范围,从而加快了搜索响应时间。
  2. Meilisearch 现在对每次搜索返回的文档数量有 1000 个的不可自定义限制,以保护数据库免受恶意抓取。
  3. 我们新增了两个实例选项,让您在索引期间对机器资源的使用有更多控制(`--max-indexing-memory` 和 `--max-indexing-threads`)。
  4. 我们现在支持日语。
  5. 向非空索引添加新文档的速度得到了提升。

贡献者

非常感谢我们所有的贡献者!没有你们的支持,我们不可能走到这里。本月,我们要特别感谢 @miiton@djKooks@mosuka 提供了日语支持,以及 @2shiori17 增加了对索引期间 RAM 和 CPU 使用率的新实例选项的支持。

好了,各位!请记住查看变更日志以获取完整的发布说明,下个月再见!

Meilisearch 1.14

Meilisearch 1.14

Meilisearch 1.14 引入了新的实验性功能,包括复合嵌入器和嵌入缓存以提升性能。它还增加了核心功能,如精细可筛选属性和按 ID 批量文档检索。

Carolina Ferreira
Carolina Ferreira2025年4月14日
Meilisearch AI launch week recap

Meilisearch AI 发布周回顾

Meilisearch AI 发布回顾:利用 AI 和个性化转变搜索

Maya Shin
Maya Shin2025年3月28日
Introducing Meilisearch's next-generation indexer: 4x faster updates, 30% less storage

Meilisearch 下一代索引器介绍:更新速度提升 4 倍,存储空间减少 30%

2024 年索引器版本通过并行处理、优化的 RAM 使用和增强的可观测性,彻底改变了搜索性能。查看我们最新版本中的新功能。

Louis Dureuil
Louis Dureuil2025年2月26日