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

    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

### Nested Class Summary

### Nested classes/interfaces inherited from interface java.util.Map

`Map.Entry<K,V>`

### Nested classes/interfaces inherited from interface org.apache.solr.common.MapWriter

`MapWriter.EntryWriter`

### Constructor Summary

Constructors
Constructor and Description
`SolrInputDocument(Map<String,SolrInputField> fields)`
`SolrInputDocument(String... fields)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addChildDocument(SolrInputDocument child)`
`void` `addChildDocuments(Collection<SolrInputDocument> children)`
`void` `addField(String name, Object value)` Add a field value to any existing values that may or may not exist.
`void` `clear()` Remove all fields from the document
`boolean` `containsKey(Object key)`
`boolean` `containsValue(Object value)`
`SolrInputDocument` `deepCopy()`
`Set<Map.Entry<String,SolrInputField>>` `entrySet()`
`SolrInputField` `get(Object key)`
`int` `getChildDocumentCount()` The anonymous child document count.
`List<SolrInputDocument>` `getChildDocuments()` Returns the list of child documents, or null if none.
`SolrInputField` `getField(String field)`
`Collection<String>` `getFieldNames()` Get all field names.
`Object` `getFieldValue(String name)` Get the first value for a field.
`Collection<Object>` `getFieldValues(String name)` Get all the values for a field.
`boolean` `hasChildDocuments()` Has anonymous children?
`boolean` `isEmpty()`
`Iterator<SolrInputField>` `iterator()`
`Set<String>` `keySet()`
`SolrInputField` `put(String key, SolrInputField value)`
`void` `putAll(Map<? extends String,? extends SolrInputField> t)`
`SolrInputField` `remove(Object key)`
`SolrInputField` `removeField(String name)` Remove a field from the document
`void` `setField(String name, Object value)` Set a field value; replacing the existing value if present.
`int` `size()`
`String` `toString()`
`Collection<SolrInputField>` `values()`
`void` `writeMap(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.MapWriter

`jsonStr, toMap`

### Methods inherited from interface org.apache.solr.common.NavigableObject

`_forEachEntry, _forEachEntry, _forEachEntry, _get, _get, _getStr, _getStr`

### Constructor Detail

#### 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:
  `writeMap` in interface `MapWriter`
Throws:
  `IOException`

#### clear

    public void clear()

Remove all fields from the document

Specified by:
  `clear` in interface `Map<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:
  `addField` in class `SolrDocumentBase<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:
  `getFieldValue` in class `SolrDocumentBase<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:
  `getFieldValues` in class `SolrDocumentBase<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:
  `getFieldNames` in class `SolrDocumentBase<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:
  `setField` in class `SolrDocumentBase<SolrInputField,SolrInputDocument>`
Parameters:
  `name` - name of the field to set
  `value` - 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`, or `null` if there was no field for `key`.

#### getField

    public SolrInputField getField(String field)

#### iterator

    public Iterator<SolrInputField> iterator()

Specified by:
  `iterator` in interface `Iterable<SolrInputField>`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### deepCopy

    public SolrInputDocument deepCopy()

#### containsKey

    public boolean containsKey(Object key)

Specified by:
  `containsKey` in interface `Map<String,SolrInputField>`

#### containsValue

    public boolean containsValue(Object value)

Specified by:
  `containsValue` in interface `Map<String,SolrInputField>`

#### entrySet

    public Set<Map.Entry<String,SolrInputField>> entrySet()

Specified by:
  `entrySet` in interface `Map<String,SolrInputField>`

#### get

    public SolrInputField get(Object key)

Specified by:
  `get` in interface `Map<String,SolrInputField>`

#### isEmpty

    public boolean isEmpty()

Specified by:
  `isEmpty` in interface `Map<String,SolrInputField>`

#### keySet

    public Set<String> keySet()

Specified by:
  `keySet` in interface `Map<String,SolrInputField>`

#### put

    public SolrInputField put(String key,
                              SolrInputField value)

Specified by:
  `put` in interface `Map<String,SolrInputField>`

#### putAll

    public void putAll(Map<? extends String,? extends SolrInputField> t)

Specified by:
  `putAll` in interface `Map<String,SolrInputField>`

#### remove

    public SolrInputField remove(Object key)

Specified by:
  `remove` in interface `Map<String,SolrInputField>`

#### size

    public int size()

Specified by:
  `size` in interface `Map<String,SolrInputField>`

#### values

    public Collection<SolrInputField> values()

Specified by:
  `values` in interface `Map<String,SolrInputField>`

#### addChildDocument

    public void addChildDocument(SolrInputDocument child)

Specified by:
  `addChildDocument` in class `SolrDocumentBase<SolrInputField,SolrInputDocument>`

#### addChildDocuments

    public void addChildDocuments(Collection<SolrInputDocument> children)

Specified by:
  `addChildDocuments` in class `SolrDocumentBase<SolrInputField,SolrInputDocument>`

#### getChildDocuments

    public List<SolrInputDocument> getChildDocuments()

Returns the list of child documents, or null if none.

Specified by:
  `getChildDocuments` in class `SolrDocumentBase<SolrInputField,SolrInputDocument>`

#### hasChildDocuments

    public boolean hasChildDocuments()

Description copied from class: `SolrDocumentBase`
Has anonymous children?

Specified by:
  `hasChildDocuments` in class `SolrDocumentBase<SolrInputField,SolrInputDocument>`

#### getChildDocumentCount

    public int getChildDocumentCount()

Description copied from class: `SolrDocumentBase`
The anonymous child document count.

Specified by:
  `getChildDocumentCount` in class `SolrDocumentBase<SolrInputField,SolrInputDocument>`