【问题标题】:Solr grouped query pagination not working properly. [Solr, Lucene]Solr 分组查询分页无法正常工作。 [Solr,Lucene]
【发布时间】:2016-10-14 09:55:49
【问题描述】:

我已按字段 family 对我的 solr 文档进行分组。 获取前 20 个组的 solr 查询如下

/select?q=*:*&group=true&group.field=family&group.ngroups=true&start=0&group.limit=1

这个查询的结果是20组如下

responseHeader: {
 zkConnected: true,
 status: 0,
 QTime: 1260,
 params: {
  q: "*:*",
  group.limit: "1",
  start: "0",
  group.ngroups: "true",
  group.field: "family",
  group: "true"
 }
},
grouped: {
 family: {
 matches: 464779,
 ngroups: 396324,
 groups: [
 {
   groupValue: "__fam__ME.EA.HE.728928",
   doclist: {
   numFound: 1,
   start: 0,
   maxScore: 1,
   docs: [
   {
    sku: "ME.EA.HE.728928",
    title: "Rexton Pocket Family Hearing Instrument Fusion",
    family: "__fam__ME.EA.HE.728928",
    brand: "Rexton",
    brandId: "6739",
    inStock: false,
    bulkDiscount: false,
    quoteOnly: false,
    cats: [
     "Hearing Machine & Components",
     "Health & Personal Care",
     "Medical Supplies & Equipment"
    ],
    leafCatIds: [
     "6038"
    ],
    parentCatIds: [
     "6259",
     "4913"
    ],
    Type__attr__: "Pocket Family",
    Type of Products__attr__: "Hearing Instrument",
    price: 3790,
    discount: 40,
    createdAt: "2016-02-18T04:51:36Z",
    moq: 1,
    offerPrice: 2255,
    suggestKeywords: [
     "Rexton",
     "Pocket Family",
     "Rexton Pocket Family"
    ],
    suggestPayload: "6038,Hearing Machine & Components",
    _version_: 1548082328946868200
   }
  ]
 }
},

在这个结果中需要注意的是 ngroups 的值是396324

但是当我想获取最后一页的数据时,我会在 Solr 上点击此查询

select?q=*:*&group=true&group.field=family&group.ngroups=true&start=396320&group.limit=1

{
 responseHeader: {
 zkConnected: true,
 status: 0,
 QTime: 5238,
 params: {
  q: "*:*",
  group.limit: "1",
  start: "396320",
  group.ngroups: "true",
  group.field: "family",
  group: "true"
  }
 },
 grouped: {
  family: {
   matches: 464779,
   ngroups: 396324,
   groups: [ ]
   }
  }
 }

当我将 start 设置为 396320 时有 0 个结果。结果中必须有 5 个文档。实际组数为386887。为什么 ngroups 不正确?

顺便说一句,这个问题在我设置的本地 solr 服务器中不存在。只是出现在测试环境的 solr 云中

【问题讨论】:

    标签: json solr lucene solrcloud


    【解决方案1】:

    这是grouping across distributed nodes 的一个已知问题(在 SolrCloud 模式下会发生这种情况):

    分布式搜索支持分组,但有一些注意事项:

    目前任何分布式搜索都不支持 group.func

    group.ngroupsgroup.facet 要求每个组中的所有文档必须位于同一分片上,以便返回准确的计数。 Document routing via composite keys 在许多情况下都是有用的解决方案。

    最直接的解决方案是使用族作为路由键的一部分,确保所有相同的族值最终都在同一个节点上。与节点数相比,不同族值的数量似乎非常高,这仍应确保您在节点之间有良好的文档分布。

    根据您实际尝试执行的操作,可能还有其他替代解决方案(如果您只是想要计数,使用 JSON 方面可能是一个不错的解决方案)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-02
      • 1970-01-01
      • 1970-01-01
      • 2018-05-08
      • 2013-05-24
      • 2013-08-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多