本文整理匯總了Java中org.apache.solr.client.solrj.SolrQuery.setFacetLimit方法的典型用法代碼示例。如果您正苦於以下問題:Java SolrQuery.setFacetLimit方法的具體用法?Java SolrQuery.setFacetLimit怎麽用?Java SolrQuery.setFacetLimit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.solr.client.solrj.SolrQuery
的用法示例。
在下文中一共展示了SolrQuery.setFacetLimit方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: obtainCollectionCounts
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
private List<VloReport.CollectionCount> obtainCollectionCounts(SolrServer solrServer) throws SolrServerException {
final SolrQuery query = new SolrQuery();
query.setRows(0);
query.setFacet(true);
query.addFacetField(FacetConstants.FIELD_COLLECTION);
query.setFacetLimit(Integer.MAX_VALUE);
final QueryResponse result = solrServer.query(query);
final FacetField collectionField = result.getFacetField(FacetConstants.FIELD_COLLECTION);
logger.debug("Collection field: {}", collectionField.getValues());
final List<VloReport.CollectionCount> counts
= collectionField.getValues().stream().map((count) -> {
VloReport.CollectionCount collectionCount = new VloReport.CollectionCount();
collectionCount.setCollection(count.getName());
collectionCount.setCount(count.getCount());
return collectionCount;
}).collect(Collectors.toList());
return counts;
}
示例2: obtainFacetStats
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
private List<VloReport.Facet> obtainFacetStats(VloConfig config, SolrServer solrServer) throws SolrServerException {
final SolrQuery query = new SolrQuery();
query.setRows(0);
query.setFacet(true);
FacetConstants.AVAILABLE_FACETS.forEach((field) -> {
query.addFacetField(field);
});
query.setFacetLimit(-1);
final QueryResponse result = solrServer.query(query);
final List<FacetField> facetFields = result.getFacetFields();
final List<VloReport.Facet> facets
= facetFields.stream().map((field) -> {
final VloReport.Facet facet = new VloReport.Facet();
facet.setName(field.getName());
facet.setValueCount(field.getValueCount());
return facet;
}).collect(Collectors.toList());
return facets;
}
示例3: enableFaceting
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
private boolean enableFaceting(SolrQuery solrQuery, FacetQuery query) {
FacetOptions facetOptions = query.getFacetOptions();
if (facetOptions == null || !facetOptions.hasFacets()) {
return false;
}
solrQuery.setFacet(true);
solrQuery.setFacetMinCount(facetOptions.getFacetMinCount());
solrQuery.setFacetLimit(facetOptions.getPageable().getPageSize());
if (facetOptions.getPageable().getPageNumber() > 0) {
int offset = Math.max(0, facetOptions.getPageable().getOffset());
solrQuery.set(FacetParams.FACET_OFFSET, offset);
}
if (FacetOptions.FacetSort.INDEX.equals(facetOptions.getFacetSort())) {
solrQuery.setFacetSort(FacetParams.FACET_SORT_INDEX);
}
return true;
}
示例4: createFacetQuery
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
@Override
public SolrQuery createFacetQuery(QueryFacetsSelection queryFacetsSelections, List<String> facets, int facetValueLimit) {
final SolrQuery query = getBaseQuery(facets);
addQueryFacetParameters(query, queryFacetsSelections);
query.setFacetLimit(facetValueLimit);
return query;
}
示例5: addFacetParameters
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
private void addFacetParameters(SolrQuery query) {
query.setFacet(true);
query.addFacetField(facetFieldExtractor.getRandomFacetField());
query.setFacetMinCount(facetMinCount);
query.setFacetLimit(facetLimit);
if(facetMethod != null && !"".equals(facetMethod)) {
query.add("facet.method", facetMethod);
}
}
示例6: getIndexAndJdsPatientCounts
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
@Override
public Map<String, Integer> getIndexAndJdsPatientCounts() throws SolrServerException {
SolrQuery qry = new SolrQuery("*:*");
qry.setRows(0);
qry.addFacetField("pid");
qry.setFacetLimit(-1); // Default is 100;
try {
QueryResponse resp = solrServer.query(qry);
FacetField ff = resp.getFacetField("pid");
int solrPidCount = ff.getValues().size();
int jdsPidCount = patientDao.count();
Map<String, Integer> rslt = new HashMap<>();
rslt.put("solrPidCount",solrPidCount);
rslt.put("jdsPidCount",jdsPidCount);
return rslt;
} catch(SolrServerException e) {
// Short-term handling when embedded SolrServer is not initializing fast enough;
// Long-term plan is to have a dedicated SolrServer.
if(e.getMessage().toLowerCase().contains("server refused connection")) {
if(solrServerInitRetry++<5) {
try {
log.warn("SOLR server refused connection when trying to get PID count; Retry #"+solrServerInitRetry);
Thread.sleep(2000);
} catch (InterruptedException e1) {
e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
return getIndexAndJdsPatientCounts();
}
}
}
return null;
}
示例7: 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;
}
示例8: categoriesAvailable
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
public static Map<String, Object> categoriesAvailable(String catalogId, String categoryId, String productId,
String facetPrefix, boolean displayproducts, int viewIndex, int viewSize, List<String> queryFilters, Boolean excludeVariants, String core) {
// create the data model
Map<String, Object> result = new HashMap<>();
HttpSolrClient client = null;
QueryResponse returnMap = new QueryResponse();
try {
// do the basic query
client = SolrUtil.getHttpSolrClient(core);
// create Query Object
String query = "inStock[1 TO *]";
if (categoryId != null)
query += " +cat:"+ SolrExprUtil.escapeTermFull(categoryId);
else if (productId != null)
query += " +productId:" + SolrExprUtil.escapeTermFull(productId);
SolrQuery solrQuery = new SolrQuery();
solrQuery.setQuery(query);
if (catalogId != null)
solrQuery.addFilterQuery("+catalog:" + SolrExprUtil.escapeTermFull(catalogId));
if (excludeVariants == null) excludeVariants = SolrProductSearch.excludeVariantsDefault;
if (excludeVariants)
SolrProductUtil.addExcludeVariantsFilter(solrQuery);
if (displayproducts) {
if (viewSize > -1) {
solrQuery.setRows(viewSize);
} else
solrQuery.setRows(50000);
if (viewIndex > -1) {
// 2016-04-01: This must be calculated
//solrQuery.setStart(viewIndex);
if (viewSize > 0) {
solrQuery.setStart(viewSize * viewIndex);
}
}
} else {
solrQuery.setFields("cat");
solrQuery.setRows(0);
}
if(UtilValidate.isNotEmpty(facetPrefix)){
solrQuery.setFacetPrefix(facetPrefix);
}
solrQuery.setFacetMinCount(0);
solrQuery.setFacet(true);
solrQuery.addFacetField("cat");
solrQuery.setFacetLimit(-1);
if (Debug.verboseOn()) Debug.logVerbose("solr: solrQuery: " + solrQuery, module);
returnMap = client.query(solrQuery,METHOD.POST);
result.put("rows", returnMap);
result.put("numFound", returnMap.getResults().getNumFound());
} catch (Exception e) {
Debug.logError(e.getMessage(), module);
}
return result;
}
示例9: createCountFacetsQuery
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
@Override
public synchronized SolrQuery createCountFacetsQuery(List<String> facets) {
final SolrQuery query = getBaseQuery(facets);
query.setFacetLimit(0);
return query;
}
示例10: suggestOLD
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
protected void suggestOLD(PatientSearch search, FrameTask task) throws FrameException {
/*
* Suggestion strategy as of 1/31/14
* - stick to the patient-specific faceting of phrases (but using the shingled filter)
* - also use the spellchecker to find misspellings (non-patient specific)
* - TODO: still need to pull the clinical text suggested keywords in? (not stored in phrase)
* - TODO: really need to investigate the eDisMax parser and it's shingle capability
*
* http://localhost:8080/solr/select?q=*:*&fq=pid:10101&rows=0&facet=true&facet.field=phrase&facet.mincount=1&facet.prefix=discharge%20sum&spellcheck=true&spellcheck.q=dischare%20sum
*/
String str = search.getQueryStr();
SolrQuery q = new SolrQuery("*:*");
// q.addFilterQuery("pid:"+search.pid);
q.setRows(0);
q.setFacetLimit(3);
q.setFacetMinCount(1);
q.addFacetField(SearchService.PHRASE);
q.setFacetPrefix(str);
q.set("spellcheck", true);
q.set(SpellingParams.SPELLCHECK_Q, str);
q.set(SpellingParams.SPELLCHECK_DICT, "spell","suggest"); // TODO: build into searcher?
q.set(SpellingParams.SPELLCHECK_COLLATE, true);
// if facets exist, use them as patient-specific suggestions
QueryResponse response = execSolrQuery(q, task);
if (response.getFacetField(SearchService.PHRASE) != null) {
List<Count> counts = response.getFacetField(SearchService.PHRASE).getValues();
for (Count count : counts) {
search.addSuggestion(new SuggestItem(count.getName(), count.getName(), "Patient Match"))
.setSort(SuggestItem.SortCat.SUGGEST, count.getCount());
}
}
// if spellcheck results exist, list them as non-patient suggestions
SpellCheckResponse spell = response.getSpellCheckResponse();
if (spell != null) {
// add suggestions
for (Suggestion s : spell.getSuggestions()) {
for (String str2 : s.getAlternatives()) {
search.addSuggestion(new SuggestItem(str2, str2, "Spelling Suggestion"))
.setSort(SuggestItem.SortCat.SPELL, 1);
}
}
}
}