mirror of https://github.com/apache/lucene.git
SOLR-2098 SOLR-236: make faceting work with field collapsing
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@997504 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ff5a2942d3
commit
2d02e21ed3
|
@ -245,7 +245,9 @@ public class QueryComponent extends SearchComponent
|
||||||
|
|
||||||
if (cmd.groupCommands != null) {
|
if (cmd.groupCommands != null) {
|
||||||
searcher.search(result,cmd);
|
searcher.search(result,cmd);
|
||||||
|
rb.setResult( result );
|
||||||
rsp.add("grouped", result.groupedResults);
|
rsp.add("grouped", result.groupedResults);
|
||||||
|
// TODO: get "hits" a different way
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
|
|
|
@ -912,7 +912,7 @@ public class SolrIndexSearcher extends IndexSearcher implements SolrInfoMBean {
|
||||||
if (last < 0 || last > maxDoc()) last=maxDoc();
|
if (last < 0 || last > maxDoc()) last=maxDoc();
|
||||||
|
|
||||||
boolean needScores = (cmd.getFlags() & GET_SCORES) != 0;
|
boolean needScores = (cmd.getFlags() & GET_SCORES) != 0;
|
||||||
|
boolean getDocSet = (cmd.getFlags() & GET_DOCSET) != 0;
|
||||||
Query query = QueryUtils.makeQueryable(cmd.getQuery());
|
Query query = QueryUtils.makeQueryable(cmd.getQuery());
|
||||||
|
|
||||||
final Filter luceneFilter = filter==null ? null : filter.getTopFilter();
|
final Filter luceneFilter = filter==null ? null : filter.getTopFilter();
|
||||||
|
@ -943,7 +943,19 @@ public class SolrIndexSearcher extends IndexSearcher implements SolrInfoMBean {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
search(query, luceneFilter, MultiCollector.wrap(collectors));
|
Collector allCollectors = MultiCollector.wrap(collectors);
|
||||||
|
DocSetCollector setCollector = null;
|
||||||
|
if (getDocSet) {
|
||||||
|
// TODO: can callCollectors be zero length?
|
||||||
|
setCollector = new DocSetDelegateCollector(maxDoc()>>6, maxDoc(), allCollectors);
|
||||||
|
allCollectors = setCollector;
|
||||||
|
}
|
||||||
|
|
||||||
|
search(query, luceneFilter, allCollectors);
|
||||||
|
|
||||||
|
if (getDocSet) {
|
||||||
|
qr.docListAndSet.docSet = setCollector.getDocSet();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: make this a generic collector list
|
// TODO: make this a generic collector list
|
||||||
List<Phase2GroupCollector> phase2Collectors = new ArrayList<Phase2GroupCollector>(cmd.groupCommands.size());
|
List<Phase2GroupCollector> phase2Collectors = new ArrayList<Phase2GroupCollector>(cmd.groupCommands.size());
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
package org.apache.solr;
|
package org.apache.solr;
|
||||||
|
|
||||||
|
import org.apache.lucene.search.FieldCache;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -214,7 +215,15 @@ public class TestGroupingSearch extends SolrTestCaseJ4 {
|
||||||
"]}}"
|
"]}}"
|
||||||
);
|
);
|
||||||
|
|
||||||
};
|
// test that faceting works with grouping
|
||||||
|
assertJQ(req("fq",filt, "q","{!func}"+f2, "group","true", "group.field",f, "fl","id"
|
||||||
|
,"facet","true", "facet.field",f)
|
||||||
|
,"/grouped/foo_i/matches:10:"
|
||||||
|
,"/facet_counts/facet_fields/"+f+":['1',3, '2',3, '3',2, '4',1, '5',1]"
|
||||||
|
);
|
||||||
|
purgeFieldCache(FieldCache.DEFAULT); // avoid FC insanity
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue