本文整理汇总了Java中org.apache.solr.client.solrj.response.FacetField.getName方法的典型用法代码示例。如果您正苦于以下问题:Java FacetField.getName方法的具体用法?Java FacetField.getName怎么用?Java FacetField.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.client.solrj.response.FacetField
的用法示例。
在下文中一共展示了FacetField.getName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
}
示例2: removeSelectedValsFromResponse
import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
private List<FacetField> removeSelectedValsFromResponse(QueryFacetsSelection query, List<FacetField> response){
List<FacetField> cleanedFacets = new ArrayList<>();
//for each facet from response
for(FacetField facet: response){
FacetSelection facetSelection = query.getSelectionValues(facet.getName());
if(facetSelection == null){
cleanedFacets.add(facet);
continue;
}else{
Collection<String> selectedValues = facetSelection.getValues();
FacetField _newFacetField = new FacetField(facet.getName(), facet.getName(), facet.getEnd());
//for each value from facet check if is selected and if not add it to the new response
for(Count val: facet.getValues()){
if(!selectedValues.contains(val.getName()))
_newFacetField.add(val.getName(), val.getCount());
}
cleanedFacets.add(_newFacetField);
}
}
return cleanedFacets;
}
示例3: 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;
}
}
示例4: extractAvailableFilters
import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
private Map<String, FacetList> extractAvailableFilters(QueryResponse response) {
Map<String, FacetList> facets = new HashMap<String, FacetList>();
if (response.getFacetFields() != null) {
for (FacetField ff : response.getFacetFields()) {
String field = ff.getName();
List<Facet> facetList = new ArrayList<Facet>(ff.getValueCount());
for (Count c : ff.getValues()) {
if (c.getCount() > 0) {
Facet f = new Facet(ff.getName(), c.getName(), c.getCount());
facetList.add(f);
}
}
facets.put(ff.getName(), new FacetList(field, getFacetLabel(field), facetList));
}
}
return facets;
}
示例5: convertFacetQueryResponseToFacetPageMap
import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
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 HashMap<Field, Page<FacetFieldEntry>>();
if (CollectionUtils.isNotEmpty(response.getFacetFields())) {
int initalPageSize = query.getFacetOptions().getPageable().getPageSize();
for (FacetField facetField : response.getFacetFields()) {
if (facetField != null && StringUtils.hasText(facetField.getName())) {
Field field = new SimpleField(facetField.getName());
if (CollectionUtils.isNotEmpty(facetField.getValues())) {
List<FacetFieldEntry> pageEntries = new ArrayList<FacetFieldEntry>(initalPageSize);
for (Count count : facetField.getValues()) {
if (count != null) {
pageEntries.add(new SimpleFacetFieldEntry(field, count.getName(), count.getCount()));
}
}
facetResult.put(field, new SolrResultPage<FacetFieldEntry>(pageEntries, query.getFacetOptions()
.getPageable(), facetField.getValueCount(), null));
} else {
facetResult.put(field, new SolrResultPage<FacetFieldEntry>(Collections.<FacetFieldEntry> emptyList(), query
.getFacetOptions().getPageable(), 0, null));
}
}
}
}
return facetResult;
}