当前位置: 首页>>代码示例>>Java>>正文


Java FacetField.Count方法代码示例

本文整理汇总了Java中org.apache.solr.client.solrj.response.FacetField.Count方法的典型用法代码示例。如果您正苦于以下问题:Java FacetField.Count方法的具体用法?Java FacetField.Count怎么用?Java FacetField.Count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.client.solrj.response.FacetField的用法示例。


在下文中一共展示了FacetField.Count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processFacetResults

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
/**
 * Add any faceting results to the result builder.
 *
 * @param resultsBuilder query result builder
 * @param facetFields faceting results
 */
protected void processFacetResults(QueryResults.Builder<QR> resultsBuilder, List<FacetField> facetFields) {
    if (facetFields != null) {
        for (FacetField facetField : facetFields) {
            String fieldName = facetField.getName();

            List<FacetCount> facetCounts = new ArrayList<>();
            for (FacetField.Count count : facetField.getValues()) {
                facetCounts.add(new FacetCount(count.getName(), count.getCount()));
            }

            FacetResult facetResult = new FacetResult(fieldName, facetCounts);
            resultsBuilder.addFacetResult(facetResult);
        }
    }
}
 
开发者ID:bbende,项目名称:tripod,代码行数:22,代码来源:SolrService.java

示例2: removeSelected

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
private FacetField removeSelected(FacetField facetField, FacetSelection selection) {
    FacetField filtered = new FacetField(facetField.getName());
    if (selection != null
            && selection.getSelectionType() == FacetSelectionType.AND) {
        //we want to exclude the selected option(s) in case of an AND selection
        for (FacetField.Count value : facetField.getValues()) {
            final String valueName = value.getName();
            if (selection.getValues().contains(valueName)
                    //exclude negative value selectors
                    //(not such a great solution, added to make availability facet checkboxes work)
                    && selection.getQualifier(valueName) != FacetSelectionValueQualifier.NOT
                    ) {
                continue;
            } else {
                filtered.add(valueName, value.getCount());
            }
        }
        return filtered;
    } else {
        return facetField;
    }

}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:24,代码来源:FacetFieldsModel.java

示例3: getRowTotal

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
public Long getRowTotal(Member row) {
	FacetField.Count count = null;
	for(FacetField.Count c : totalRows.getValues()) {
		if(c.getName() == null) {
			if(row.getValue() == null){
				count = c;
				break;
			}
		} else if(c.getName().equals(row.getValue())) {
			count = c;
			break;
		}
	}
	if(count == null) {
		return null;
	} else {
		return count.getCount();
	}
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:20,代码来源:CellSet.java

示例4: getColumnTotal

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
public Long getColumnTotal(Member col) {
	FacetField.Count count = null;
	for(FacetField.Count c : totalCols.getValues()) {
		if(c.getName() == null) {
			if(col.getValue() == null) {
				count = c;
				break;
			}
		} else if(c.getName().equals(col.getValue())) {
			count = c;
			break;
		}
	}
	if(count == null) {
		return null;
	} else {
		return count.getCount();
	}
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:20,代码来源:CellSet.java

示例5: getPickableValues

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
public List<String> getPickableValues(Field field, String solrServer) throws ReportingException {
	if (!fields.contains(field)) {
		throw new IllegalArgumentException("This report doesn't contain the specified field " + field);
	}
	if (field.getValuesMode() != Field.ValuesMode.PICK) {
		throw new IllegalArgumentException("This field isn't pickable " + field);
	}

	List<String> result = new ArrayList<>();

	HttpSolrServer solr = new HttpSolrServer(solrServer);
	SolrQuery query = toPickableValuesQuery(field.getName());
	try {
		QueryResponse response = solr.query(query);
		FacetField facetField = response.getFacetField(field.getName());
		List<FacetField.Count> values = facetField.getValues();
		for (FacetField.Count value : values) {
			result.add(value.getName());
		}
		Collections.sort(result);
	} catch (SolrServerException e) {
		throw new ReportingException("Could not determine pickable values", e);
	}
	return result;
}
 
开发者ID:UoW-IRRs,项目名称:API-Extras,代码行数:26,代码来源:Report.java

示例6: verifyFacetFieldValue

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
private void verifyFacetFieldValue(FacetField facetField, String facetFieldValue, int facetFieldCount) {
    FacetField.Count fc = null;
    int count = 0;
    boolean matched = false;
    LOG.info("Facet field name=" + facetField.getName() + "; Expected facetFieldValue=" + facetFieldValue
            + "; facetFieldCount=" + facetFieldCount);

    List<FacetField.Count> facetFieldValues = facetField.getValues();
    if (null != facetFieldValues) {
        for (int i = 0; i < facetFieldValues.size(); i++) {
            fc = facetFieldValues.get(i);
            //LOG.info("fc.getName()=" + fc.getName() + "; fc.getCount()=" + fc.getCount());
            if (fc.getName().equals(facetFieldValue)) {
                LOG.info("Expected facetFieldValue found.");
                assertEquals(facetFieldCount, fc.getCount());
                matched = true;
                break;
            }
        }
    }
    if (!matched) {
        LOG.info("Expected facetFieldValue not found.");
    }
    assertEquals(matched, true);
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:26,代码来源:DiscoveryIndexer_AT.java

示例7: listGraphNodes

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
@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);
	}	
}
 
开发者ID:spaziocodice,项目名称:SolRDF,代码行数:19,代码来源:CloudDatasetGraph.java

示例8: searchTermsInternal

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
private SearchResultsBean searchTermsInternal(String searchQuery, String facetField, Map<String, String> attributes, UserRegistry registry) throws IndexerException, RegistryException {
    SearchResultsBean resultsBean = new SearchResultsBean();
    SolrClient client = SolrClient.getInstance();
    //authenticate required attribute is not used, since we are going to authorize each time and not depends on this flag.
    attributes.remove(IndexingConstants.AUTH_REQUIRED);
    List<FacetField.Count> results = (searchQuery == null) ? client.facetQuery(registry.getTenantId(), attributes) :
            client.facetQuery(searchQuery, facetField, registry.getTenantId());

    if (log.isDebugEnabled()) {
        log.debug("result for the term search: " + results);
    }

    List<TermData> termDataList = new ArrayList<>();
    for (FacetField.Count count : results) {
        termDataList.add(new TermData(count.getName(), count.getCount()));
    }
    resultsBean.setTermDataList(termDataList.toArray(new TermData[termDataList.size()]));
    return resultsBean;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:20,代码来源:ContentBasedSearchService.java

示例9: getTermSearchResultsWithException

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
@Test
public void getTermSearchResultsWithException() throws Exception {
    List<FacetField.Count> resultList = new ArrayList<>();
    FacetField.Count count = new FacetField.Count(new FacetField("tags_ss"), "tag1", 2);
    resultList.add(count);
    when(client.facetQuery(anyInt(), (Map)anyObject())).thenReturn(resultList);
    when(service.getTermSearchResults((String[][]) anyObject())).thenCallRealMethod();
    when(service.searchTerms((Map)anyObject(), (UserRegistry)anyObject())).thenThrow(new IndexerException
            ("Test Exception", new Exception()));

        String[][] searchAttributes = new String[2][2];
        searchAttributes[0][0] = "facet.field";
        searchAttributes[0][1] = "tags";
        searchAttributes[1][0] = "mediaType";
        searchAttributes[1][1] = "application/json";
        SearchResultsBean resultsBean = service.getTermSearchResults(searchAttributes);
        TermData[] resultDataList = resultsBean.getTermDataList();
        assertNull(resultDataList);

}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:21,代码来源:ContentBasedSearchServiceTest.java

示例10: setFacets

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
/**
 * Helper method that takes Solr response and extracts the facets results.
 * The facets are converted to a list of Facets understood by the search API.
 * The result of this method can be a empty list.
 *
 * @param queryResponse that contains the facets information returned by Solr
 * @return the List of facets retrieved from the Solr response
 */
private void setFacets(SearchResponse<NameUsageSearchResult, NameUsageSearchParameter> response, final QueryResponse queryResponse) {
  List<Facet<NameUsageSearchParameter>> facets = Lists.newArrayList();
  if (queryResponse.getFacetFields() != null) {
    List<FacetField> facetFields =  queryResponse.getFacetFields();
    for (final FacetField facetField : facetFields) {
      NameUsageSearchParameter facetParam = SolrMapping.FACET_MAPPING.inverse().get(facetField.getName());
      Facet<NameUsageSearchParameter> facet = new Facet<NameUsageSearchParameter>(facetParam);

      List<Facet.Count> counts = Lists.newArrayList();
      if (facetField.getValues() != null) {
        for (final FacetField.Count count : facetField.getValues()) {
          String value = SolrMapping.interpretSolrValue(facetParam, count.getName());
          counts.add(new Facet.Count(value, count.getCount()));
        }
      }
      facet.setCounts(counts);
      facets.add(facet);
    }
  }
  response.setFacets(facets);
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:30,代码来源:ResponseBuilder.java

示例11: createValuesView

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
private DataView<FacetField.Count> createValuesView(String id) {
    final IModel<String> fieldNameModel = new PropertyModel<>(getModel(), "name");
    return new DataView<FacetField.Count>(id, valuesProvider, ITEMS_PER_PAGE) {

        @Override
        protected void populateItem(final Item<FacetField.Count> item) {
            item.setDefaultModel(new CompoundPropertyModel<>(item.getModel()));

            // link to select an individual facet value
            final Link selectLink = new AjaxFallbackLink("facetSelect") {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    // call callback
                    onValuesSelected(
                            // for now only single values can be selected
                    		Collections.singleton(item.getModelObject().getName()),
                            target);
                }
            };
            item.add(selectLink);

            // 'name' field from Count (name of value)
            selectLink.add(new FieldValueLabel("name", fieldNameModel));

            // 'count' field from Count (document count for value)
            item.add(new Label("count"));
        }
    };
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:31,代码来源:AllFacetValuesPanel.java

示例12: getList

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
@Override
public List<FacetField.Count> getList() {
    final Iterable<Count> filteredValues = getFilteredValues();
    // sort what remains
    final ImmutableList sorted = getOrdering().immutableSortedCopy(filteredValues);
    if (sorted.size() > maxNumberOfItems) {
        return Lists.newArrayList(sorted.subList(0, maxNumberOfItems));
    } else {
        // return iterator starting at specified offset
        return sorted;
    }
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:13,代码来源:FacetFieldValuesProvider.java

示例13: filter

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
private Iterable<FacetField.Count> filter(List<FacetField.Count> list) {
    if (hasFilter()) {
        final IConverter<String> converter = fieldValueConverterProvider.getConverter(model.getObject().getName());
        return Iterables.filter(list, new Predicate<FacetField.Count>() {
            @Override
            public boolean apply(Count input) {
                return getFilterModel().getObject().matches(input, converter);
            }
        });
    } else {
        return list;
    }
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:14,代码来源:FacetFieldValuesProvider.java

示例14: getFilteredValues

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
private Iterable<Count> getFilteredValues() {
    if (filtered == null) {
        // get all the values
        final List<FacetField.Count> values = model.getObject().getValues();
        filtered = filter(values);
    }
    return filtered;
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:9,代码来源:FacetFieldValuesProvider.java

示例15: testIteratorCountOrder

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
/**
 * Test of iterator method, of class FacetFieldValuesProvider.
 */
@Test
public void testIteratorCountOrder() {
    final FacetFieldValuesProvider instance = new FacetFieldValuesProvider(Model.of(facetField), 10, LOW_PRIORITY_VALUES, new SortParam<FieldValuesOrder>(FieldValuesOrder.COUNT, true), valueConverterProvider);

    long first = 0;
    long count = 100;
    final Iterator<? extends FacetField.Count> result = instance.iterator(first, count);

    //sorted by count
    assertTrue(result.hasNext());
    FacetField.Count valueCount = result.next();
    assertEquals(101, valueCount.getCount());

    assertTrue(result.hasNext());
    valueCount = result.next();
    assertEquals(102, valueCount.getCount());

    assertTrue(result.hasNext());
    valueCount = result.next();
    assertEquals(103, valueCount.getCount());

    assertTrue(result.hasNext());
    valueCount = result.next();
    assertEquals(104, valueCount.getCount());

    // low priority last
    assertTrue(result.hasNext());
    valueCount = result.next();
    assertEquals(500, valueCount.getCount());

    assertFalse(result.hasNext());
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:36,代码来源:FacetFieldValuesProviderTest.java


注:本文中的org.apache.solr.client.solrj.response.FacetField.Count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。