use*_*086 2 lucene solr full-text-search search-engine fieldcollapsing
使用Solr 3.3
密钥库项目名称描述类别价格
======================================== =================================
1商店名称Xbox 360 Nice游戏机电子游戏199.99
2商店名称Xbox 360 Nice游戏机电子游戏199.99
3商店名称Xbox 360尼斯游戏机电子游戏249.99
我有类似于上表的数据并加载到Solr.项目名称,描述类别,价格是可搜索的.
Facet Field
Category
Electronic(1)
Games(1)
**Store Name**
XBox 360 Nice game machine priced from 199.99 - 249.99
Run Code Online (Sandbox Code Playgroud)
什么是我可以发送给Solr以接收上述结果的查询参数,基本上我想按Store,ItemName,Description和min max price对它进行分组
我想保持分页与main(StoreName)一致.分页应基于"商店名称"组.所以如果找到20家商店.我应该能够正确页面.
请建议
如果使用Solr 4.0,则在添加参数"group.facet = true"时,新的"分组"(替换FieldCollapsing)可以解决此问题.
因此,要对字段进行分组,您需要将以下参数添加到搜索请求中:
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
Run Code Online (Sandbox Code Playgroud)
找到的组数是您向用户显示并用于分页的组,而不是正常的总计数,这将是索引中的文档总数.