Package org.apache.solr.common
Class SolrInputDocument
- java.lang.Object
-
- org.apache.solr.common.SolrDocumentBase<SolrInputField,SolrInputDocument>
-
- org.apache.solr.common.SolrInputDocument
-
- All Implemented Interfaces:
Serializable,Iterable<SolrInputField>,Map<String,SolrInputField>,MapSerializable,MapWriter,NavigableObject,org.noggit.JSONWriter.Writable
public class SolrInputDocument extends SolrDocumentBase<SolrInputField,SolrInputDocument> implements Iterable<SolrInputField>
Represent the field-value information needed to construct and index a Lucene Document. Like the SolrDocument, the field values should match those specified in schema.xml- Since:
- solr 1.3
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SolrInputDocument()SolrInputDocument(String... fields)SolrInputDocument(Map<String,SolrInputField> fields)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddChildDocument(SolrInputDocument child)voidaddChildDocuments(Collection<SolrInputDocument> children)voidaddField(String name, Object value)Add a field value to any existing values that may or may not exist.voidclear()Remove all fields from the documentbooleancontainsKey(Object key)booleancontainsValue(Object value)SolrInputDocumentdeepCopy()Set<Map.Entry<String,SolrInputField>>entrySet()SolrInputFieldget(Object key)intgetChildDocumentCount()Deprecated.List<SolrInputDocument>getChildDocuments()Returns the list of child documents, or null if none.SolrInputFieldgetField(String field)Collection<String>getFieldNames()Get all field names.ObjectgetFieldValue(String name)Get the first value for a field.Collection<Object>getFieldValues(String name)Get all the values for a field.booleanhasChildDocuments()Has anonymous children?booleanisEmpty()Iterator<SolrInputField>iterator()Set<String>keySet()SolrInputFieldput(String key, SolrInputField value)voidputAll(Map<? extends String,? extends SolrInputField> t)SolrInputFieldremove(Object key)SolrInputFieldremoveField(String name)Remove a field from the documentvoidsetField(String name, Object value)Set a field value; replacing the existing value if present.intsize()StringtoString()Collection<SolrInputField>values()voidvisitSelfAndNestedDocs(BiConsumer<String,SolrInputDocument> consumer)Beta API; may change at will.voidwriteMap(MapWriter.EntryWriter ew)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface java.util.Map
compute, 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
-
-
-
-
Constructor Detail
-
SolrInputDocument
public SolrInputDocument()
-
SolrInputDocument
public SolrInputDocument(String... fields)
-
SolrInputDocument
public SolrInputDocument(Map<String,SolrInputField> fields)
-
-
Method Detail
-
writeMap
public void writeMap(MapWriter.EntryWriter ew) throws IOException
- Specified by:
writeMapin interfaceMapWriter- Throws:
IOException
-
clear
public void clear()
Remove all fields from the document- Specified by:
clearin interfaceMap<String,SolrInputField>
-
addField
public void addField(String name, Object value)
Add a field value to any existing values that may or may not exist.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<SolrInputField,SolrInputDocument>- 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.
-
getFieldValue
public Object getFieldValue(String name)
Get the first value for a field.- Specified by:
getFieldValuein classSolrDocumentBase<SolrInputField,SolrInputDocument>- Parameters:
name- name of the field to fetch- Returns:
- first value of the field or null if not present
-
getFieldValues
public Collection<Object> getFieldValues(String name)
Get all the values for a field.- Specified by:
getFieldValuesin classSolrDocumentBase<SolrInputField,SolrInputDocument>- Parameters:
name- name of the field to fetch- Returns:
- value of the field or null if not set
-
getFieldNames
public Collection<String> getFieldNames()
Get all field names.- Specified by:
getFieldNamesin classSolrDocumentBase<SolrInputField,SolrInputDocument>- Returns:
- Set of all field names.
-
setField
public void setField(String name, Object value)
Set a field value; replacing the existing value if present.- Specified by:
setFieldin classSolrDocumentBase<SolrInputField,SolrInputDocument>- Parameters:
name- name of the field to setvalue- value of the field
-
removeField
public SolrInputField removeField(String name)
Remove a field from the document- Parameters:
name- The field name whose field is to be removed from the document- Returns:
- the previous field with
name, ornullif there was no field forkey.
-
getField
public SolrInputField getField(String field)
-
iterator
public Iterator<SolrInputField> iterator()
- Specified by:
iteratorin interfaceIterable<SolrInputField>
-
deepCopy
public SolrInputDocument deepCopy()
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<String,SolrInputField>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap<String,SolrInputField>
-
entrySet
public Set<Map.Entry<String,SolrInputField>> entrySet()
- Specified by:
entrySetin interfaceMap<String,SolrInputField>
-
get
public SolrInputField get(Object key)
- Specified by:
getin interfaceMap<String,SolrInputField>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceMap<String,SolrInputField>
-
put
public SolrInputField put(String key, SolrInputField value)
- Specified by:
putin interfaceMap<String,SolrInputField>
-
putAll
public void putAll(Map<? extends String,? extends SolrInputField> t)
- Specified by:
putAllin interfaceMap<String,SolrInputField>
-
remove
public SolrInputField remove(Object key)
- Specified by:
removein interfaceMap<String,SolrInputField>
-
size
public int size()
- Specified by:
sizein interfaceMap<String,SolrInputField>
-
values
public Collection<SolrInputField> values()
- Specified by:
valuesin interfaceMap<String,SolrInputField>
-
addChildDocument
public void addChildDocument(SolrInputDocument child)
- Specified by:
addChildDocumentin classSolrDocumentBase<SolrInputField,SolrInputDocument>
-
addChildDocuments
public void addChildDocuments(Collection<SolrInputDocument> children)
- Specified by:
addChildDocumentsin classSolrDocumentBase<SolrInputField,SolrInputDocument>
-
visitSelfAndNestedDocs
public void visitSelfAndNestedDocs(BiConsumer<String,SolrInputDocument> consumer)
Beta API; may change at will.
-
getChildDocuments
public List<SolrInputDocument> getChildDocuments()
Returns the list of child documents, or null if none.- Specified by:
getChildDocumentsin classSolrDocumentBase<SolrInputField,SolrInputDocument>
-
hasChildDocuments
public boolean hasChildDocuments()
Description copied from class:SolrDocumentBaseHas anonymous children?- Specified by:
hasChildDocumentsin classSolrDocumentBase<SolrInputField,SolrInputDocument>
-
getChildDocumentCount
@Deprecated public int getChildDocumentCount()
Deprecated.Description copied from class:SolrDocumentBaseThe anonymous child document count.- Specified by:
getChildDocumentCountin classSolrDocumentBase<SolrInputField,SolrInputDocument>
-
-