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


Java SolrDocument.get方法代碼示例

本文整理匯總了Java中org.apache.solr.common.SolrDocument.get方法的典型用法代碼示例。如果您正苦於以下問題:Java SolrDocument.get方法的具體用法?Java SolrDocument.get怎麽用?Java SolrDocument.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.solr.common.SolrDocument的用法示例。


在下文中一共展示了SolrDocument.get方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkIndex

import org.apache.solr.common.SolrDocument; //導入方法依賴的package包/類
/**
 * Integrity check.
 */
public void checkIndex()
{
   try
   {
      SolrQuery query = new SolrQuery("*:*");
      query.setFilterQueries("*");
      query.setStart(0);
      Iterator<SolrDocument> it = solrDao.scroll(query);
      while (it.hasNext())
      {
         SolrDocument doc = it.next();
         Long pid = (Long) doc.get("id");
         Product product = productService.systemGetProduct(pid);
         if (product == null)
         {
            Long id = (Long) doc.getFieldValue("id");
            LOGGER.warn("Removing unknown product " + id + " from solr index");
            try
            {
               solrDao.remove(id);
               // decrease the offset, because a product has been removed
               query.setStart(query.getStart() - 1);
            }
            catch (IOException e)
            {
               LOGGER.error("Cannot remove Solr entry " + id, e);
            }
         }
      }
   }
   catch (IOException|SolrServerException ex)
   {
      LOGGER.error("Cannot check the index", ex);
   }
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:39,代碼來源:SearchService.java

示例2: nextInner

import org.apache.solr.common.SolrDocument; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
protected boolean nextInner() throws IOException {
  if (list == null || pos >= list.size()) {
    return false;
  }
  SolrDocument doc = list.get(pos++);
  key = (K) doc.get(store.getMapping().getPrimaryKey());
  persistent = store.newInstance(doc, fields);
  return true;
}
 
開發者ID:jianglibo,項目名稱:gora-boot,代碼行數:12,代碼來源:SolrResult.java

示例3: newInstance

import org.apache.solr.common.SolrDocument; //導入方法依賴的package包/類
public T newInstance(SolrDocument doc, String[] fields) throws IOException {
  T persistent = newPersistent();
  if (fields == null) {
    fields = fieldMap.keySet().toArray(new String[fieldMap.size()]);
  }
  String pk = mapping.getPrimaryKey();
  for (String f : fields) {
    Field field = fieldMap.get(f);
    Schema fieldSchema = field.schema();
    String sf = null;
    if (pk.equals(f)) {
      sf = f;
    } else {
      sf = mapping.getSolrField(f);
    }
    Object sv = doc.get(sf);
    if (sv == null) {
      continue;
    }

    Object v = deserializeFieldValue(field, fieldSchema, sv, persistent);
    persistent.put(field.pos(), v);
    persistent.setDirty(field.pos());

  }
  persistent.clearDirty();
  return persistent;
}
 
開發者ID:jianglibo,項目名稱:gora-boot,代碼行數:29,代碼來源:SolrStore.java

示例4: showDebugOutput

import org.apache.solr.common.SolrDocument; //導入方法依賴的package包/類
/**
 * Anzeige von Debug-Informationen
 * @param response
 * @param results
 */
private void showDebugOutput(QueryResponse response, SolrDocumentList results) {
    // interne Interpretation der eingegebenen Suchanfrage
    System.out.println("rawquerystring: " + response.getDebugMap().get("rawquerystring"));
    System.out.println("parsedquery_toString: " + response.getDebugMap().get("parsedquery_toString"));

    // Erläuterung zur Scoreberechnung der einzelnen Dokumente
    for (SolrDocument doc : results) {
        String id = (String) doc.get("id");
        System.out.println("*** Scorewert für Dokument " + id + " ***");
        System.out.println(response.getExplainMap().get(id));
    }
}
 
開發者ID:saschaszott,項目名稱:suma-tech,代碼行數:18,代碼來源:SolrSearcherWithAuth.java

示例5: querySolrIndex

import org.apache.solr.common.SolrDocument; //導入方法依賴的package包/類
/**
 * Returns all patterns from the index and their features for reverb and the
 * wordnet distance and the overall boa-boaScore.
 * 
 * @param propertyUri the property URI
 * @return a list of patterns
 */
private static Set<Pattern> querySolrIndex(String propertyUri) {

    Map<Integer, Pattern> patterns = new HashMap<>();

    try {

        SolrQuery query = new SolrQuery("uri:\"" + propertyUri + "\"");
        query.addField("REVERB");
        query.addField("WORDNET_DISTANCE");
        query.addField("SUPPORT_NUMBER_OF_PAIRS_LEARNED_FROM");
        query.addField("pos");
        query.addField("boa-score");
        query.addField("nlr-var");
        query.addField("nlr-no-var");
        query.setRows(10000);
        QueryResponse response = server.query(query);
        SolrDocumentList docList = response.getResults();

        // return the first list of types
        for (SolrDocument d : docList) {

            Pattern pattern = new Pattern();
            pattern.naturalLanguageRepresentation = (String) d.get("nlr-var");
            pattern.naturalLanguageRepresentationWithoutVariables = (String) d.get("nlr-no-var");
            pattern.features.put("REVERB", Double.valueOf((String) d.get("REVERB")));
            pattern.features.put("WORDNET_DISTANCE", Double.valueOf((String) d.get("WORDNET_DISTANCE")));
            pattern.features.put("SUPPORT_NUMBER_OF_PAIRS_LEARNED_FROM", Double.valueOf((String) d.get("SUPPORT_NUMBER_OF_PAIRS_LEARNED_FROM")));
            pattern.posTags = (String) d.get("pos");
            pattern.boaScore = Double.valueOf((String) d.get("boa-score"));
            pattern.naturalLanguageScore = calculateNaturalLanguageScore(pattern);

            // since ?D? and ?R? are removed so two patterns might look the
            // same
            if (isSuitable(pattern)) {

                // merge the pattern
                if (patterns.containsKey(pattern.hashCode())) {

                    Pattern p = patterns.get(pattern.hashCode());
                    p.features.put("REVERB", pattern.features.get("REVERB") + p.features.get("REVERB"));
                    p.features.put("WORDNET_DISTANCE", pattern.features.get("WORDNET_DISTANCE") + p.features.get("WORDNET_DISTANCE"));
                    p.features.put("SUPPORT_NUMBER_OF_PAIRS_LEARNED_FROM", pattern.features.get("SUPPORT_NUMBER_OF_PAIRS_LEARNED_FROM") + p.features.get("SUPPORT_NUMBER_OF_PAIRS_LEARNED_FROM"));
                    p.boaScore += pattern.boaScore;
                    p.naturalLanguageScore += pattern.naturalLanguageScore;
                    patterns.put(pattern.hashCode(), p);
                }
                else {

                    patterns.put(pattern.hashCode(), pattern);
                }
            }
        }
    }
    catch (SolrServerException e) {

        System.out.println("Could not execute query: " + e);
        e.printStackTrace();
    }
    return new HashSet<>(patterns.values());
}
 
開發者ID:dice-group,項目名稱:RDF2PT,代碼行數:68,代碼來源:BoaPatternSelector.java


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