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 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 documentboolean
containsKey(Object key)
boolean
containsValue(Object value)
SolrInputDocument
deepCopy()
Set<Map.Entry<String,SolrInputField>>
entrySet()
SolrInputField
get(Object key)
int
getChildDocumentCount()
Deprecated.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 documentvoid
setField(String name, Object value)
Set a field value; replacing the existing value if present.int
size()
String
toString()
Collection<SolrInputField>
values()
void
visitSelfAndNestedDocs(BiConsumer<String,SolrInputDocument> consumer)
Beta API; may change at will.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.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:
writeMap
in interfaceMapWriter
- Throws:
IOException
-
clear
public void clear()
Remove all fields from the document- Specified by:
clear
in 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:
addField
in 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:
getFieldValue
in 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:
getFieldValues
in 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:
getFieldNames
in 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:
setField
in 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
, ornull
if there was no field forkey
.
-
getField
public SolrInputField getField(String field)
-
iterator
public Iterator<SolrInputField> iterator()
- Specified by:
iterator
in interfaceIterable<SolrInputField>
-
deepCopy
public SolrInputDocument deepCopy()
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interfaceMap<String,SolrInputField>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in interfaceMap<String,SolrInputField>
-
entrySet
public Set<Map.Entry<String,SolrInputField>> entrySet()
- Specified by:
entrySet
in interfaceMap<String,SolrInputField>
-
get
public SolrInputField get(Object key)
- Specified by:
get
in interfaceMap<String,SolrInputField>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceMap<String,SolrInputField>
-
put
public SolrInputField put(String key, SolrInputField value)
- Specified by:
put
in interfaceMap<String,SolrInputField>
-
putAll
public void putAll(Map<? extends String,? extends SolrInputField> t)
- Specified by:
putAll
in interfaceMap<String,SolrInputField>
-
remove
public SolrInputField remove(Object key)
- Specified by:
remove
in interfaceMap<String,SolrInputField>
-
size
public int size()
- Specified by:
size
in interfaceMap<String,SolrInputField>
-
values
public Collection<SolrInputField> values()
- Specified by:
values
in interfaceMap<String,SolrInputField>
-
addChildDocument
public void addChildDocument(SolrInputDocument child)
- Specified by:
addChildDocument
in classSolrDocumentBase<SolrInputField,SolrInputDocument>
-
addChildDocuments
public void addChildDocuments(Collection<SolrInputDocument> children)
- Specified by:
addChildDocuments
in 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:
getChildDocuments
in classSolrDocumentBase<SolrInputField,SolrInputDocument>
-
hasChildDocuments
public boolean hasChildDocuments()
Description copied from class:SolrDocumentBase
Has anonymous children?- Specified by:
hasChildDocuments
in classSolrDocumentBase<SolrInputField,SolrInputDocument>
-
getChildDocumentCount
@Deprecated public int getChildDocumentCount()
Deprecated.Description copied from class:SolrDocumentBase
The anonymous child document count.- Specified by:
getChildDocumentCount
in classSolrDocumentBase<SolrInputField,SolrInputDocument>
-
-