private static List<FacetFieldResult> processFacetFields(Facets facets, List<FacetField> facetFields) { List<FacetFieldResult> ret = new ArrayList<>(); FacetFieldResult facetResult; if (facetFields != null) { for (FacetField facet : facetFields) { LOGGER.trace("facet:{} count:{}", facet.getName(), facet.getValueCount()); facetResult = new FacetFieldResult(facet.getName(), facet.getValueCount(), facets.getParameters().get(facet.getName()).getValues()); for (Count count : facet.getValues()) { LOGGER.trace(" value:{} value:{}", count.getName(), count.getCount()); facetResult.addFacetValue(count.getName(), count.getName(), count.getCount()); } ret.add(facetResult); } } return ret; }
protected Map<String, Map<String, Long>> getFacetCounts(List<String> fields, QueryResponse solrResponse) { Map<String, Map<String, Long>> fieldCounts = new HashMap<>(); for (String field : fields) { Map<String, Long> valueCounts = new HashMap<>(); FacetField facetField = solrResponse.getFacetField(field); for (Count facetCount : facetField.getValues()) { valueCounts.put(facetCount.getName(), facetCount.getCount()); } fieldCounts.put(field, valueCounts); } return fieldCounts; }
@Override public Iterator<Node> listGraphNodes() { try { final QueryResponse response = cloud.query(LIST_GRAPHS_QUERY); final FacetField graphFacetField = response.getFacetField(Field.C); if (graphFacetField != null && graphFacetField.getValueCount() > 0) { final List<Node> graphs = new ArrayList<Node>(); for (final FacetField.Count graphName : graphFacetField.getValues()) { graphs.add(NTriples.asURI(graphName.getName())); } return graphs.iterator(); } return EMPTY_GRAPHS_ITERATOR; } catch (final Exception exception) { LOGGER.error(MessageCatalog._00113_NWS_FAILURE, exception); throw new SolrException(ErrorCode.SERVER_ERROR, exception); } }
public String getName() { return this.field.getName(); }
private String createFacetQuery(List<FacetField> facetFields) { if(facetFields == null || facetFields.isEmpty()) { return ""; } StringBuffer buff = new StringBuffer(); for(FacetField query:facetFields) { buff.append(query.getName()); buff.append("(" + query.getValueCount() + ") "); } return buff.toString(); }
FacetField f = new FacetField( facet.getKey() ); for( Map.Entry<String, Number> entry : facet.getValue() ) { f.add( entry.getKey(), entry.getValue().longValue() ); FacetField nl = f.getLimitingFields( minsize ); if( nl.getValueCount() > 0 ) { _limitingFacets.add( nl ); String gap = (String) values.get("gap"); Date end = (Date) values.get("end"); FacetField f = new FacetField(facet.getKey(), gap, end); f.add(entry.getKey(), Long.parseLong(entry.getValue().toString())); } catch (NumberFormatException e) {
public Long getCount() { return Long.valueOf(this.field.getValueCount()); }
public FacetField getLimitingFields(long max) { FacetField ff = new FacetField( _name ); if( _values != null ) { ff._values = new ArrayList<>( _values.size() ); for( Count c : _values ) { if( c._count < max ) { // !equal to ff._values.add( c ); } } } return ff; }
private static void facetFieldToXML(FacetField facet, XMLWriter xml) throws IOException { xml.openElement("facet"); xml.attribute("name", facet.getName()); xml.attribute("count", facet.getValueCount()); for (Count count : facet.getValues()) { xml.openElement("term"); xml.attribute("field", facet.getName()); xml.attribute("text", count.getName()); xml.attribute("cardinality", String.valueOf(count.getCount())); xml.closeElement(); } xml.closeElement(); } }
private void setFacetFieldCounts(FacetField facetField, Map<String, Long> countMap){ if ((facetField ==null)||(countMap==null)){ return; } for (FacetField.Count fcnt : facetField.getValues()){ countMap.put(fcnt.getName().toLowerCase().replace(" ", "_") + "_count", fcnt.getCount()); } }
if (0 < field.getValueCount()) { ObjectCount[] result = new ObjectCount[field.getValueCount() + (showTotal ? 1 : 0)]; for (int i = 0; i < field.getValues().size(); i++) { FacetField.Count fieldCount = field.getValues().get(i); result[i] = new ObjectCount(); result[i].setCount(fieldCount.getCount());
/** get * * @param name the name of the * @return the FacetField by name or null if it does not exist */ public FacetField getFacetField(String name) { if (_facetFields==null) return null; for (FacetField f : _facetFields) { if (f.getName().equals(name)) return f; } return null; }
if (facetField.getValueCount() > 0){ chunkResults += facetField.getValueCount(); if (results.containsKey(facetField.getName())){ int current = results.get(facetField.getName()); results.put(facetField.getName(), current+facetField.getValueCount()); results.put(facetField.getName(), facetField.getValueCount()); else if (!results.containsKey(facetField.getName())){ results.put(facetField.getName(), 0);
FacetField f = new FacetField( facet.getKey() ); for( Map.Entry<String, Number> entry : facet.getValue() ) { f.add( entry.getKey(), entry.getValue().longValue() ); FacetField nl = f.getLimitingFields( minsize ); if( nl.getValueCount() > 0 ) { _limitingFacets.add( nl );
public FacetField getLimitingFields(long max) { FacetField ff = new FacetField( _name ); if( _values != null ) { ff._values = new ArrayList<Count>( _values.size() ); for( Count c : _values ) { if( c._count < max ) { // !equal to ff._values.add( c ); } } } return ff; }
if (response.getFacetFields() != null) { for (FacetField facet : response.getFacetFields()) { String facetFieldName = facet.getName(); SearchFacetDTO facetDTO = namedFacetMap.get(facetFieldName); for (Count value : facet.getValues()) { SearchFacetResultDTO resultDTO = new SearchFacetResultDTO(); resultDTO.setFacet(facetDTO.getFacet());
static Map<Field, Page<FacetFieldEntry>> convertFacetQueryResponseToFacetPageMap(FacetQuery query, QueryResponse response) { Assert.notNull(query, "Cannot convert response for 'null', query"); if (!hasFacets(query, response)) { return Collections.emptyMap(); } Map<Field, Page<FacetFieldEntry>> facetResult = new LinkedHashMap<>(); if (!CollectionUtils.isEmpty(response.getFacetFields())) { int initalPageSize = Math.max(1, query.getFacetOptions().getPageable().getPageSize()); for (FacetField facetField : response.getFacetFields()) { if (facetField != null && StringUtils.hasText(facetField.getName())) { Field field = new SimpleField(facetField.getName()); if (!CollectionUtils.isEmpty(facetField.getValues())) { List<FacetFieldEntry> pageEntries = new ArrayList<>(initalPageSize); for (Count count : facetField.getValues()) { if (count != null) { pageEntries.add(new SimpleFacetFieldEntry(field, count.getName(), count.getCount())); } } facetResult.put(field, new SolrResultPage<>(pageEntries, query.getFacetOptions().getPageable(), facetField.getValueCount(), null)); } else { facetResult.put(field, new SolrResultPage<>(Collections.<FacetFieldEntry> emptyList(), query.getFacetOptions().getPageable(), 0, null)); } } } } return facetResult; }
@Override public Object transform(final Object fieldName) { FacetField facetResult = m_solrResultList == null ? null : m_solrResultList.getFacetField(fieldName.toString()); I_CmsSearchControllerFacetField facetController = m_controller.getFieldFacets().getFieldFacetController().get( fieldName.toString()); List<String> result = new ArrayList<String>(); if (null != facetController) { List<String> checkedEntries = facetController.getState().getCheckedEntries(); if (null != facetResult) { List<String> returnedValues = new ArrayList<String>(facetResult.getValues().size()); for (FacetField.Count value : facetResult.getValues()) { returnedValues.add(value.getName()); } for (String checked : checkedEntries) { if (!returnedValues.contains(checked)) { result.add(checked); } } } else { result = checkedEntries; } } return result; } });
if (0 < field.getValueCount()) ObjectCount[] result = new ObjectCount[field.getValueCount() + (showTotal ? 1 : 0)]; for (int i = 0; i < field.getValues().size(); i++) FacetField.Count fieldCount = field.getValues().get(i); result[i] = new ObjectCount(); result[i].setCount(fieldCount.getCount());