本文整理匯總了Java中org.apache.solr.common.SolrInputDocument.get方法的典型用法代碼示例。如果您正苦於以下問題:Java SolrInputDocument.get方法的具體用法?Java SolrInputDocument.get怎麽用?Java SolrInputDocument.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.solr.common.SolrInputDocument
的用法示例。
在下文中一共展示了SolrInputDocument.get方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addField
import org.apache.solr.common.SolrInputDocument; //導入方法依賴的package包/類
private void addField(SolrInputDocument doc, String name, String value) {
// find if such field already exists
if (doc.get(name) == null) {
doc.addField(name, value);
} else {
// for some fields we can't allow multiple values, like ID field phrase, so we have to perform this check
SolrInputField f = doc.get(name);
boolean valueExists = false;
for (Object existingValue : f.getValues()) {
if (existingValue == null && value == null) {
valueExists = true;
break;
}
if (existingValue != null && value != null && existingValue.equals(value)) {
valueExists = true;
break;
}
}
if (!valueExists) {
f.addValue(value);
}
}
}
示例2: addField
import org.apache.solr.common.SolrInputDocument; //導入方法依賴的package包/類
private static void addField(SolrInputDocument doc, String name, String value) {
// find if such field already exists
if (doc.get(name) == null) {
// System.out.println("Adding field " + name + " without previous values");
doc.addField(name, value);
} else {
// for some fields we can't allow multiple values, like ID field phrase, so we have to perform this check
SolrInputField f = doc.get(name);
for (Object val : f.getValues()) {
// fix for boolean values
if ((value.equalsIgnoreCase("t") && val.toString().equalsIgnoreCase("true")) ||
(value.equalsIgnoreCase("f") && val.toString().equalsIgnoreCase("false"))) {
return;
}
if (value.equals(val.toString())) {
// if we find such value in the doc, we will not add it again
// System.out.println("Field " + name + " already contains value " + value);
return;
}
}
// System.out.println("Adding field " + name + " without new value " + value);
f.addValue(value);
}
}