本文整理匯總了Java中org.apache.solr.common.SolrDocument.getFieldNames方法的典型用法代碼示例。如果您正苦於以下問題:Java SolrDocument.getFieldNames方法的具體用法?Java SolrDocument.getFieldNames怎麽用?Java SolrDocument.getFieldNames使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.solr.common.SolrDocument
的用法示例。
在下文中一共展示了SolrDocument.getFieldNames方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fetchExistingOrCreateNewSolrDoc
import org.apache.solr.common.SolrDocument; //導入方法依賴的package包/類
private SolrInputDocument fetchExistingOrCreateNewSolrDoc(String id) throws SolrServerException, IOException {
Map<String, String> p = new HashMap<String, String>();
p.put("q", PHRASE + ":\"" + ClientUtils.escapeQueryChars(id) + "\"");
SolrParams params = new MapSolrParams(p);
QueryResponse res = solrAC.query(params);
if (res.getResults().size() == 0) {
return new SolrInputDocument();
} else if (res.getResults().size() == 1) {
SolrDocument doc = res.getResults().get(0);
SolrInputDocument tmp = new SolrInputDocument();
for (String fieldName : doc.getFieldNames()) {
tmp.addField(fieldName, doc.getFieldValue(fieldName));
}
return tmp;
} else {
throw new IllegalStateException("Query with params : " + p + " returned more than 1 hit!");
}
}
示例2: fetchExistingOrCreateNewSolrDoc
import org.apache.solr.common.SolrDocument; //導入方法依賴的package包/類
private static SolrInputDocument fetchExistingOrCreateNewSolrDoc(SolrClient solr, String id) throws SolrServerException, IOException {
countCreatedAcDocs++;
if (!mergingWithOldDocsEnabled) {
// if disabled, always use fresh document and override older docs with the same phrase
return new SolrInputDocument();
}
if (id.equals("")) {
return new SolrInputDocument();
}
Map<String, String> p = new HashMap<String, String>();
p.put("q", PHRASE + ":\"" + ClientUtils.escapeQueryChars(id) + "\"");
long t1 = System.currentTimeMillis();
SolrParams params = new MapSolrParams(p);
QueryResponse res = solr.query(params);
totalSearchTime += (System.currentTimeMillis() - t1);
if (res.getResults().size() == 0) {
// System.out.println("Document for phrase " + id + " NOT FOUND");
countDistinctNewDocs++;
return new SolrInputDocument();
} else if (res.getResults().size() == 1) {
SolrDocument doc = res.getResults().get(0);
SolrInputDocument tmp = new SolrInputDocument();
// System.out.println("Document for phrase " + id + " found");
for (String fieldName : doc.getFieldNames()) {
tmp.addField(fieldName, doc.getFieldValue(fieldName));
}
return tmp;
} else {
throw new IllegalStateException("Query with params : " + p + " returned more than 1 hit!");
}
}