本文整理汇总了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!");
}
}