當前位置: 首頁>>代碼示例>>Java>>正文


Java SolrDocument.getFieldNames方法代碼示例

本文整理匯總了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!");
  }
}
 
開發者ID:sematext,項目名稱:solr-autocomplete,代碼行數:23,代碼來源:AutocompleteUpdateRequestProcessor.java

示例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!");
  }
}
 
開發者ID:sematext,項目名稱:solr-autocomplete,代碼行數:40,代碼來源:CustomIndexLoader.java


注:本文中的org.apache.solr.common.SolrDocument.getFieldNames方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。