本文整理匯總了Java中org.apache.solr.client.solrj.SolrQuery.setFacetMissing方法的典型用法代碼示例。如果您正苦於以下問題:Java SolrQuery.setFacetMissing方法的具體用法?Java SolrQuery.setFacetMissing怎麽用?Java SolrQuery.setFacetMissing使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.solr.client.solrj.SolrQuery
的用法示例。
在下文中一共展示了SolrQuery.setFacetMissing方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRemoteFacets
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
/**
* Get a list of remote facets keyed by field name.
*
* @param fields
* Fields.
* @return List of facets keyed by field name.
* @throws SophieException
* If facets could not be fetched.
*/
private Map<String, FacetField> getRemoteFacets(List<FieldInfo> fields) throws SophieException {
// Prepare query.
SolrQuery query = getBaseQuery(0, 0);
query.setFacet(true);
query.setFacetSort("index");
query.setFacetLimit(FACET_LIMIT);
query.setFacetMissing(true);
// For each field, determine whether Solr can generate a facet (fq works
// only on indexed fields). If yes, then list that field in the query.
for (FieldInfo field : fields) {
if (SolrUtils.getFlags(field).contains(FieldFlag.INDEXED)) {
query.addFacetField(field.getName());
}
}
// Send query.
Map<String, FacetField> facets = new HashMap<String, FacetField>();
try {
for (FacetField facet : Sophie.client.query(query).getFacetFields()) {
facets.put(facet.getName(), facet);
}
} catch (SolrServerException | IOException | SolrException e) {
throw new SophieException("Unable to fetch remote facets", e);
}
// Return facets keyed by field name.
return facets;
}