Meilisearch v1.14 发布啦 ✨ 在我们的博客上阅读更多内容

转到主页Meilisearch 的标志
返回文章
2023 年 4 月 12 日

介绍多索引搜索

联邦搜索通过跨多个索引进行搜索,从而提升用户体验和结果相关性。

Carolina Ferreira
Carolina Ferreira开发者布道师 @ Meilisearch@CarolainFG
Introducing multi-index search

Meilisearch v1.1 引入了 /multi-search 端点。借助此端点,用户现在可以通过将多个搜索查询捆绑到单个 HTTP 请求中,从而在一个或多个索引上发送多个搜索查询。本质上,/multi-search 端点为 联邦搜索 铺平了道路

联邦搜索Meilisearch 1.10 及更高版本中可用。

使用 Meilisearch 进行多索引搜索

联邦搜索获得了 277 票,是 最受请求的功能 之一。我们很高兴最终宣布该功能的第一个阶段。

我们引入了一个 /multi-search 路由,允许通过单个 HTTP 请求在多个索引中进行搜索。假设我们有两个索引:moviesactors。使用 /multi-search 端点,我们可以搜索女演员的名字,并在搜索结果中检索到她的传记和电影。

以以下多索引搜索请求为例

curl 
-X POST 'http://localhost:7700/multi-search' 
-H 'Content-Type: application/json' 
--data-binary '{
  "queries": [
     {
       "indexUid": "movies",
       "q": "Kate Winslet",
       "limit": 1
     },
    {
       "indexUid": "actors",
       "q": "Kate Winslet",
       "limit": 1
    }
  ]
}'

响应将包含每个搜索索引的一组搜索结果

{
   "results": [
     {
       "indexUid": "movies",
       "hits": [
         {
           "title": "The Reader",
           "overview": "The story of Michael Berg, a German lawyer who, as a teenager in the late 1950s, had an affair with an older woman, Hanna, who then disappeared only to resurface years later as one of the defendants in a war crimes trial stemming from her actions as a concentration camp guard late in the war. He alone realizes that Hanna is illiterate and may be concealing that fact at the expense of her freedom.",
           "crew": [...],
           "cast": [
		...
             {
               "character": "Hanna Schmitz",
               "name": "Kate Winslet",
               "profile_path": "/e3tdop3WhseRnn8KwMVLAV25Ybv.jpg"
             },
		...
           ]
         }
       ],
// other search results fields: processingTimeMs, limit, ...
     },
     {
       "indexUid": "actors",
       "hits": [
     {
       "name": "Kate Winslet",
       "known_for": [
           "Titanic",
           "Eternal Sunshine of the Spotless Mind",
           "The Reader"
       ],
       "birthday": "1975-10-05",
       "deathday": null,
       "biography": "Kate Elizabeth Winslet (born 5 October 1975) is an English actress. Known for her work in independent films..."
     }
       ],
	// other search results fields: processingTimeMs, limit, ...
     }
   ]
 }

如您所见,在结果数组中,索引的排序顺序与查询中的顺序相同。响应包含常规搜索返回的 常用字段 以及索引 UID。请注意,在此示例中,我们使用 limit 参数将返回的文档数量限制为一个。

多索引搜索演示

Searching for 'Kate Winslet' returns both her biography and movies in which she starred, while searching for 'Titanic' returns the movie itself as well as actors who starred in it.

亲自试用

此演示使用两个数据集:电影和演员。每个数据集都存储在自己的索引中,具有自己的设置,并且正如您在上面的示例中看到的,具有自己的模式。

由于这两个索引具有不同的模式,因此它们具有不同的可搜索属性。在电影索引中,您可以按电影标题、角色、演员、制片人、导演或电影概述搜索电影。

//movies index 
searchableAttributes: [
   'title',
   'crew.name',
   'cast.name',
   'cast.character',
   'overview',
 ]

演员索引允许您按姓名搜索演员,以及他们最出名的电影或节目,以及在其传记中找到的关键字。

//actors index 
searchableAttributes: ['name', 'known_for', 'biography']

设置、数据集和代码的完整列表都可在 GitHub 上找到,因此请随时自行探索。请随意调整设置以根据您的需求自定义行为。如果您有改进演示的想法,例如添加 facets,请随时提交 pull request。欢迎所有贡献!

结论

我们很高兴交付联邦搜索的第一个迭代版本,并且我们将努力推动实现聚合搜索结果。如果没有我们开发者社区提供的宝贵反馈和见解,我们不可能实现这一点。您的反馈对于帮助我们确定优先级和塑造功能以满足您的需求至关重要。

如果您有兴趣了解我们的进展,我们鼓励您查看我们的产品路线图,加入我们在 GitHub 上的讨论,或在 Discord 上与我们联系。

与往常一样,我们致力于为用户提供最佳的搜索体验,并感谢您为实现这一目标提供的帮助。

Meilisearch indexes embeddings 7x faster with binary quantization

Meilisearch 通过二进制量化将 embeddings 索引速度提高 7 倍

通过使用向量存储 Arroy 实施二进制量化,在保持搜索相关性和效率的同时,大幅减少了大型 embeddings 的磁盘空间使用量和索引时间。

Tamo
Tamo2024 年 11 月 29 日
How to add AI-powered search to a React app

如何在 React 应用程序中添加 AI 驱动的搜索

使用 Meilisearch 的 AI 驱动的搜索构建一个 React 电影搜索和推荐应用程序。

Carolina Ferreira
Carolina Ferreira2024 年 9 月 24 日
Meilisearch is too slow

Meilisearch 速度太慢

在这篇博文中,我们将探讨 Meilisearch 文档索引器所需的增强功能。我们将讨论当前的索引引擎、其缺点以及优化性能的新技术。

Clément Renault
Clément Renault2024 年 8 月 20 日