v1.3 有哪些新功能?
v1.3 引入了许多激动人心的功能,包括向量搜索、排名分数详情、分面值搜索以及查询时可搜索字段。

让我们来看看 Meilisearch 最新更新中的一些最重要变化。我们将在本文中介绍主要变化,您也可以在 GitHub 上查看完整的更新日志。
v1.3 现已在 Meilisearch Cloud 上可用,包括所有实验性功能。一键升级您的 Meilisearch 实例,无需停机。
实验性功能:向量搜索
正在使用 LangChain?现在您可以使用 Meilisearch 向量存储来受益于强大的搜索功能!
我们很高兴推出向量存储!现在,您可以使用向量嵌入(数据的数值表示)来索引和搜索文档。此功能的首次迭代,您需要使用外部工具,例如 Hugging Face、Cohere 或 OpenAI,来创建此类嵌入。请查看[公告文章](/blog/vector-search-announcement/),以发现此功能的广泛可能性和潜在应用。
此功能是实验性的,您可以使用新的实验性功能端点启用它。
要根据向量近似度搜索文档,请确保它们包含一个 _vectors
字段
curl -X POST -H 'content-type: application/json' 'localhost:7700/indexes/songs/documents' --data-binary '[ { "id": 0, "_vectors": [0, 0.8, -0.2], "title": "Across The Universe" }, { "id": 1, "_vectors": [1, -0.2, 0], "title": "All Things Must Pass" }, { "id": 2, "_vectors": [[0.5, 3, 1], [-0.2, 4, 6]], "title": "And Your Bird Can Sing" } ]'
存储后,您可以使用新的 vector
搜索参数结合搜索和多重搜索路由来搜索您的向量化文档。
curl -X POST -H 'content-type: application/json' 'localhost:7700/indexes/songs/search' --data-binary '{ "vector": [0, 1, 2] }'
👉 请注意,您需要使用第三方工具在查询中生成向量。
返回的文档包含一个 _semanticScore
字段,表示每个文档与查询的语义相似度(或相关性)。
{ "hits": [ { "id": 0, "_vectors": [0, 0.8, -0.2], "title": "Across The Universe", "_semanticScore": 0.6754 }, { "id": 1, "_vectors": [1, -0.2, 0], "title": "All Things Must Pass", "_semanticScore": 0.7546 }, { "id": 2, "_vectors": [[0.5, 3, 1], [-0.2, 4, 6]], "title": "And Your Bird Can Sing", "_semanticScore": 0.78 } ], "query": "", "vector": [0, 1, 2], "processingTimeMs": 0, "limit": 20, "offset": 0, "estimatedTotalHits": 2 }
此功能是实验性的,我们需要您的帮助来改进它!请在此 GitHub 讨论中分享反馈。
新功能:在搜索时显示排名分数
使用新的 showRankingScore
搜索参数来查看每个文档的相关性排名分数
curl -X POST 'http://localhost:7700/indexes/movies/search' -H 'Content-Type: application/json' --data-binary '{ "q": "Batman Returns", "showRankingScore": true }'
响应中的每个文档都将包含一个 _rankingScore
属性,该属性表示 0 到 1 之间的分数。
"_rankingScore": 0.8575757575757575,
_rankingScore
越高,文档的相关性越高。
实验性功能:排名分数详情
对于返回的每个文档,Meilisearch 提供了每条排名规则的排名分数详情。此功能完美诠释了社区参与如何丰富 Meilisearch 的[设计过程](/blog/from-ranking-to-scoring/)。
此功能是实验性的,您可以使用新的实验性功能端点启用它。
将 showRankingScoreDetails
搜索参数设置为 true
以查看排名分数详情
curl -X POST 'http://localhost:7700/indexes/movies/search' -H 'Content-Type: application/json' --data-binary '{ "q": "Batman Returns", "showRankingScoreDetails": true }'
响应应包含每条规则的相关性分数。
"_rankingScoreDetails": { "words": { "order": 0, "matchingWords": 1, "maxMatchingWords": 1, "score": 1.0 }, "typo": { "order": 1, "typoCount": 0, "maxTypoCount": 1, "score": 1.0 }, "proximity": { "order": 2, "score": 1.0 }, "attribute": { "order": 3, "attributesRankingOrder": 0.8, "attributesQueryWordOrder": 0.6363636363636364, "score": 0.7272727272727273 }, "exactness": { "order": 4, "matchType": "noExactMatch", "score": 0.3333333333333333 } }
此功能是实验性的。您可以通过在此 GitHub 讨论中分享反馈来帮助我们改进它。
新功能:搜索分面值
定义可筛选属性后,您可以使用新的端点 POST /indexes/{index}/facet-search
来搜索分面值。
curl -X POST 'http://localhost:7700/indexes/movies/facet-search' -H 'Content-Type: application/json' --data-binary '{ "facetName": "genres", "facetQuery": "a" }'
由于分面搜索支持错别字容忍和前缀搜索,上述查询将返回以下结果:
{ "facetHits": [ { "value": "Action", "count": 5403 }, { "value": "Adventure", "count": 3020 }, { "value": "Animation", "count": 1969 } ], "facetQuery": "a", "processingTimeMs": 0 }
要测试此功能,请查看我们更新的电子商务演示。
新功能:按计数排序分面值
默认情况下,分面按字母数字升序排序。现在,您可以根据包含每个分面值的匹配文档数量,按降序排序分面值。
要按计数排序分面,您可以使用分面索引设置中的新属性 sortFacetValuesBy
。
要修改所有分面的排序顺序,您可以使用星号(*)通配符。
curl -X PATCH 'http://localhost:7700/indexes/movies/settings/faceting -H 'Content-Type: application/json' --data-binary '{ "sortFacetValuesBy": {"*": "count"} }'
另外,您还可以灵活地按计数对单个分面进行排序,同时保持其他属性的字母数字排序。
curl -X PATCH 'http://localhost:7700/indexes/movies/settings/faceting -H 'Content-Type: application/json' --data-binary '{ "sortFacetValuesBy": {"*": "alpha", "genre": "count"} }'
您也可以在电子商务演示中尝试。
新功能:查询时可搜索属性
通过新的 attributesToSearchOn
搜索参数,您现在可以在查询时将搜索限制到可搜索属性的子集。它接受一个字符串数组,指示一个或多个文档属性。
{ "q": "adventure", "attributesToSearchOn": ["genre"] }
给定以下文档,上述查询将仅返回 ID 为 1 的文档。
{ "id": 0, "name": "An Adventure in Space and Time", "genre": ["drama"] }, { "id": 1, "name": "A Strange and Stubborn Endurance", "genre": ["adventure"] }
相关性变更:属性排名规则
在 v1.3 中,属性排名规则会为查询词在查询中位置更接近的文档分配更高的相关性,而非查询词在查询中位置较远的文档。
在此之前,此规则根据词语在属性中的位置而不是其在搜索查询中的位置来衡量相关性。属性中包含查询词在属性开头部分的文档被认为更相关。
考虑以下查询:“蝙蝠侠:黑暗骑士归来”以及相应的文档:
{ "id": 0, "title": "Batman the dark knight returns" }, { "id": 1, "title": "Dark the Batman knight returns" }, { "id": 2, "title": "Batman returns: a retrospective", "description": "The Dark knight is analyzed in this new Batman documentary" }
在 v1.3 之前,属性排名规则将文档 2 置于列表顶部,其次是文档 0 和文档 1(并列排名)。
自 v1.3 以来,顺序严格为:文档 0、文档 1、文档 2,这提供了更自然的排名。
其他改进
/tasks
路由现在使用total
属性显示队列中的任务总数。它还根据特定过滤器显示任务总数。- 增强的日语支持和分词功能
- Prometheus
/metrics
实验性功能改进
贡献者
我们非常感谢所有参与本次发布的社区成员。我们要感谢:@vvv、@jirutka、@gentcys、@cuishuang、@0xflotus 和 @roy9495 对 Meilisearch 的帮助。
我们还要特别感谢我们的 Meilistar @mosuka,感谢他持续对 Charabia 进行的日语改进。
总结
v1.3 的内容就是这些了!请记住查看更新日志以获取完整的发布说明,下次再见!
您可以订阅我们的新闻通讯,以便随时了解最新动态。要了解更多关于 Meilisearch 的未来并帮助塑造它,请查看我们的路线图,并参与我们的产品讨论。
如需其他帮助,请加入我们的 Discord 开发者社区。