Package org.apache.solr.client.solrj.response

Examples of org.apache.solr.client.solrj.response.FacetField


        if (queryResponse == null)
        {
            return new ObjectCount[0];
        }

        FacetField dateFacet = queryResponse.getFacetDate("time");
        // TODO: check if this cannot crash I checked it, it crashed!!!
        // Create an array for our result
        ObjectCount[] result = new ObjectCount[dateFacet.getValueCount()
                + (showTotal ? 1 : 0)];
        // Run over our datefacet & store all the values
        for (int i = 0; i < dateFacet.getValues().size(); i++)
        {
            FacetField.Count dateCount = dateFacet.getValues().get(i);
            result[i] = new ObjectCount();
            result[i].setCount(dateCount.getCount());
            result[i].setValue(getDateView(dateCount.getName(), dateType, context));
        }
        if (showTotal)
View Full Code Here


        solrQuery.addFacetField("field");

        QueryResponse response = getSolr().query(solrQuery);

        List<String> results = new ArrayList<String>();
        FacetField facetField = response.getFacetField("field");
        if(facetField != null){
            List<FacetField.Count> values = facetField.getValues();
            if(values != null){
                for (FacetField.Count facetValue : values) {
                    if (facetValue != null && facetValue.getName() != null) {
                        results.add(facetValue.getName());
                    }
View Full Code Here

            for (int i = 0; i < fieldsList.size(); i++) {
                String fn = fieldsList.getName(i);
                @SuppressWarnings("unchecked")
                NamedList<Object> values = (NamedList<Object>) fieldsList.getVal(i);
                String type = (String) values.get("type");
                facetResults.add(new FacetResultImpl(new FacetField(fn), type.trim()));
            }
        } catch (SolrServerException e) {
            String msg = "SolrSearchImpl.getFacetNames: Failed to execute solr query";
            log.error(msg, e);
            throw new SearchException(msg, e);
View Full Code Here

  }

  @Test
  public void testConvertFacetQueryResponseForQueryResultWithSingleFacetFieldWithoutValues() {
    List<FacetField> fieldList = new ArrayList<FacetField>(1);
    FacetField ffield = new FacetField("field_1");
    fieldList.add(ffield);

    Mockito.when(response.getFacetFields()).thenReturn(fieldList);

    Map<Field, Page<FacetFieldEntry>> result = ResultHelper.convertFacetQueryResponseToFacetPageMap(
        createFacetQuery("field_1"), response);
    Assert.assertNotNull(result);
    Assert.assertEquals(1, result.size());
    Entry<Field, Page<FacetFieldEntry>> resultEntry = result.entrySet().iterator().next();

    Assert.assertEquals(ffield.getName(), resultEntry.getKey().getName());
    Assert.assertTrue(resultEntry.getValue().getContent().isEmpty());
  }
View Full Code Here

  }

  @Test
  public void testConvertFacetQueryResponseForQueryResultWithSingeFacetField() {
    List<FacetField> fieldList = new ArrayList<FacetField>(1);
    FacetField ffield = createFacetField("field_1", 1, 2);
    fieldList.add(ffield);

    Mockito.when(response.getFacetFields()).thenReturn(fieldList);

    Map<Field, Page<FacetFieldEntry>> result = ResultHelper.convertFacetQueryResponseToFacetPageMap(
        createFacetQuery("field_1"), response);
    Assert.assertNotNull(result);
    Assert.assertEquals(1, result.size());
    Entry<Field, Page<FacetFieldEntry>> resultEntry = result.entrySet().iterator().next();

    Assert.assertEquals(ffield.getName(), resultEntry.getKey().getName());
    Assert.assertEquals(2, resultEntry.getValue().getContent().size());
  }
View Full Code Here

    fq.setFacetOptions(new FacetOptions().addFacetOnPivot(pivotFieldNames));
    return fq;
  }

  private FacetField createFacetField(String fieldName, long... values) {
    FacetField ffield = new FacetField(fieldName);
    for (int i = 1; i <= values.length; i++) {
      ffield.add("value_" + i, values[i - 1]);
    }
    return ffield;
  }
View Full Code Here

TOP

Related Classes of org.apache.solr.client.solrj.response.FacetField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.