热门标签 | 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;
}

推荐阅读
  • 总结一下C中string的操作,来自〈CPrimer〉第四版。1.string对象的定义和初始化:strings1;空串strings2(s1);将s2初始 ... [详细]
  • CF:3D City Model(小思维)问题解析和代码实现
    本文通过解析CF:3D City Model问题,介绍了问题的背景和要求,并给出了相应的代码实现。该问题涉及到在一个矩形的网格上建造城市的情景,每个网格单元可以作为建筑的基础,建筑由多个立方体叠加而成。文章详细讲解了问题的解决思路,并给出了相应的代码实现供读者参考。 ... [详细]
  • 标题: ... [详细]
  • 本文介绍了使用C++Builder实现获取USB优盘序列号的方法,包括相关的代码和说明。通过该方法,可以获取指定盘符的USB优盘序列号,并将其存放在缓冲中。该方法可以在Windows系统中有效地获取USB优盘序列号,并且适用于C++Builder开发环境。 ... [详细]
  • 这是原文链接:sendingformdata许多情况下,我们使用表单发送数据到服务器。服务器处理数据并返回响应给用户。这看起来很简单,但是 ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • 本文介绍了九度OnlineJudge中的1002题目“Grading”的解决方法。该题目要求设计一个公平的评分过程,将每个考题分配给3个独立的专家,如果他们的评分不一致,则需要请一位裁判做出最终决定。文章详细描述了评分规则,并给出了解决该问题的程序。 ... [详细]
  • sklearn数据集库中的常用数据集类型介绍
    本文介绍了sklearn数据集库中常用的数据集类型,包括玩具数据集和样本生成器。其中详细介绍了波士顿房价数据集,包含了波士顿506处房屋的13种不同特征以及房屋价格,适用于回归任务。 ... [详细]
  • 本文介绍了一个题目的解法,通过二分答案来解决问题,但困难在于如何进行检查。文章提供了一种逃逸方式,通过移动最慢的宿管来锁门时跑到更居中的位置,从而使所有合格的寝室都居中。文章还提到可以分开判断两边的情况,并使用前缀和的方式来求出在任意时刻能够到达宿管即将锁门的寝室的人数。最后,文章提到可以改成O(n)的直接枚举来解决问题。 ... [详细]
  • 3.223.28周学习总结中的贪心作业收获及困惑
    本文是对3.223.28周学习总结中的贪心作业进行总结,作者在解题过程中参考了他人的代码,但前提是要先理解题目并有解题思路。作者分享了自己在贪心作业中的收获,同时提到了一道让他困惑的题目,即input details部分引发的疑惑。 ... [详细]
  • 开发笔记:实验7的文件读写操作
    本文介绍了使用C++的ofstream和ifstream类进行文件读写操作的方法,包括创建文件、写入文件和读取文件的过程。同时还介绍了如何判断文件是否成功打开和关闭文件的方法。通过本文的学习,读者可以了解如何在C++中进行文件读写操作。 ... [详细]
  • IjustinheritedsomewebpageswhichusesMooTools.IneverusedMooTools.NowIneedtoaddsomef ... [详细]
  • 本文介绍了在iOS开发中使用UITextField实现字符限制的方法,包括利用代理方法和使用BNTextField-Limit库的实现策略。通过这些方法,开发者可以方便地限制UITextField的字符个数和输入规则。 ... [详细]
  • Gitlab接入公司内部单点登录的安装和配置教程
    本文介绍了如何将公司内部的Gitlab系统接入单点登录服务,并提供了安装和配置的详细教程。通过使用oauth2协议,将原有的各子系统的独立登录统一迁移至单点登录。文章包括Gitlab的安装环境、版本号、编辑配置文件的步骤,并解决了在迁移过程中可能遇到的问题。 ... [详细]
  • 本文介绍了解决java开源项目apache commons email简单使用报错的方法,包括使用正确的JAR包和正确的代码配置,以及相关参数的设置。详细介绍了如何使用apache commons email发送邮件。 ... [详细]
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社区 版权所有