本文整理汇总了Java中org.apache.solr.common.SolrInputField.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java SolrInputField.setValue方法的具体用法?Java SolrInputField.setValue怎么用?Java SolrInputField.setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.common.SolrInputField
的用法示例。
在下文中一共展示了SolrInputField.setValue方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInstance
import org.apache.solr.common.SolrInputField; //导入方法依赖的package包/类
@Override
public UpdateRequestProcessor getInstance(SolrQueryRequest req,
SolrQueryResponse rsp,
UpdateRequestProcessor next) {
final IndexSchema schema = req.getSchema();
return new FieldMutatingUpdateProcessor(getSelector(), next) {
@Override
protected SolrInputField mutate(SolrInputField src) {
if (src.getValueCount() <= 1)
return src;//short circuit single value
SchemaField field = schema.getField(src.getName());
FieldType ft = field.getType();
IndexableField result = ft.createField(field, src, src.getBoost());
if (result == null)
return null;//remove
src.setValue(result, src.getBoost());
return src;
}
};
}
示例2: getInstance
import org.apache.solr.common.SolrInputField; //导入方法依赖的package包/类
@Override
public final UpdateRequestProcessor getInstance(SolrQueryRequest req,
SolrQueryResponse rsp,
UpdateRequestProcessor next) {
return new FieldMutatingUpdateProcessor(getSelector(), next) {
@Override
protected SolrInputField mutate(final SolrInputField src) {
if (src.getValueCount() <= 1) return src;
SolrInputField result = new SolrInputField(src.getName());
result.setValue(pickSubset(src.getValues()),
src.getBoost());
return result;
}
};
}
示例3: getInstance
import org.apache.solr.common.SolrInputField; //导入方法依赖的package包/类
@Override
public UpdateRequestProcessor getInstance(SolrQueryRequest req,
SolrQueryResponse rsp,
UpdateRequestProcessor next) {
return new FieldMutatingUpdateProcessor(getSelector(), next) {
@Override
protected SolrInputField mutate(final SolrInputField src) {
if (src.getValueCount() <= 1) return src;
SolrInputField result = new SolrInputField(src.getName());
result.setValue(StringUtils.join(src.getValues(), delimiter),
src.getBoost());
return result;
}
};
}
示例4: testSolrInputFieldEquality
import org.apache.solr.common.SolrInputField; //导入方法依赖的package包/类
public void testSolrInputFieldEquality() {
String randomString = TestUtil.randomSimpleString(random(), 10, 20);
int val = random().nextInt();
SolrInputField sif1 = new SolrInputField(randomString);
sif1.setValue(val, 1.0f);
SolrInputField sif2 = new SolrInputField(randomString);
sif2.setValue(val, 1.0f);
assertTrue(assertSolrInputFieldEquals(sif1, sif2));
sif1.setBoost(2.1f);
sif2.setBoost(2.1f);
assertTrue(assertSolrInputFieldEquals(sif1, sif2));
sif2.setBoost(2.0f);
assertFalse(assertSolrInputFieldEquals(sif1, sif2));
sif2.setName("foo");
assertFalse(assertSolrInputFieldEquals(sif1, sif2));
}
示例5: writeRegularPropertyToTarget
import org.apache.solr.common.SolrInputField; //导入方法依赖的package包/类
private Collection<SolrInputField> writeRegularPropertyToTarget(final Map<? super Object, ? super Object> target,
SolrPersistentProperty persistentProperty, Object fieldValue) {
SolrInputField field = new SolrInputField(persistentProperty.getFieldName());
if (persistentProperty.isCollectionLike()) {
Collection<?> collection = asCollection(fieldValue);
for (Object o : collection) {
if (o != null) {
field.addValue(convertToSolrType(persistentProperty.getType(), o), 1f);
}
}
} else {
field.setValue(convertToSolrType(persistentProperty.getType(), fieldValue), 1f);
}
target.put(persistentProperty.getFieldName(), field);
return Collections.singleton(field);
}
示例6: generateField
import org.apache.solr.common.SolrInputField; //导入方法依赖的package包/类
/**
* @return {@link SolrInputField}
* @should generate SolrInputField correctly
*/
public SolrInputField generateField() {
SolrInputField field = new SolrInputField(getField());
field.setValue(getValue(), 1);
return field;
}
示例7: getInstance
import org.apache.solr.common.SolrInputField; //导入方法依赖的package包/类
@Override
public UpdateRequestProcessor getInstance(SolrQueryRequest req,
SolrQueryResponse rsp,
UpdateRequestProcessor next) {
return new FieldMutatingUpdateProcessor(getSelector(), next) {
@Override
protected SolrInputField mutate(final SolrInputField src) {
SolrInputField result = new SolrInputField(src.getName());
result.setValue(src.getValueCount(),
src.getBoost());
return result;
}
};
}
示例8: parseFieldValue
import org.apache.solr.common.SolrInputField; //导入方法依赖的package包/类
private void parseFieldValue(SolrInputField sif) throws IOException {
int ev = parser.nextEvent();
if (ev == JSONParser.OBJECT_START) {
parseExtendedFieldValue(sif, ev);
} else {
Object val = parseNormalFieldValue(ev);
sif.setValue(val, 1.0f);
}
}
示例9: assignUUIDs
import org.apache.solr.common.SolrInputField; //导入方法依赖的package包/类
/**
* Assigns UUIDs for each document (that does not have an "id" field) in the given list.
* Also makes sure "uniqueId" field is present. The UUIDs generated by this method start
* with ID_FIELD_PREFIX for easy identification. Optionally takes a list
* of UUIDs to be used to set/override the "id" field values of the documents.
*
* @param solrDocs
* @param ids List of id values (optional) to be used for the given documents.
*/
protected void assignUUIDs(List<SolrInputDocument> solrDocs, List<String> ids) throws Exception {
if ((null == solrDocs) || (solrDocs.size() == 0)) {
return;
}
if ((null != ids) && (ids.size() < solrDocs.size())) {
throw new Exception(
"Insufficient UUIDs(" + ids.size() + ") specified for documents(" + solrDocs.size() + ".");
}
for (int i = 0; i < solrDocs.size(); i++) {
SolrInputDocument solrInputDocument = solrDocs.get(i);
SolrInputField idField = solrInputDocument.getField("id");
String uuid = null;
if (null != ids) {
// Get the supplied UUID.
uuid = ids.get(i);
}
if (null == idField) {
if (null == uuid) {
// Generate UUID.
uuid = UUID.randomUUID().toString();
uuid = ID_FIELD_PREFIX + uuid; // identifies the uuid generated by discovery module.
}
solrInputDocument.addField(WorkBibCommonFields.ID, uuid);
solrInputDocument.addField(WorkBibCommonFields.UNIQUE_ID, uuid);
} else {
if (null != uuid) {
// Use the supplied UUID.
solrInputDocument.setField(WorkBibCommonFields.ID, uuid);
solrInputDocument.setField(WorkBibCommonFields.UNIQUE_ID, uuid);
} else {
// Leave the existing id value and make sure uniqueId is set.
// uuid = (String) idField.getValue();
if (idField.getValue() instanceof List) {
List<String> uuidList = (List<String>) idField.getValue();
uuid = uuidList.get(0);
} else if (idField.getValue() instanceof String) {
uuid = (String) idField.getValue();
}
if (null == uuid) {
// Generate UUID.
uuid = UUID.randomUUID().toString();
uuid = ID_FIELD_PREFIX + uuid; // identifies the uuid generated by discovery module.
idField.setValue(uuid, 1.0f);
}
SolrInputField uniqueIdField = solrInputDocument.getField(WorkBibCommonFields.UNIQUE_ID);
if (null == uniqueIdField) {
solrInputDocument.addField(WorkBibCommonFields.UNIQUE_ID, uuid);
} else {
if (uniqueIdField.getValue() == null) {
solrInputDocument.setField(WorkBibCommonFields.UNIQUE_ID, uuid);
}
}
}
}
}
}
示例10: assignUUIDs
import org.apache.solr.common.SolrInputField; //导入方法依赖的package包/类
protected void assignUUIDs(List<SolrInputDocument> solrDocs, List<String> ids) throws Exception {
if ((null == solrDocs) || (solrDocs.size() == 0)) {
return;
}
if ((null != ids) && (ids.size() < solrDocs.size())) {
throw new Exception(
"Insufficient UUIDs(" + ids.size() + ") specified for documents(" + solrDocs.size() + ".");
}
for (int i = 0; i < solrDocs.size(); i++) {
SolrInputDocument solrInputDocument = solrDocs.get(i);
SolrInputField idField = solrInputDocument.getField("id");
String uuid = null;
if (null != ids) {
// Get the supplied UUID.
uuid = ids.get(i);
}
if (null == idField) {
if (null == uuid) {
// Generate UUID.
uuid = UUID.randomUUID().toString();
uuid = ID_FIELD_PREFIX + uuid; // identifies the uuid generated by discovery module.
}
solrInputDocument.addField(ID, uuid);
solrInputDocument.addField(UNIQUE_ID, uuid);
} else {
if (null != uuid) {
// Use the supplied UUID.
solrInputDocument.setField(ID, uuid);
solrInputDocument.setField(UNIQUE_ID, uuid);
} else {
// Leave the existing id value and make sure uniqueId is set.
// uuid = (String) idField.getValue();
if (idField.getValue() instanceof List) {
List<String> uuidList = (List<String>) idField.getValue();
uuid = uuidList.get(0);
} else if (idField.getValue() instanceof String) {
uuid = (String) idField.getValue();
}
if (null == uuid) {
// Generate UUID.
uuid = UUID.randomUUID().toString();
uuid = ID_FIELD_PREFIX + uuid; // identifies the uuid generated by discovery module.
idField.setValue(uuid, 1.0f);
}
SolrInputField uniqueIdField = solrInputDocument.getField(UNIQUE_ID);
if (null == uniqueIdField) {
solrInputDocument.addField(UNIQUE_ID, uuid);
} else {
if (uniqueIdField.getValue() == null) {
solrInputDocument.setField(UNIQUE_ID, uuid);
}
}
}
}
}
}