本文整理匯總了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);
}
}
示例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;
}
示例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;
}
示例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));
}
}
示例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());
}