想要更好地控制您的搜索设置?了解我们的灵活的基础设施定价

回到主页Meilisearch 的标志
返回文章

v0.27 版本新特性

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

2022年5月9日阅读4分钟
Shivay Lamba
Shivay LambaMeilisearch团队null
What's new in v0.27
分享文章

本文介绍了一些主要和突破性的更改,您可以在此处查看完整的更新日志

新功能:支持嵌套字段

Meilisearch 现在完全支持嵌套文档字段,允许您使用点表示法访问这些字段。
举个例子。如果您有一个书店索引,您可能希望搜索结果可以按作者姓氏过滤,但不能按名字过滤。

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

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

新功能:自定义拼写容错

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

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

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

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

curl --location --request POST 'http://: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://: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://: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.16

Meilisearch 1.16

Meilisearch 1.16 引入了多模态嵌入和新的 API,用于在实例之间传输数据。

Laurent Cazanove
Laurent Cazanove2025年8月5日
Meilisearch 1.15

Meilisearch 1.15

Meilisearch 1.15 引入了新的拼写容错设置、字符串过滤器比较运算符,并改进了对中文的支持。

Carolina Ferreira
Carolina Ferreira2025年6月10日
Meilisearch 1.14

Meilisearch 1.14

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

Carolina Ferreira
Carolina Ferreira2025年4月14日
© . This site is unofficial and not affiliated with Meilisearch.