List of usage examples for org.apache.solr.client.solrj.response FacetField toString
@Override
public String toString()
From source file:org.alfresco.solr.query.DistributedAlfrescoSolrFacetingTest.java
License:Open Source License
@Test public void distributedSearch_fieldFacetingRequiringRefinement_shouldReturnCorrectCounts() throws Exception { /*/* ww w . jav a2 s .co m*/ * The way this index is built is to have a correct distributed faceting count only after refining happens. * Given these params : facet.limit=2&facet.overrequest.count=0&facet.overrequest.ration=1 * Initially you will get these counts: * Shard 0 * a(2) b(2) * Shard 1 * c(3) b(2) * We didn't get [c] from shard0 and [a] from shard1. * The refinement phase will ask those shards for those counts. * Only if refinement works we'll see the correct results (compared to not sharded Solr) * */ index(getDefaultTestClient(), 0, "id", "10", "suggest", "b", "_version_", "0", "content@s___t@{http://www.alfresco.org/model/content/1.0}content", "a b"); index(getDefaultTestClient(), 0, "id", "20", "suggest", "b", "_version_", "0", "content@s___t@{http://www.alfresco.org/model/content/1.0}content", "a"); index(getDefaultTestClient(), 0, "id", "30", "suggest", "b", "_version_", "0", "content@s___t@{http://www.alfresco.org/model/content/1.0}content", "b c"); index(getDefaultTestClient(), 1, "id", "40", "suggest", "b", "_version_", "0", "content@s___t@{http://www.alfresco.org/model/content/1.0}content", "c b"); index(getDefaultTestClient(), 1, "id", "50", "suggest", "b", "_version_", "0", "content@s___t@{http://www.alfresco.org/model/content/1.0}content", "c b"); index(getDefaultTestClient(), 1, "id", "60", "suggest", "b", "_version_", "0", "content@s___t@{http://www.alfresco.org/model/content/1.0}content", "c"); commit(getDefaultTestClient(), true); String expectedFacetField = "{http://www.alfresco.org/model/content/1.0}content:[b (4), c (4)]"; String jsonQuery = "{\"query\":\"(suggest:b)\",\"locales\":[\"en\"], \"templates\": [{\"name\":\"t1\", \"template\":\"%cm:content\"}], \"authorities\": [\"joel\"], \"tenants\": []}"; putHandleDefaults(); QueryResponse queryResponse = query(getDefaultTestClient(), true, jsonQuery, params("qt", "/afts", "shards.qt", "/afts", "start", "0", "rows", "0", "fl", "score,id", "facet", "true", "facet.field", "{http://www.alfresco.org/model/content/1.0}content", "facet.limit", "2", "facet.overrequest.count", "0", "facet.overrequest.ratio", "1")); List<FacetField> facetFields = queryResponse.getFacetFields(); FacetField facetField = facetFields.get(0); Assert.assertThat(facetField.toString(), is(expectedFacetField)); }
From source file:org.alfresco.solr.query.DistributedAlfrescoSolrFacetingTest.java
License:Open Source License
@Test public void fieldFaceting_mincountMissing_shouldReturnFacetsMincountOne() throws Exception { String expectedContentFacetField = "{http://www.alfresco.org/model/content/1.0}content:[contenttwo (4), contentone (1)]"; String expectedNameFacetField = "{http://www.alfresco.org/model/content/1.0}name:[nametwo (4), nameone (1)]"; String jsonQuery = "{\"query\":\"(suggest:a)\",\"locales\":[\"en\"], \"templates\": [{\"name\":\"t1\", \"template\":\"%cm:content\"}], \"authorities\": [\"joel\"], \"tenants\": []}"; putHandleDefaults();//from ww w . jav a 2 s . co m QueryResponse queryResponse = query(getDefaultTestClient(), true, jsonQuery, params("qt", "/afts", "shards.qt", "/afts", "start", "0", "rows", "0", "fl", "score,id", "facet", "true", "facet.field", "{http://www.alfresco.org/model/content/1.0}content", "facet.field", "{http://www.alfresco.org/model/content/1.0}name")); List<FacetField> facetFields = queryResponse.getFacetFields(); FacetField contentFacetField = facetFields.get(0); Assert.assertThat(contentFacetField.toString(), is(expectedContentFacetField)); FacetField nameFacetField = facetFields.get(1); Assert.assertThat(nameFacetField.toString(), is(expectedNameFacetField)); }
From source file:org.alfresco.solr.query.DistributedAlfrescoSolrFacetingTest.java
License:Open Source License
@Test public void fieldFaceting_mincountSetZero_shouldReturnFacetsMincountOne() throws Exception { String expectedContentFacetField = "{http://www.alfresco.org/model/content/1.0}content:[contenttwo (4), contentone (1)]"; String expectedNameFacetField = "{http://www.alfresco.org/model/content/1.0}name:[nametwo (4), nameone (1)]"; String jsonQuery = "{\"query\":\"(suggest:a)\",\"locales\":[\"en\"], \"templates\": [{\"name\":\"t1\", \"template\":\"%cm:content\"}], \"authorities\": [\"joel\"], \"tenants\": []}"; putHandleDefaults();//w w w. j a va 2 s . c o m QueryResponse queryResponse = query(getDefaultTestClient(), true, jsonQuery, params("qt", "/afts", "shards.qt", "/afts", "start", "0", "rows", "0", "fl", "score,id", "facet", "true", "facet.field", "{http://www.alfresco.org/model/content/1.0}content", "facet.field", "{http://www.alfresco.org/model/content/1.0}name", "facet.mincount", "0")); List<FacetField> facetFields = queryResponse.getFacetFields(); FacetField contentFacetField = facetFields.get(0); Assert.assertThat(contentFacetField.toString(), is(expectedContentFacetField)); FacetField nameFacetField = facetFields.get(1); Assert.assertThat(nameFacetField.toString(), is(expectedNameFacetField)); }
From source file:org.alfresco.solr.query.DistributedAlfrescoSolrFacetingTest.java
License:Open Source License
@Test public void fieldFaceting_mincountSetTwo_shouldReturnFacetsOriginalMincount() throws Exception { String expectedContentFacetField = "{http://www.alfresco.org/model/content/1.0}content:[contenttwo (4)]"; String expectedNameFacetField = "{http://www.alfresco.org/model/content/1.0}name:[nametwo (4)]"; String jsonQuery = "{\"query\":\"(suggest:a)\",\"locales\":[\"en\"], \"templates\": [{\"name\":\"t1\", \"template\":\"%cm:content\"}], \"authorities\": [\"joel\"], \"tenants\": []}"; putHandleDefaults();// www .ja v a 2s . c om QueryResponse queryResponse = query(getDefaultTestClient(), true, jsonQuery, params("qt", "/afts", "shards.qt", "/afts", "start", "0", "rows", "0", "fl", "score,id", "facet", "true", "facet.field", "{http://www.alfresco.org/model/content/1.0}content", "facet.field", "{http://www.alfresco.org/model/content/1.0}name", "facet.mincount", "2")); List<FacetField> facetFields = queryResponse.getFacetFields(); FacetField contentFacetField = facetFields.get(0); Assert.assertThat(contentFacetField.toString(), is(expectedContentFacetField)); FacetField nameFacetField = facetFields.get(1); Assert.assertThat(nameFacetField.toString(), is(expectedNameFacetField)); }
From source file:org.alfresco.solr.query.DistributedAlfrescoSolrFacetingTest.java
License:Open Source License
@Test public void fieldFaceting_perFieldMincountSetZero_shoulReturnFacetsMincountOne() throws Exception { String expectedContentFacetField = "{http://www.alfresco.org/model/content/1.0}content:[contenttwo (4), contentone (1)]"; String expectedNameFacetField = "{http://www.alfresco.org/model/content/1.0}name:[nametwo (4), nameone (1)]"; String jsonQuery = "{\"query\":\"(suggest:a)\",\"locales\":[\"en\"], \"templates\": [{\"name\":\"t1\", \"template\":\"%cm:content\"}], \"authorities\": [\"joel\"], \"tenants\": []}"; putHandleDefaults();//w w w.java 2 s. c o m QueryResponse queryResponse = query(getDefaultTestClient(), true, jsonQuery, params("qt", "/afts", "shards.qt", "/afts", "start", "0", "rows", "0", "fl", "score,id", "facet", "true", "facet.field", "{http://www.alfresco.org/model/content/1.0}content", "facet.field", "{http://www.alfresco.org/model/content/1.0}name", "f.{http://www.alfresco.org/model/content/1.0}content.facet.mincount", "0", "f.{http://www.alfresco.org/model/content/1.0}name.facet.mincount", "0")); List<FacetField> facetFields = queryResponse.getFacetFields(); FacetField contentFacetField = facetFields.get(0); Assert.assertThat(contentFacetField.toString(), is(expectedContentFacetField)); FacetField nameFacetField = facetFields.get(1); Assert.assertThat(nameFacetField.toString(), is(expectedNameFacetField)); }
From source file:org.alfresco.solr.query.DistributedAlfrescoSolrFacetingTest.java
License:Open Source License
@Test public void fieldFaceting_perFieldMincountSetTwo_shoulReturnFacetsMincountTwo() throws Exception { String expectedContentFacetField = "{http://www.alfresco.org/model/content/1.0}content:[contenttwo (4)]"; String expectedNameFacetField = "{http://www.alfresco.org/model/content/1.0}name:[nametwo (4), nameone (1)]"; String jsonQuery = "{\"query\":\"(suggest:a)\",\"locales\":[\"en\"], \"templates\": [{\"name\":\"t1\", \"template\":\"%cm:content\"}], \"authorities\": [\"joel\"], \"tenants\": []}"; putHandleDefaults();//from w w w. ja v a 2s.c om QueryResponse queryResponse = query(getDefaultTestClient(), true, jsonQuery, params("qt", "/afts", "shards.qt", "/afts", "start", "0", "rows", "0", "fl", "score,id", "facet", "true", "facet.field", "{http://www.alfresco.org/model/content/1.0}content", "facet.field", "{http://www.alfresco.org/model/content/1.0}name", "f.{http://www.alfresco.org/model/content/1.0}content.facet.mincount", "2", "f.{http://www.alfresco.org/model/content/1.0}name.facet.mincount", "0")); List<FacetField> facetFields = queryResponse.getFacetFields(); FacetField contentFacetField = facetFields.get(0); Assert.assertThat(contentFacetField.toString(), is(expectedContentFacetField)); FacetField nameFacetField = facetFields.get(1); Assert.assertThat(nameFacetField.toString(), is(expectedNameFacetField)); }