SolrNet Grouping Question

63 views
Skip to first unread message

Adam Whittaker

unread,
Nov 17, 2014, 7:05:36 PM11/17/14
to sol...@googlegroups.com
Hello,

Is there a way to group by multiple columns and group by the phrase not the indexed words?

My data looks a little like this:

Column  A                              Column B
this is a phrase                       another sub phrase
this is a phrase                       another sub phrase
this is a phrase                       another sub phrase
this is a phrase                       another new sub phrase
this is a phrase                       another new sub phrase
something else                       something else sub phrase

I'm basically trying to group by both columns (the phrases), bring back the group names and counts.

I tried this but it is using the index so its breaking the individual words into groups and i cant figure out how to do it by two groups: 

    var r = solrcase.Query( new SolrQueryByRange<DateTime>("CASEREQUESTEDDATE", DateTime.Now.AddDays(-7),
                        DateTime.Now.AddDays(-1)), new QueryOptions
                        {
                            Grouping = new GroupingParameters
                            {
                                Format = GroupingFormat.Grouped,
                                Fields = new[] { "COLUMN A" },
                                Ngroups = true
                                                              
                                
                            }
                        });

            var test = r.Grouping["COLUMN A"];

Thanks,

Dorin Oltean

unread,
Nov 18, 2014, 8:54:08 AM11/18/14
to sol...@googlegroups.com
You can create a new column using copyField and choose another fieldType that contains KeywordTokenizerFactory
And then use that column to group.  That column could be multifield but I am not sure how multifield works with grouping.

If multifvalueield doesn't work with grouping, the new column value should be constructed before indexing.

Dorin Oltean

unread,
Nov 18, 2014, 8:54:51 AM11/18/14
to sol...@googlegroups.com
but this is done from Solr and not from solrnet.

Adam Whittaker

unread,
Nov 18, 2014, 10:37:39 AM11/18/14
to sol...@googlegroups.com
Thank you,

I ended up creating some new copy fields with string instead of text general. I then used pivot facets with the two columns as the pivot fields:

 var queryOptions = new QueryOptions
            {
                Facet = new FacetParameters
                {
                    Queries = new[]
                    {
                        new SolrFacetPivotQuery
                        {
                            Fields = new[] {new PivotFields("P_DEVICETYPE", "P_PROBLEMTYPE")},
                            MinCount = 1
                        }
                    },
                },
                Rows = 0
            };

I then used the pivot and childpivots to get my data - its works great.

Thanks again.
Reply all
Reply to author
Forward
0 new messages