Package org.apache.solr.common
Class SolrDocument
- java.lang.Object
- 
- org.apache.solr.common.SolrDocumentBase<Object,SolrDocument>
- 
- org.apache.solr.common.SolrDocument
 
 
- 
- All Implemented Interfaces:
- Serializable,- Iterable<Map.Entry<String,Object>>,- Map<String,Object>,- MapSerializable,- MapWriter,- NavigableObject
 
 public class SolrDocument extends SolrDocumentBase<Object,SolrDocument> implements Iterable<Map.Entry<String,Object>> A concrete representation of a document within a Solr index. Unlike a lucene Document, a SolrDocument may have an Object value matching the type defined in schema.xmlFor indexing documents, use the SolrInputDocument that contains extra information for document and field boosting. - Since:
- solr 1.3
- See Also:
- Serialized Form
 
- 
- 
Constructor SummaryConstructors Constructor Description SolrDocument()SolrDocument(Map<String,Object> fields)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddChildDocument(SolrDocument child)voidaddChildDocuments(Collection<SolrDocument> children)voidaddField(String name, Object value)This will add a field to the document.voidclear()Remove all fields from the documentbooleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<String,Object>>entrySet()Objectget(Object key)intgetChildDocumentCount()Deprecated.List<SolrDocument>getChildDocuments()Returns the list of anonymous child documents, or null if none.Collection<String>getFieldNames()Get all field names.ObjectgetFieldValue(String name)Get the value or collection of values for a given field.Map<String,Object>getFieldValueMap()Expose a Map interface to the solr fields.Collection<Object>getFieldValues(String name)Get a collection of values for a given field nameMap<String,Collection<Object>>getFieldValuesMap()Expose a Map interface to the solr field value collection.ObjectgetFirstValue(String name)returns the first value for a fieldbooleanhasChildDocuments()Has anonymous children?booleanisEmpty()Iterator<Map.Entry<String,Object>>iterator()Iterate of String->Object keysSet<String>keySet()Objectput(String key, Object value)voidputAll(Map<? extends String,? extends Object> t)Objectremove(Object key)booleanremoveFields(String name)Remove all fields with the namevoidsetField(String name, Object value)Set a field with the given object.intsize()StringtoString()Collection<Object>values()voidvisitSelfAndNestedDocs(BiConsumer<String,SolrDocument> consumer)Beta API; may change at will.voidwriteMap(MapWriter.EntryWriter ew)- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface java.lang.IterableforEach, spliterator
 - 
Methods inherited from interface java.util.Mapcompute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
 - 
Methods inherited from interface org.apache.solr.common.NavigableObject_forEachEntry, _forEachEntry, _forEachEntry, _get, _get, _getStr, _getStr, _size
 
- 
 
- 
- 
- 
Method Detail- 
writeMappublic void writeMap(MapWriter.EntryWriter ew) throws IOException - Specified by:
- writeMapin interface- MapWriter
- Throws:
- IOException
 
 - 
getFieldNamespublic Collection<String> getFieldNames() Description copied from class:SolrDocumentBaseGet all field names.- Specified by:
- getFieldNamesin class- SolrDocumentBase<Object,SolrDocument>
- Returns:
- a list of field names defined in this document - this Collection is directly backed by this SolrDocument.
- See Also:
- keySet()
 
 - 
clearpublic void clear() Remove all fields from the document
 - 
removeFieldspublic boolean removeFields(String name) Remove all fields with the name
 - 
setFieldpublic void setField(String name, Object value) 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- Specified by:
- setFieldin class- SolrDocumentBase<Object,SolrDocument>
- Parameters:
- name- name of the field to set
- value- value of the field
 
 - 
addFieldpublic void addField(String name, Object value) This will add a field to the document. If fields already exist with this name it will append value to the collection. If the value is Collection, each value will be added independently.The class type of value and the name parameter should match schema.xml. schema.xml can be found in conf directory under the solr home by default. - Specified by:
- addFieldin class- SolrDocumentBase<Object,SolrDocument>
- Parameters:
- name- Name of the field, should match one of the field names defined under "fields" tag in schema.xml.
- value- Value of the field, should be of same class type as defined by "type" attribute of the corresponding field in schema.xml.
 
 - 
getFieldValuepublic Object getFieldValue(String name) Get the value or collection of values for a given field.- Specified by:
- getFieldValuein class- SolrDocumentBase<Object,SolrDocument>
 
 - 
getFieldValuespublic Collection<Object> getFieldValues(String name) Get a collection of values for a given field name- Specified by:
- getFieldValuesin class- SolrDocumentBase<Object,SolrDocument>
 
 - 
visitSelfAndNestedDocspublic void visitSelfAndNestedDocs(BiConsumer<String,SolrDocument> consumer) Beta API; may change at will.
 - 
getFieldValuesMappublic Map<String,Collection<Object>> getFieldValuesMap() Expose a Map interface to the solr field value collection.
 - 
getFieldValueMappublic Map<String,Object> getFieldValueMap() Expose a Map interface to the solr fields. This function is useful for JSTL
 - 
containsKeypublic boolean containsKey(Object key) - Specified by:
- containsKeyin interface- Map<String,Object>
 
 - 
containsValuepublic boolean containsValue(Object value) - Specified by:
- containsValuein interface- Map<String,Object>
 
 - 
addChildDocumentpublic void addChildDocument(SolrDocument child) - Specified by:
- addChildDocumentin class- SolrDocumentBase<Object,SolrDocument>
 
 - 
addChildDocumentspublic void addChildDocuments(Collection<SolrDocument> children) - Specified by:
- addChildDocumentsin class- SolrDocumentBase<Object,SolrDocument>
 
 - 
getChildDocumentspublic List<SolrDocument> getChildDocuments() Description copied from class:SolrDocumentBaseReturns the list of anonymous child documents, or null if none. There may be other "labelled" child documents found in field values, in which the field name is the label. This may be deprecated in 8.0.- Specified by:
- getChildDocumentsin class- SolrDocumentBase<Object,SolrDocument>
 
 - 
hasChildDocumentspublic boolean hasChildDocuments() Description copied from class:SolrDocumentBaseHas anonymous children?- Specified by:
- hasChildDocumentsin class- SolrDocumentBase<Object,SolrDocument>
 
 - 
getChildDocumentCount@Deprecated public int getChildDocumentCount() Deprecated.Description copied from class:SolrDocumentBaseThe anonymous child document count.- Specified by:
- getChildDocumentCountin class- SolrDocumentBase<Object,SolrDocument>
 
 
- 
 
-