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