org.apache.solr.common

## Class SolrInputDocument

- java.lang.Object
- - org.apache.solr.common.SolrInputDocument

All Implemented Interfaces:
  Serializable, Iterable<SolrInputField>, Map<String,SolrInputField>

    public class SolrInputDocument
    extends Object
    implements Map<String,SolrInputField>, Iterable<SolrInputField>, Serializable

Represent the field and boost 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>`

### Constructor Summary

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

### Method Summary

Methods
`void` `addField(String name, Object value)` Add a field with implied null value for boost.
`void` `addField(String name, Object value, float boost)` Adds a field with the given name, value and boost.
`void` `clear()` Remove all fields and boosts from the document
`boolean` `containsKey(Object key)`
`boolean` `containsValue(Object value)`
`SolrInputDocument` `deepCopy()`
`Set<Map.Entry<String,SolrInputField>>` `entrySet()`
`SolrInputField` `get(Object key)`
`float` `getDocumentBoost()`
`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` `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` `setDocumentBoost(float documentBoost)`
`void` `setField(String name, Object value)` Set a field with implied null value for boost.
`void` `setField(String name, Object value, float boost)`
`int` `size()`
`String` `toString()`
`Collection<SolrInputField>` `values()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface java.util.Map

`equals, hashCode`

### Constructor Detail

#### SolrInputDocument

    public SolrInputDocument()

#### SolrInputDocument

    public SolrInputDocument(Map<String,SolrInputField> fields)

### Method Detail

#### clear

    public void clear()

Remove all fields and boosts from the document

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

#### addField

    public void addField(String name,
                Object value)

Add a field with implied null value for boost. 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.

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.
See Also:
  `addField(String, Object, float)`

#### getFieldValue

    public Object getFieldValue(String name)

Get the first value for a field.

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.

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.

Returns:
  Set of all field names.

#### setField

    public void setField(String name,
                Object value)

Set a field with implied null value for boost.

Parameters:
  `name` - name of the field to set
  `value` - value of the field
See Also:
  `setField(String, Object, float)`

#### setField

    public void setField(String name,
                Object value,
                float boost)

#### addField

    public void addField(String name,
                Object value,
                float boost)

Adds a field with the given name, value and boost. If a field with the name already exists, then the given value is appended to the value of that field, with the new boost. If the value is a collection, then each of its values will be added to the field. 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.

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.
  `boost` - Boost value for 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>`

#### getDocumentBoost

    public float getDocumentBoost()

#### setDocumentBoost

    public void setDocumentBoost(float documentBoost)

#### 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>`