发布日期: 2026-03-23
版本号: v1.40.0

本次更新主要增强了联合搜索功能,支持在federation对象中使用distinct属性,实现跨索引和跨远程的全局去重计算,并兼容分面分布与合并。性能方面显著优化,联合搜索速度提升约100毫秒,JSON文档生成效率提高以更好地处理大型文档,同时通过升级内存分配器大幅降低了高负载下的内存使用。此外,修复了多个安全漏洞和bug,包括密钥隐藏检查、网络问题、AWS Bedrock API支持以及虚拟文件系统兼容性等。新增了任务队列压缩API(需启用实验性功能标志),并进行了多项依赖升级和杂项改进。

更新内容 (中文)

本版本在联合搜索中新增了对 distinct 属性的支持,实现了跨索引的去重属性与分面分布统计功能。此外,还带来了显著的性能提升:联合搜索速度加快(约快100ms),优化了JSON文档生成机制以更好地处理大型文档,并大幅改善了大规模工作负载下的内存使用效率。

✨ 功能增强

  • 在联合搜索中支持 distinct 属性 — 由 @dureuill 提交于 https://github.com/meilisearch/meilisearch/pull/6214
    现在可以在联合搜索的 federation 对象中传递 distinct 属性,对结果应用全局的、跨索引及跨远程的去重计算。

    包含去重功能的联合搜索请求示例
    {
      "federation": {
        "distinct": "genres", // ✨ 新增功能
        "facetsByIndex": {    // 去重功能同样支持分面分布恢复
          "comics": ["genres"],
          "movies": ["genres"]
        },
        "mergeFacets": {}     // 去重功能同样支持分面分布合并
      },
      "queries": [
        {
          "indexUid": "comics",
          "q": "batman",
          "attributesToRetrieve": ["title", "genres"],
          "useNetwork": true   // 去重功能同样支持网络查询
        },
        {
          "indexUid": "movies",
          "q": "superman",
          "attributesToRetrieve": ["title", "genres"],
          "useNetwork": true
        }
      ]
    }
    
    包含去重功能的联合搜索响应示例
    {
      "hits": [
        {
          "title": "Batman",
          "genres": ["Family","Adventure","Comedy","Science Fiction","Crime"],
          "_federation": {
            "indexUid": "comics",
            "queriesPosition": 0,
            "weightedRankingScore": 1.0,
            "remote": "ms2"
          }
        },
        {
          "title": "Batman",
          "genres": ["Fantasy","Action"],
          "_federation": {
            "indexUid": "comics",
            "queriesPosition": 0,
            "weightedRankingScore": 1.0,
            "remote": "ms1"
          }
        },
        {
          "title": "Batman & Bill",
          "genres": ["Documentary"],
          "_federation": {
            "indexUid": "comics",
            "queriesPosition": 0,
            "weightedRankingScore": 0.9848484848484848,
            "remote": "ms1"
          }
        },
        {
          "title": "Superman: Red Son",
          "genres": [],
          "_federation": {
            "indexUid": "movies",
            "queriesPosition": 1,
            "weightedRankingScore": 0.9848484848484849,
            "remote": "ms0"
          }
        },
        {
          "title": "Superman, Spider-Man or Batman",
          "genres": ["Drama"],
          "_federation": {
            "indexUid": "movies",
            "queriesPosition": 1,
            "weightedRankingScore": 0.9848484848484849,
            "remote": "ms0"
          }
        }
      ],
      "processingTimeMs": 15,
      "limit": 5,
      "offset": 0,
      "estimatedTotalHits": 11,
      "facetDistribution": {
        "genres": {
          "Action": 1,
          "Adventure": 1,
          "Comedy": 3,
          "Crime": 2,
          "Documentary": 1,
          "Drama": 1,
          "Family": 1,
          "Fantasy": 1,
          "Horror": 2,
          "Romance": 1,
          "Science Fiction": 1,
          "Thriller": 1,
          "Western": 1
        }
      },
      "facetStats": {},
      "requestUid": "019d05c7-ea65-77a1-8274-22a8ba9e26db",
      "remoteErrors": {}
    }
    

    注意:在联合搜索层级应用去重属性时,需遵守以下规则:

    1. 禁止同时在查询层级和联合搜索层级应用 distinct,否则将返回 HTTP 400 错误。
    2. 所选的去重字段将应用于所有远程服务和索引,因此它必须是所有参与的远程服务和索引的可过滤属性。
    3. 尽管 Meilisearch 会尝试计算最精确的分面分布,但在分布式环境中无法保证这一点,因为去重算法并未应用于所有远程文档。
  • 提升联合搜索性能 — 由 @dureuill 提交于 https://github.com/meilisearch/meilisearch/pull/6229
    提升了联合搜索性能:所有请求速度约快100ms。增强了HTTP服务器的可靠性:服务器在处理大量联合搜索请求时不再被阻塞。

  • 优化JSON文档生成 — 由 @Kerollmops 提交于 https://github.com/meilisearch/meilisearch/pull/6257
    解决了用户在请求大型文档时可能遇到的性能问题。此外,当用户仅请求大型文档的小部分字段时,性能也得到了提升。

  • 使用最新版 mimalloc 以改善内存使用 — 由 @Kerollmops 提交于 https://github.com/meilisearch/meilisearch/pull/6201
    将 mimalloc 从 v2 更新至 v3,改善了线程间的内存共享,并显著减少了大规模工作负载下的内存使用。同时,它在链接时覆盖了分配器以使用 mimalloc,允许 LMDB、Meilisearch 及其他C语言库共享分配,从而提升整体内存效率。@Kerollmops 撰写了关于此改进背后故事的博客文章

  • 新增 POST /tasks/compact 端点用于任务队列压缩 — 由 @YoEight 提交于 https://github.com/meilisearch/meilisearch/pull/6193
    压缩任务队列数据库并回收空间,使得新任务可以持续入队,而无需删除现有任务。此功能位于实验性功能标志 taskQueueCompactionRoute 之后。

[!WARNING]
任务队列压缩完成后,所有写入操作将被阻止,直到服务器重启。

🔐 安全

🪲 错误修复

🔩 其他杂项

新贡献者

更新内容 (原始)

This release introduced support for the distinct attribute in federated search, enabling cross-index distinct attributes with facet distribution support. Additionally, significant performance improvements were delivered, including faster federated search (approximately 100ms faster), optimized JSON document generation for better handling of large documents and a much better memory usage for large workloads.

✨ Enhancement

  • Support distinct in federated search by @dureuill in https://github.com/meilisearch/meilisearch/pull/6214

    The distinct attribute can now be passed to the federation object in federated search to apply a global, cross-index and cross-remote distinct computation to the results.

    Example of a federated search request with distinct
    {
      "federation": {
        "distinct": "genres", // ✨ NEW
        "facetsByIndex": { // recovering facet distribution is also supported with distinct
          "comics": [
            "genres"
          ],
          "movies": [
            "genres"
          ]
        },
        "mergeFacets": {} // merging facet distributions is also supported with distinct
      },
      "queries": [
        {
          "indexUid": "comics",
          "q": "batman",
          "attributesToRetrieve": ["title", "genres"],
          "useNetwork": true // distinct is also supported with network queries
        },
        {
          "indexUid": "movies",
          "q": "superman",
          "attributesToRetrieve": ["title", "genres"],
          "useNetwork": true
        }
      ]
    }
    
    Sample response to a federated search request with distinct
    {
      "hits": [
        {
          "title": "Batman",
          "genres": [
            "Family",
            "Adventure",
            "Comedy",
            "Science Fiction",
            "Crime"
          ],
          "_federation": {
            "indexUid": "comics",
            "queriesPosition": 0,
            "weightedRankingScore": 1.0,
            "remote": "ms2"
          }
        },
        {
          "title": "Batman",
          "genres": [
            "Fantasy",
            "Action"
          ],
          "_federation": {
            "indexUid": "comics",
            "queriesPosition": 0,
            "weightedRankingScore": 1.0,
            "remote": "ms1"
          }
        },
        {
          "title": "Batman & Bill",
          "genres": [
            "Documentary"
          ],
          "_federation": {
            "indexUid": "comics",
            "queriesPosition": 0,
            "weightedRankingScore": 0.9848484848484848,
            "remote": "ms1"
          }
        },
        {
          "title": "Superman: Red Son",
          "genres": [],
          "_federation": {
            "indexUid": "movies",
            "queriesPosition": 1,
            "weightedRankingScore": 0.9848484848484849,
            "remote": "ms0"
          }
        },
        {
          "title": "Superman, Spider-Man or Batman",
          "genres": [
            "Drama"
          ],
          "_federation": {
            "indexUid": "movies",
            "queriesPosition": 1,
            "weightedRankingScore": 0.9848484848484849,
            "remote": "ms0"
          }
        }
      ],
      "processingTimeMs": 15,
      "limit": 5,
      "offset": 0,
      "estimatedTotalHits": 11,
      "facetDistribution": {
        "genres": {
          "Action": 1,
          "Adventure": 1,
          "Comedy": 3,
          "Crime": 2,
          "Documentary": 1,
          "Drama": 1,
          "Family": 1,
          "Fantasy": 1,
          "Horror": 2,
          "Romance": 1,
          "Science Fiction": 1,
          "Thriller": 1,
          "Western": 1
        }
      },
      "facetStats": {},
      "requestUid": "019d05c7-ea65-77a1-8274-22a8ba9e26db",
      "remoteErrors": {}
    }
    

    Note the following to apply the distinct attribute at the federation level:

    1. Applying distinct at the query level at the same time as the federation level is disallowed and will return a HTTP 400 error.
    2. The chosen distinct field will apply to all remotes and indexes, so it must be a filterable attribute for all participating remotes and indexes.
    3. While Meilisearch attempts to compute the most accurate facet distribution, in distributed contexts this cannot be guaranteed as the distinct algorithm is not applied on all of the remote documents.
  • Improve performance of federated search by @dureuill in https://github.com/meilisearch/meilisearch/pull/6229

    Improves performance of federated search: about 100ms faster for all requests. Improves reliability of the HTTP server: the server will no longer be blocked when too many federated search requests are being processed.

  • Optimize the generation of JSON documents by @Kerollmops in https://github.com/meilisearch/meilisearch/pull/6257

    Addresses performance issues that users might encounter when requesting large documents. Additionally, performance is enhanced when users request only a small subset of fields from large documents.

  • Use the latest version of mimalloc to improve memory usage by @Kerollmops in https://github.com/meilisearch/meilisearch/pull/6201

    Updates mimalloc from v2 to v3, improving memory sharing between threads and significantly reducing memory usage on large workloads. It also overrides the allocator to use mimalloc at linking time, allowing LMDB, Meilisearch, and other C libraries to share their allocations for better overall memory efficiency. @Kerollmops wrote a blog post about the story behind this improvement.

  • Add POST /tasks/compact for task queue compaction by @YoEight in https://github.com/meilisearch/meilisearch/pull/6193

    Compacts the task queue database and reclaim space so new tasks can keep being enqueued, without deleting existing tasks. This feature is behind the taskQueueCompactionRoute experimental feature flag.

[!WARNING]
Once task queue compaction completes, all write operations are blocked until the server is restarted.

🔐 Security

🪲 Bug fixes

🔩 Miscellaneous

New Contributors

下载链接