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