热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.apache.solr.common.SolrDocument.setField()方法的使用及代码示例

本文整理了Java中org.apache.solr.common.SolrDocument.setField()方法的一些代码示例,展示了SolrDocum

本文整理了Java中org.apache.solr.common.SolrDocument.setField()方法的一些代码示例,展示了SolrDocument.setField()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SolrDocument.setField()方法的具体详情如下:
包路径:org.apache.solr.common.SolrDocument
类名称:SolrDocument
方法名:setField

SolrDocument.setField介绍

[英]Set a field with the given object. If the object is an Array, it will set multiple fields with the included contents. This will replace any existing field with the given name
[中]用给定对象设置一个字段。如果对象是数组,它将设置包含内容的多个字段。这将用给定的名称替换任何现有字段

代码示例

代码示例来源:origin: apache/incubator-sentry

@Override
public void transform(SolrDocument doc, int docid) {
doc.setField( name, docid );
}
}

代码示例来源:origin: org.apache.solr/solr-common

this.setField( name, value );
return;

代码示例来源:origin: org.apache.solr/solr-solrj

c.add(o);
this.setField( name, c );
} else {
this.setField( name, value );

代码示例来源:origin: com.hynnet/solr-solrj

c.add(o);
this.setField( name, c );
} else {
this.setField( name, value );

代码示例来源:origin: org.dspace.dependencies.solr/dspace-solr-solrj

/**
* @param d SolrInputDocument to convert
* @return a SolrDocument with the same fields and values as the SolrInputDocument
*/
public static SolrDocument toSolrDocument( SolrInputDocument d )
{
SolrDocument doc = new SolrDocument();
for( SolrInputField field : d ) {
doc.setField( field.getName(), field.getValue() );
}
return doc;
}

代码示例来源:origin: keeps/roda

public static SolrInputDocument addOtherPropertiesToIndexedFile(String prefix, OtherMetadata otherMetadataBinary,
ModelService model, SolrClient index)
throws RequestNotValidException, GenericException, NotFoundException, AuthorizationDeniedException,
ParserConfigurationException, SAXException, IOException, XPathExpressionException, SolrServerException {
SolrDocument solrDocument = index.getById(RodaConstants.INDEX_FILE,
IdUtils.getFileId(otherMetadataBinary.getAipId(), otherMetadataBinary.getRepresentationId(),
otherMetadataBinary.getFileDirectoryPath(), otherMetadataBinary.getFileId()));
Binary binary = model.retrieveOtherMetadataBinary(otherMetadataBinary);
Map> otherProperties = MetadataFileUtils.parseBinary(binary);
for (Map.Entry> entry : otherProperties.entrySet()) {
solrDocument.setField(prefix + entry.getKey(), entry.getValue());
}
return solrDocumentToSolrInputDocument(solrDocument);
}

代码示例来源:origin: org.apache.solr/solr-solrj

public SolrDocument readSolrDocument(DataInputInputStream dis) throws IOException {
tagByte = dis.readByte();
int size = readSize(dis);
SolrDocument doc = new SolrDocument(new LinkedHashMap<>(size));
for (int i = 0; i String fieldName;
Object obj = readVal(dis); // could be a field name, or a child document
if (obj instanceof SolrDocument) {
doc.addChildDocument((SolrDocument)obj);
continue;
} else {
fieldName = (String)obj;
}
Object fieldVal = readVal(dis);
doc.setField(fieldName, fieldVal);
}
return doc;
}

代码示例来源:origin: org.apache.solr/solr-common

public SolrDocument readSolrDocument(FastInputStream dis) throws IOException {
NamedList nl = (NamedList) readVal(dis);
SolrDocument doc = new SolrDocument();
for (int i = 0; i String name = nl.getName(i);
Object val = nl.getVal(i);
doc.setField(name, val);
}
return doc;
}

代码示例来源:origin: org.dspace.dependencies.solr/dspace-solr-core

private void returnFields(ResponseBuilder rb, ShardRequest sreq) {
// Keep in mind that this could also be a shard in a multi-tiered system.
// TODO: if a multi-tiered system, it seems like some requests
// could/should bypass middlemen (like retrieving stored fields)
// TODO: merge fsv to if requested
if ((sreq.purpose & ShardRequest.PURPOSE_GET_FIELDS) != 0) {
boolean returnScores = (rb.getFieldFlags() & SolrIndexSearcher.GET_SCORES) != 0;
assert(sreq.responses.size() == 1);
ShardResponse srsp = sreq.responses.get(0);
SolrDocumentList docs = (SolrDocumentList)srsp.getSolrResponse().getResponse().get("response");
String keyFieldName = rb.req.getSchema().getUniqueKeyField().getName();
for (SolrDocument doc : docs) {
Object id = doc.getFieldValue(keyFieldName);
ShardDoc sdoc = rb.resultIds.get(id.toString());
if (sdoc != null) {
if (returnScores && sdoc.score != null) {
doc.setField("score", sdoc.score);
}
rb._responseDocs.set(sdoc.positionInResponse, doc);
}
}
}
}

代码示例来源:origin: apache/incubator-sentry

private static SolrDocument toSolrDoc(Document doc, IndexSchema schema) {
SolrDocument out = new SolrDocument();
for ( IndexableField f : doc.getFields() ) {
// Make sure multivalued fields are represented as lists
Object existing = out.get(f.name());
if (existing == null) {
SchemaField sf = schema.getFieldOrNull(f.name());
// don't return copyField targets
if (sf != null && schema.isCopyFieldTarget(sf)) continue;
if (sf != null && sf.multiValued()) {
List vals = new ArrayList<>();
vals.add( f );
out.setField( f.name(), vals );
}
else{
out.setField( f.name(), f );
}
}
else {
out.addField( f.name(), f );
}
}
return out;
}

代码示例来源:origin: sirensolutions/siren

@Override
public void transform(SolrDocument doc, int docid) throws IOException {
Query query = context.query;
SimpleJsonByQueryExtractor extractor = new SimpleJsonByQueryExtractor();
try {
IndexSchema schema = context.req.getSchema();
for (String fieldName : doc.getFieldNames()) {
FieldType ft = schema.getFieldOrNull(fieldName).getType();
if (ft instanceof ExtendedJsonField) {
String sirenField = (String) doc.getFieldValue(fieldName);
String json = extractor.extractAsString(sirenField, query);
if (json == null) {
// query doesn't contain variables, no transformation is necessary
continue;
}
doc.setField(fieldName, json);
}
}
} catch (ProjectionException e) {
throw new IOException(String.format(
"Problem while projecting (extracting variables from matched document id %s",
doc.getFieldValue("id")), e);
}
}

代码示例来源:origin: apache/stanbol

negativeSupport, uptodate, evaluationDate);
if (metadata.getFieldValues(falsePositivesField) == null) {
metadata.setField(falsePositivesField, new ArrayList());
metadata.setField(falseNegativesField, new ArrayList());

代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.enhancer.engine.topic

negativeSupport, uptodate, evaluationDate);
if (metadata.getFieldValues(falsePositivesField) == null) {
metadata.setField(falsePositivesField, new ArrayList());
metadata.setField(falseNegativesField, new ArrayList());

代码示例来源:origin: com.hynnet/solr-solrj

public SolrDocument readSolrDocument(DataInputInputStream dis) throws IOException {
tagByte = dis.readByte();
int size = readSize(dis);
SolrDocument doc = new SolrDocument();
for (int i = 0; i String fieldName;
Object obj = readVal(dis); // could be a field name, or a child document
if (obj instanceof SolrDocument) {
doc.addChildDocument((SolrDocument)obj);
continue;
} else {
fieldName = (String)obj;
}
Object fieldVal = readVal(dis);
doc.setField(fieldName, fieldVal);
}
return doc;
}

代码示例来源:origin: com.hynnet/solr-solrj

/**
* @param d SolrInputDocument to convert
* @return a SolrDocument with the same fields and values as the SolrInputDocument
*/
public static SolrDocument toSolrDocument(SolrInputDocument d) {
SolrDocument doc = new SolrDocument();
for (SolrInputField field : d) {
doc.setField(field.getName(), field.getValue());
}
if (d.getChildDocuments() != null) {
for (SolrInputDocument in : d.getChildDocuments()) {
doc.addChildDocument(toSolrDocument(in));
}
}
return doc;
}

代码示例来源:origin: ChronixDB/chronix.server

/**
* Converts a lucene document to a solr document.
*
* @param schema the index schema
* @param luceneDoc the lucene document
* @return solr document
*/
public SolrDocument toSolrDoc(IndexSchema schema, Document luceneDoc) {
SolrDocument solrDoc = new SolrDocument();
luceneDoc.forEach(it -> solrDoc.addField(it.name(), schema.getField(it.name()).getType().toObject(it)));
for (String field : solrDoc.getFieldNames()) {
Object value = solrDoc.getFieldValue(field);
if (value instanceof ByteBuffer) {
solrDoc.setField(field, ((ByteBuffer) value).array());
}
}
return solrDoc;
}

代码示例来源:origin: ChronixDB/chronix.server

private SolrDocument solrDocumentWithOutTimeSeriesFunctionResults(boolean dataShouldReturned, boolean dataAsJson, ChronixTimeSeries timeSeries) {
SolrDocument doc = new SolrDocument();
//add the join key
doc.put(ChronixQueryParams.JOIN_KEY, timeSeries.getJoinKey());
for (Map.Entry entry : (Set>) timeSeries.getAttributes().entrySet()) {
doc.addField(entry.getKey(), entry.getValue());
}
//add the metric field as it is not stored in the getAttributes
doc.addField(Schema.NAME, timeSeries.getName());
doc.addField(Schema.TYPE, timeSeries.getType());
//TODO: Fix this. It is expensive to calculate this based on the points. This is already stored.
doc.addField(Schema.START, timeSeries.getStart());
doc.addField(Schema.END, timeSeries.getEnd());
if (dataShouldReturned) {
//ensure that the returned data is sorted
timeSeries.sort();
//data should returned serialized as json
if (dataAsJson) {
doc.setField(ChronixQueryParams.DATA_AS_JSON, timeSeries.dataAsJson());
} else {
doc.addField(Schema.DATA, timeSeries.dataAsBlob());
}
}
return doc;
}

推荐阅读
  • 本文详细介绍了 org.apache.commons.io.IOCase 类中的 checkCompareTo() 方法,通过多个代码示例展示其在不同场景下的使用方法。 ... [详细]
  • 配置多VLAN环境下的透明SQUID代理
    本文介绍如何在包含多个VLAN的网络环境中配置SQUID作为透明网关。网络拓扑包括Cisco 3750交换机、PANABIT防火墙和SQUID服务器,所有设备均部署在ESXi虚拟化平台上。 ... [详细]
  • 探讨ChatGPT在法律和版权方面的潜在风险及影响,分析其作为内容创造工具的合法性和合规性。 ... [详细]
  • 本文详细介绍了如何使用 HTML 和 CSS 对文件上传按钮进行样式美化,使用户界面更加友好和美观。 ... [详细]
  • 对象自省自省在计算机编程领域里,是指在运行时判断一个对象的类型和能力。dir能够返回一个列表,列举了一个对象所拥有的属性和方法。my_list[ ... [详细]
  • 反向投影技术主要用于在大型输入图像中定位特定的小型模板图像。通过直方图对比,它能够识别出最匹配的区域或点,从而确定模板图像在输入图像中的位置。 ... [详细]
  • Python处理Word文档的高效技巧
    本文详细介绍了如何使用Python处理Word文档,涵盖从基础操作到高级功能的各种技巧。我们将探讨如何生成文档、定义样式、提取表格数据以及处理超链接和图片等内容。 ... [详细]
  • 本文介绍了一个SQL Server自定义函数,用于从字符串中提取仅包含数字和小数点的子串。该函数通过循环删除非数字字符来实现,并附带创建测试表、存储过程以演示其应用。 ... [详细]
  • 本文介绍如何从字符串中移除大写、小写、特殊、数字和非数字字符,并提供了多种编程语言的实现示例。 ... [详细]
  • #print(34or4 ... [详细]
  • 本文探讨了如何在Classic ASP中实现与PHP的hash_hmac('SHA256', $message, pack('H*', $secret))函数等效的哈希生成方法。通过分析不同实现方式及其产生的差异,提供了一种使用Microsoft .NET Framework的解决方案。 ... [详细]
  • 使用JS、HTML5和C3创建自定义弹出窗口
    本文介绍如何结合JavaScript、HTML5和C3.js来实现一个功能丰富的自定义弹出窗口。通过具体的代码示例,详细讲解了实现过程中的关键步骤和技术要点。 ... [详细]
  • 本文将详细探讨 Java 中提供的不可变集合(如 `Collections.unmodifiableXXX`)和同步集合(如 `Collections.synchronizedXXX`)的实现原理及使用方法,帮助开发者更好地理解和应用这些工具。 ... [详细]
  • 本文详细探讨了Java中的ClassLoader类加载器的工作原理,包括其如何将class文件加载至JVM中,以及JVM启动时的动态加载策略。文章还介绍了JVM内置的三种类加载器及其工作方式,并解释了类加载器的继承关系和双亲委托机制。 ... [详细]
  • 一个登陆界面
    预览截图html部分123456789101112用户登入1314邮箱名称邮箱为空15密码密码为空16登 ... [详细]
author-avatar
疯子jiushiwohaha
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有