本文整理匯總了Java中org.apache.solr.client.solrj.SolrQuery.setTermsPrefix方法的典型用法代碼示例。如果您正苦於以下問題:Java SolrQuery.setTermsPrefix方法的具體用法?Java SolrQuery.setTermsPrefix怎麽用?Java SolrQuery.setTermsPrefix使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.solr.client.solrj.SolrQuery
的用法示例。
在下文中一共展示了SolrQuery.setTermsPrefix方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: complete
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
public List<String> complete(String query) {
List<String> results = new ArrayList<>();
SolrServer solrServer = new HttpSolrServer("http://" + systemConfig.getSolrHostColonPort() + "/solr");
SolrQuery solrQuery = new SolrQuery();
solrQuery.setParam("qt", "/terms");
solrQuery.setTermsLower(query);
solrQuery.setTermsPrefix(query);
// dataverses and files use SearchFields.NAME
// solrQuery.addTermsField(SearchFields.NAME);
solrQuery.addTermsField("text");
// long datasetFieldDescription = 33L;
// String solrFieldDatasetFieldDescription = datasetFieldService.find(datasetFieldDescription).getSolrField();
// solrQuery.addTermsField(solrFieldDatasetFieldDescription);
List<Term> items = null;
try {
logger.info("Solr query: " + solrQuery);
QueryResponse qr = solrServer.query(solrQuery);
TermsResponse resp = qr.getTermsResponse();
// items = resp.getTerms(SearchFields.NAME);
items = resp.getTerms("text");
// items = resp.getTerms(solrFieldDatasetFieldDescription);
} catch (SolrServerException e) {
items = null;
}
if (items != null) {
for (Term term : items) {
logger.info("term: " + term.getTerm());
results.add(term.getTerm());
}
} else {
logger.info("no terms found");
}
return results;
}
開發者ID:pengchengluo,項目名稱:Peking-University-Open-Research-Data-Platform,代碼行數:39,代碼來源:AutoCompleteBean.java
示例2: testTermsResponse
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
@Test
public void testTermsResponse() throws Exception {
SolrInputDocument doc = new SolrInputDocument();
doc.setField("id", 1);
doc.setField("terms_s", "samsung");
getSolrServer().add(doc);
getSolrServer().commit(true, true);
SolrQuery query = new SolrQuery();
query.setRequestHandler("/terms");
query.setTerms(true);
query.setTermsLimit(5);
query.setTermsLower("s");
query.setTermsPrefix("s");
query.addTermsField("terms_s");
query.setTermsMinCount(1);
QueryRequest request = new QueryRequest(query);
List<Term> terms = request.process(getSolrServer()).getTermsResponse().getTerms("terms_s");
Assert.assertNotNull(terms);
Assert.assertEquals(terms.size(), 1);
Term term = terms.get(0);
Assert.assertEquals(term.getTerm(), "samsung");
Assert.assertEquals(term.getFrequency(), 1);
}
示例3: 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());
}
}