本文整理匯總了Java中org.apache.solr.client.solrj.SolrQuery.setTermsRegex方法的典型用法代碼示例。如果您正苦於以下問題:Java SolrQuery.setTermsRegex方法的具體用法?Java SolrQuery.setTermsRegex怎麽用?Java SolrQuery.setTermsRegex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.solr.client.solrj.SolrQuery
的用法示例。
在下文中一共展示了SolrQuery.setTermsRegex方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: printStats
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
/**
* Gibt für das übergebene Indexfeld die drei Indexterme aus, die die größte Document Frequency haben.
* Es werden hierbei aber nur Indexterme betrachtet, die mit einem Buchstaben beginnen.
*
* @param indexFieldName Feldname des Indexfelds
*/
private void printStats(String indexFieldName) {
System.out.println("- - - - - Field Statistics for Index Field " + indexFieldName + " - - - - -");
SolrQuery query = new SolrQuery();
query.setRequestHandler("/terms");
query.setTermsLimit(3);
query.setTermsSortString(TermsParams.TERMS_SORT_COUNT);
query.addTermsField(indexFieldName);
query.setTermsRegex("^[a-zA-Z].*");
QueryRequest request = new QueryRequest(query);
request.setBasicAuthCredentials(Configuration.USERNAME, Configuration.PASSWORD);
try {
List<TermsResponse.Term> terms = request.process(solrClient).getTermsResponse().getTerms(indexFieldName);
if (terms != null) {
for (TermsResponse.Term term : terms) {
System.out.println(term.getTerm() + " (df = " + term.getFrequency() + ")");
}
}
} catch (SolrServerException|IOException e) {
System.err.println("Fehler bei der Term-Lookup im Dictionary");
}
}
示例2: appendTermsOptionsToSolrQuery
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
protected void appendTermsOptionsToSolrQuery(TermsOptions options, SolrQuery solrQuery) {
solrQuery.setTerms(true);
if (options.getLimit() >= 0) {
solrQuery.setTermsLimit(options.getLimit());
}
if (options.getMaxCount() >= -1) {
solrQuery.setTermsMaxCount(options.getMaxCount());
}
if (options.getMinCount() >= 0) {
solrQuery.setTermsMinCount(options.getMinCount());
}
if (StringUtils.hasText(options.getPrefix())) {
solrQuery.setTermsPrefix(options.getPrefix());
}
if (StringUtils.hasText(options.getRegex())) {
solrQuery.setTermsRegex(options.getRegex());
}
if (options.getRegexFlag() != null) {
solrQuery.setTermsRegexFlag(options.getRegexFlag().toString().toLowerCase());
}
if (options.getSort() != null) {
solrQuery.setTermsSortString(options.getSort().toString().toLowerCase());
}
if (options.getUpperBoundTerm() != null) {
solrQuery.setTermsUpper(options.getUpperBoundTerm().getTerm());
solrQuery.setTermsUpperInclusive(options.getUpperBoundTerm().isInclude());
}
if (options.getLowerBoundTerm() != null) {
solrQuery.setTermsUpper(options.getLowerBoundTerm().getTerm());
solrQuery.setTermsUpperInclusive(options.getLowerBoundTerm().isInclude());
}
if (!options.isRaw()) {
solrQuery.setTermsRaw(options.isRaw());
}
}