solr中的分组条件

时间:2013-03-29 05:33:40

标签: solr grouping

这是我有的产品格式

<doc>
    <str name="productname">ipad</str>
    <str name="sku">1524856</str>
    <str name="store">apple.com</str>
</doc> 
<doc>
    <str name="productname">ipad</str>
    <str name="sku">1524856</str>
    <str name="store">apple.com</str>
</doc> 
<doc>
    <str name="productname">ipad</str>
    <str name="sku">1524856</str>
    <str name="store">buy.com</str>
</doc> 
<doc>
    <str name="productname">ipad</str>
    <str name="sku">1524856</str>
    <str name="store">amazon.com</str>
</doc> 
<doc>
    <str name="productname">ipad</str>
    <str name="sku">1524856</str>
    <str name="store">amazon.com</str>
</doc> 
<doc>
    <str name="productname">ipad</str>
    <str name="sku">1524856</str>
    <str name="store">ebay.com</str>
</doc> 

我必须将它与sku分组,所以我把它写成

http://**********/?q=ipad&wt=xml&group=true&group.field=upc&group.ngroups=true

在我的输出中是

<result name="doclist" numFound="6" start="0">
<doc>
    <str name="productname">ipad</str>
    <str name="sku">1524856</str>
    <str name="store">apple.com</str>
</doc> 

但我也希望与商店名称分组。如果具有相同sku的商店中的多个产品,则只需要一个商店

我的o / p应该是这样的(numfound = 4而不是6)

<result name="doclist" numFound="4" start="0">
<doc>
    <str name="productname">ipad</str>
    <str name="sku">1524856</str>
    <str name="store">apple.com</str>
</doc> 

1 个答案:

答案 0 :(得分:0)

我通过添加'group.limit = 100000'找到了一个解决方案,这显示了匹配条件的组中的所有文档列表,我使用php将其唯一分组