SOLR-1825: SolrQuery.addFacetQuery now enables facets automatically

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1144564 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Christopher John Male 2011-07-09 01:02:27 +00:00
parent 038a555aef
commit 5c2923a1de
3 changed files with 10 additions and 0 deletions

View File

@ -260,6 +260,9 @@ Other Changes
* SOLR-2027: FacetField.getValues() now returns an empty list if there are no
values, instead of null (Chris Male)
* SOLR-1825: SolrQuery.addFacetQuery now enables facets automatically, like
addFacetField (Chris Male)
Documentation
----------------------

View File

@ -292,6 +292,7 @@ public class SolrQuery extends ModifiableSolrParams
*/
public SolrQuery addFacetQuery(String f) {
this.add(FacetParams.FACET_QUERY, f);
this.set(FacetParams.FACET, true);
return this;
}

View File

@ -195,4 +195,10 @@ public class SolrQueryTest extends LuceneTestCase {
q.setTermsRegexFlag("multiline");
assertEquals(2, q.getTermsRegexFlags().length);
}
public void testAddFacetQuery() {
SolrQuery solrQuery = new SolrQuery();
solrQuery.addFacetQuery("field:value");
assertTrue("Adding a Facet Query should enable facets", solrQuery.getBool(FacetParams.FACET));
}
}