当前位置: 首页>>代码示例>>Java>>正文


Java SolrInputField.setValue方法代码示例

本文整理汇总了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;
    }
  };
}
 
开发者ID:randomstatistic,项目名称:SOLR-5170,代码行数:21,代码来源:MultiValUpdateRequestProcessorFactory.java

示例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;
    }
  };
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:FieldValueSubsetUpdateProcessorFactory.java

示例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;
    }
  };
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:ConcatFieldUpdateProcessorFactory.java

示例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));


}
 
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:DocumentBuilderTest.java

示例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);

}
 
开发者ID:yiduwangkai,项目名称:dubbox-solr,代码行数:22,代码来源:MappingSolrConverter.java

示例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;
}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:11,代码来源:LuceneField.java

示例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;
    }
  };
}
 
开发者ID:europeana,项目名称:search,代码行数:15,代码来源:CountFieldValuesUpdateProcessorFactory.java

示例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);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:JsonLoader.java

示例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);
                    }
                }
            }
        }
    }
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:66,代码来源:AbstractDocumentIndexer.java

示例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);
                    }
                }
            }
        }
    }
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:57,代码来源:DocstoreSolrIndexService.java


注:本文中的org.apache.solr.common.SolrInputField.setValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。