I'm trying to group my documents but I don't understand how to make a combined query. Example:
<doc1>
<id>1</id>
<myid>1</myid>
<name>test</name>
</doc1>
<doc2>
<id>2</id>
<myid>1</myid>
<name>test2</name>
</doc2>
When I group on myid I get only 1 group result which is excepted. But I wonder how I could get a list of the names with that group.
something like:
<Response>
<doc>
<id>1,2</id>
<myid>1</myid>
<name>test1,test2</name> //this
</doc>
The query I'm using:
SolrQuery sq = new SolrQuery();
sq.setQuery("*:*");
sq.setStart(0);
sq.setRows(100);
sq.setParam("group", true);
sq.setParam("group.field","myid");
I don't know how to read the groupresponse to get the name values for that grouped item?
I noticed there's an option to set group.limit and group.offset which allow me to get multiple results. But I'm still wondering if its possible to get a list of the 'name' fields. I think I need to facet name on the group results but I don't know how.
If you have Solr source code
Refer to the QueryResponseTest.java
JUnit and testGroupResponse()
method
SOLR-2637 is applied 3.4 onwards.
Check out the patch SOLR-2637.patch also.