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


Java FacetField.getValues方法代码示例

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


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

示例1: getSets

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
/**
 * Creates a list with all available values for the given field (minus any blacklisted values).
 * 
 * @return
 * @throws SolrServerException
 * @should return all values
 */
public List<String> getSets(String field) throws SolrServerException {
    List<String> ret = new ArrayList<>();

    SolrQuery query = new SolrQuery();
    query.setQuery(field + ":* " + DataManager.getInstance().getConfiguration().getCollectionBlacklistFilterSuffix());
    query.setStart(0);
    query.setRows(0);
    query.addFacetField(field);
    logger.trace("Set query: {}", query.getQuery());
    QueryResponse resp = server.query(query);

    FacetField facetField = resp.getFacetField(field);
    if (facetField != null) {
        for (Count count : facetField.getValues()) {
            if (count.getCount() == 0) {
                continue;
            }
            ret.add(count.getName());
        }
    }

    Collections.sort(ret);
    logger.trace("{} terms found for {}", ret.size(), field);
    return ret;
}
 
开发者ID:intranda,项目名称:goobi-viewer-connector,代码行数:33,代码来源:SolrSearchIndex.java

示例2: 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

示例3: 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;
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:27,代码来源:SolrFacetFieldsService.java

示例4: 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

示例5: testRestrictedSearch

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
/**
 *
 */
@Test
public final void testRestrictedSearch() throws Exception {
	Map<String, String> selectedFacets = new HashMap<String, String>();

	selectedFacets.put("taxon.distribution_TDWG_0_ss", "AUSTRALASIA");

	Page<SearchableObject> results = getSearchableObjectDao().search("taxon.scientific_name_t:Aus", null, null, null,
			new String[] {"taxon.distribution_TDWG_0_ss" , "taxon.distribution_TDWG_1_ss"}, null, selectedFacets, null, null);
	assertEquals("There should be 2 taxa matching Aus found in AUSTRALASIA", new Integer(2), (Integer)results.getSize());
	for(String facetName : results.getFacetNames()) {
		logger.debug(facetName);
		FacetField facet = results.getFacetField(facetName);
		for(Count count : facet.getValues()) {
			logger.debug("\t" + count.getName() + " " + count.getCount());
		}
	}
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:21,代码来源:SearchTest.java

示例6: convertFacet

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
/**
 * Returns a list of facetinfo with counts.
 * @param field
 * @param title
 * @param type
 */
protected FacetCount convertFacet(FacetField field, String title, FacetType type) {
	if (field != null) {
		FacetCount facetCount = new FacetCount()//
				.setName(field.getName())//
				.setTitle(title)//
				.setType(type);
		List<Count> counts = field.getValues();
		if (counts != null) {
			for (Count count : counts) {
				FacetCount.Option option = new FacetCount.Option()//
						.setName(count.getName())//
						.setCount(count.getCount());
				facetCount.addOption(option);
			}
		}
		return facetCount;
	}
	return null;
}
 
开发者ID:HuygensING,项目名称:elaborate4-backend,代码行数:26,代码来源:AbstractSolrServer.java

示例7: extractFacetGroups

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
/** Extract facet values from solrResponse into something sendable
 * 
 * @param facetFields
 * @return
 */
private List<FacetGroup> extractFacetGroups(List<FacetField> facetFields) {
	List<FacetGroup> facets = new ArrayList<FacetGroup>();
	for (FacetField facetField : facetFields) {
		FacetGroup group = new FacetGroup();
		group.setName(facetField.getName());
		group.setCount(facetField.getValueCount());
		for (Count element : facetField.getValues()) {
			Facet f = new Facet();
			f.setName(element.getName());
			f.setCount(element.getCount());
			if (group.getFacets() == null) {
				List<Facet> facet = new ArrayList<Facet>();
				facet.add(f);
				group.setFacets(facet);
			} else {
				group.getFacets().add(f);
			}
		}
		facets.add(group);
	}
	return facets;
}
 
开发者ID:learning-layers,项目名称:SocRec,代码行数:28,代码来源:ItemService.java

示例8: 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

示例9: 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

示例10: 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;
}
 
开发者ID:flaxsearch,项目名称:hackday,代码行数:22,代码来源:SolrSearchEngine.java

示例11: setFacets

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
private void setFacets(List<FacetField> facetFields) {
  if(facetFields == null) {
    return;
  }
  DefaultListModel model = new DefaultListModel();
  int i = 0;
  for(FacetField facet:facetFields) {
    for(Count count:facet.getValues()) {
      model.add(i++, facet.getName() + ":" + count.getName() + "(" + count.getCount() + ")");
    }
  }
  jListFacets.setModel(model);
}
 
开发者ID:lafourchette,项目名称:solrmeter,代码行数:14,代码来源:QueryPanel.java

示例12: testSOLRPatient

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
private void testSOLRPatient(SolrServer solr, Map<String, Object> src, FrameTask task) throws FrameExecException {
		String pid = (String) src.get("pid");
		SolrQuery q = new SolrQuery("*:*");
		q.addFilterQuery("pid:"+pid);
		q.addFacetField("domain");
		q.setFacetMinCount(0);
		q.setRows(0);
//		System.out.println("\n\nSRC:" + src);
		
		try {
			QueryResponse resp = solr.query(q);
			FacetField facet = resp.getFacetField("domain");
			for (FacetField.Count count : facet.getValues()) {
				// compensate for JDS/SOLR domain name miss-matches
				String name = count.getName();
				if (!src.containsKey(name) && domainMap.containsKey(name)) {
					name = domainMap.get(name);
				}
				if (name == null) continue; // skip some items for now.
				
				// get the counts for each system
				int o1 = (src.get(name) == null) ? -1 : (Integer) src.get(name);
				long o2 = count.getCount();
				if (o1 != o2) {
					// add an error message action if they do not match
					String msg = String.format(MSG, pid, count.getName(), o1, o2);
					task.addAction(new FrameAction.RefDataAction(Table.buildRow("error", msg, "class", null, "resolutions", null)));
				}
				
				// TODO: if a key in one count does not exist in the other, throw an error too
			}
		} catch (Exception ex) {
			throw new FrameExecException(this, "Error running SOLR Query", ex);
		}
	}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:36,代码来源:SOLRIntegrityCheckFrame.java

示例13: getSuggestion

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
@Override
public Suggestion getSuggestion(SuggestionInput input) {
    TimeTracker timeTracker = new TimeTracker();

    SolrQuery solrQuery = new SolrQuery(ALL_DOCS_QUERY);
    solrQuery.setRows(0);

    if (!StringUtils.isBlank(input.getText())) {
        solrQuery.addFilterQuery(FIELD_TOKENIZED_SEARCH_FIELD + ":" + escapeSolr(input.getText()) + "*");
    }

    addFilterQuery(solrQuery, FIELD_PROPERTY_ID, input.getPropertyId());
    addFilterQuery(solrQuery, FIELD_SPACE, input.getSpaceId());
    addFilterQuery(solrQuery, FIELD_SYSTEM, input.getSystemId());

    solrQuery.setFacetMinCount(1);
    solrQuery.addFacetField(FIELD_GLOBAL_AGENT_ID);

    try {
        Suggestion result = new Suggestion();

        QueryResponse response = this.solrClient.query(solrQuery);

        FacetField globalAgentIdFacetField = response.getFacetField(FIELD_GLOBAL_AGENT_ID);
        for (Count eachValue : globalAgentIdFacetField.getValues()) {
            String globalAgentId = eachValue.getName();

            result.addAgentDescription(this.getAgentDescription(globalAgentId));
        }

        result.setExecutionTime(timeTracker.getElapsed(MILLISECONDS));
        return result;
    } catch (SolrException | SolrServerException | IOException e) {
        throw new DataRetrievalException("Failed to create suggestions", e);
    }
}
 
开发者ID:Indoqa,项目名称:logspace,代码行数:37,代码来源:SolrAgentService.java

示例14: getFirstFacetValue

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
private String getFirstFacetValue(QueryResponse response, String fieldName) {
    FacetField facetField = response.getFacetField(fieldName);

    if (facetField == null) {
        return null;
    }

    List<Count> values = facetField.getValues();
    if (values == null || values.isEmpty()) {
        return null;
    }

    return values.get(0).getName();
}
 
开发者ID:Indoqa,项目名称:logspace,代码行数:15,代码来源:SolrAgentService.java

示例15: loadAgentDescription

import org.apache.solr.client.solrj.response.FacetField; //导入方法依赖的package包/类
private AgentDescription loadAgentDescription(String globalAgentId) throws SolrServerException, IOException {
    SolrQuery query = new SolrQuery(ALL_DOCS_QUERY);
    query.setRows(0);

    query.setFilterQueries(FIELD_GLOBAL_AGENT_ID + ":\"" + globalAgentId + "\"");

    query.setFacetMinCount(1);
    query.addFacetField(FIELD_SPACE, FIELD_SYSTEM, FIELD_PROPERTY_ID);

    QueryResponse response = this.solrClient.query(query);

    AgentDescription result = new AgentDescription();
    result.setGlobalId(globalAgentId);
    result.setName(IdHelper.getAgentId(globalAgentId));
    result.setSpace(this.getFirstFacetValue(response, FIELD_SPACE));
    result.setSystem(this.getFirstFacetValue(response, FIELD_SYSTEM));

    List<PropertyDescription> propertyDescriptions = new ArrayList<>();
    FacetField facetField = response.getFacetField(FIELD_PROPERTY_ID);
    for (Count eachValue : facetField.getValues()) {
        propertyDescriptions.add(createPropertyDescription(eachValue.getName()));
    }
    Collections.sort(propertyDescriptions);
    result.setPropertyDescriptions(propertyDescriptions);

    return result;
}
 
开发者ID:Indoqa,项目名称:logspace,代码行数:28,代码来源:SolrAgentService.java


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