fieldcollapsing - Solr grouping using a comma separated field value -
i have comma separated field value called 'categories' have indexed & stored using custom field type defined as:
<fieldtype name="text_comma_delimited" class="solr.textfield"> <analyzer> <tokenizer class="solr.patterntokenizerfactory" pattern="," /> </analyzer> </fieldtype>
and defined field as:
<field name="categories" type="text_comma_delimited" indexed="true" stored="true" />
now want products grouped these categories use simple grouping query this:
http://localhost:8089/solr/products/select?q=*:*&wt=json&indent=true&group=true&group.field=categories&group.limit=-1&rows=-1&group.ngroups=true&group.facet=true
but result gives 2 groups instead of 6. seems considering one-one relationship between product , category hence 1 product appearing once should 1 many. 1 product can appear in more 1 categories. here result:
{ "responseheader":{ "status":0, "qtime":2, "params":{ "fl":"category,sku", "group.ngroups":"true", "indent":"true", "start":"0", "q":"*:*", "group.limit":"-1", "group.field":"category", "group":"true", "wt":"json", "group.facet":"true", "rows":"-1"}}, "grouped":{ "specialties":{ "matches":6, "ngroups":2, "groups":[{ "groupvalue":"fiction", "doclist":{"numfound":3,"start":0,"docs":[ { "sku":"f5678", "category":"fiction,abc,xyz"}, { "sku":"f9876", "category":"fiction,abc,pqr"}, { "sku":"f2365", "category":"pqr,fiction"}, ]}, { "groupvalue":"technical", "doclist":{"numfound":1,"start":0,"docs":[ { "sku":"t9876", "category":"cvb,technical"}] }}]}}}
i tried faceting , shows correct count each category url:
http://localhost:8089/solr/products/select?q=*:*&wt=json&indent=true&facet=true&facet.field=categories
the result gives me perfect list , count, above grouping response falls short of data:
"facet_counts":{ "facet_queries":{}, "facet_fields":{ "categories":[ "fiction",3, "mystery",1, "sci-fi",1, "self help",1, "technical",1, "philosophy",1 ]}, "facet_dates":{}, "facet_ranges":{}}}
also, 'load term info' in schema browser of solr admin console shows above field values , count. group query not returning correctly. else can tried this? appreciated.
Comments
Post a Comment