使用 Solr 3.3
主要商店项目名称描述类别价格
================================================ =======================
1 店名 Xbox 360 不错的游戏机 电子游戏 199.99
2 店名 Xbox 360 尼斯游戏机 电子游戏 199.99
3 店名 Xbox 360 尼斯游戏机 电子游戏 249.99
我有类似于上表的数据并加载到 Solr 中。项目名称, description Category, Price 可搜索。
预期结果
Facet Field
Category
Electronic(1)
Games(1)
**Store Name**
XBox 360 Nice game machine priced from 199.99 - 249.99
我可以发送给 Solr 以接收上面的结果的查询参数是什么,基本上我想按 Store、ItemName、Description 和 min max price 对其进行分组
而且我想使分页与主要 (StoreName) 保持一致。分页应基于 Store Name 组。因此,如果找到 20 家商店。我应该能够正确分页。
请推荐
最佳答案
如果使用 Solr 4.0,新的“Grouping”(取代 FieldCollapsing)在您添加参数“group.facet=true”时修复了这个问题。
因此,要对您的字段进行分组,您需要将以下参数添加到您的搜索请求中:
group=true // Enables grouping
group.facet=true // Facet counts to be number of groups instead of documents
group.field=Store // Groups results by the field "Store"
group.ngroups=true // Tells Solr to return the number of groups found
找到的组数是您将向用户显示并用于分页的数量,而不是正常的总数,即索引中的文档总数。
关于solr - 对结果进行分组并保持分面计数一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7238205/