Package org.apache.solr.common
Class SolrDocument
- All Implemented Interfaces:
Serializable,Iterable<Map.Entry<String,,Object>> Map<String,,Object> MapSerializable,MapWriter,NavigableObject,org.noggit.JSONWriter.Writable
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.xml
For indexing documents, use the SolrInputDocument that contains extra information for document and field boosting.
- Since:
- solr 1.3
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.solr.common.MapWriter
MapWriter.EntryWriter -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChildDocument(SolrDocument child) voidaddChildDocuments(Collection<SolrDocument> children) voidThis will add a field to the document.voidclear()Remove all fields from the documentbooleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()intDeprecated.Returns the list of anonymous child documents, or null if none.Get all field names.getFieldValue(String name) Get the value or collection of values for a given field.Expose a Map interface to the solr fields.getFieldValues(String name) Get a collection of values for a given field nameExpose a Map interface to the solr field value collection.getFirstValue(String name) returns the first value for a fieldgetSubsetOfFields(Set<String> fieldNames) Get the value or collection of values for a given field.booleanHas anonymous children?booleanisEmpty()iterator()Iterate of String->Object keyskeySet()voidbooleanremoveFields(String name) Remove all fields with the namevoidSet a field with the given object.intsize()toString()values()voidvisitSelfAndNestedDocs(BiConsumer<String, SolrDocument> consumer) Beta API; may change at will.voidWrites this object's entries out toew.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAllMethods inherited from interface org.apache.solr.common.NavigableObject
_forEachEntry, _forEachEntry, _forEachEntry, _get, _get, _getStr, _getStr, _size
-
Field Details
-
_fields
-
-
Constructor Details
-
SolrDocument
public SolrDocument() -
SolrDocument
-
-
Method Details
-
writeMap
Description copied from interface:MapWriterWrites this object's entries out toew.- Specified by:
writeMapin interfaceMapWriter- Throws:
IOException
-
getFieldNames
Description copied from class:SolrDocumentBaseGet all field names.- Specified by:
getFieldNamesin classSolrDocumentBase<Object,SolrDocument> - Returns:
- a list of field names defined in this document - this Collection is directly backed by this SolrDocument.
- See Also:
-
clear
public void clear()Remove all fields from the document -
removeFields
Remove all fields with the name -
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- Specified by:
setFieldin classSolrDocumentBase<Object,SolrDocument> - Parameters:
name- name of the field to setvalue- value of the field
-
addField
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 classSolrDocumentBase<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.
-
getFirstValue
returns the first value for a field -
getFieldValue
Get the value or collection of values for a given field.- Specified by:
getFieldValuein classSolrDocumentBase<Object,SolrDocument>
-
getFieldValues
Get a collection of values for a given field name- Specified by:
getFieldValuesin classSolrDocumentBase<Object,SolrDocument>
-
getSubsetOfFields
Get the value or collection of values for a given field. -
toString
-
iterator
Iterate of String->Object keys -
visitSelfAndNestedDocs
Beta API; may change at will. -
getFieldValuesMap
Expose a Map interface to the solr field value collection. -
getFieldValueMap
Expose a Map interface to the solr fields. This function is useful for JSTL -
containsKey
- Specified by:
containsKeyin interfaceMap<String,Object>
-
containsValue
- Specified by:
containsValuein interfaceMap<String,Object>
-
entrySet
-
get
-
isEmpty
public boolean isEmpty() -
keySet
-
put
-
putAll
-
remove
-
size
public int size() -
values
-
addChildDocument
- Specified by:
addChildDocumentin classSolrDocumentBase<Object,SolrDocument>
-
addChildDocuments
- Specified by:
addChildDocumentsin classSolrDocumentBase<Object,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 classSolrDocumentBase<Object,SolrDocument>
-
hasChildDocuments
public boolean hasChildDocuments()Description copied from class:SolrDocumentBaseHas anonymous children?- Specified by:
hasChildDocumentsin classSolrDocumentBase<Object,SolrDocument>
-
getChildDocumentCount
Deprecated.Description copied from class:SolrDocumentBaseThe anonymous child document count.- Specified by:
getChildDocumentCountin classSolrDocumentBase<Object,SolrDocument>
-