org.apache.solr.common
Class SolrDocument

java.lang.Object
  extended by org.apache.solr.common.SolrDocument
All Implemented Interfaces:
Serializable, Iterable<Map.Entry<String,Object>>

public class SolrDocument
extends Object
implements Serializable, 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
Version:
$Id: SolrDocument.java 683248 2008-08-06 12:26:49Z yonik $
See Also:
Serialized Form

Constructor Summary
SolrDocument()
           
 
Method Summary
 void addField(String name, Object value)
          This will add a field to the document.
 void clear()
          Remove all fields from the document
 Collection<String> getFieldNames()
           
 Object getFieldValue(String name)
          Get the value or collection of values for a given field.
 Map<String,Object> getFieldValueMap()
          Expose a Map interface to the solr fields.
 Collection<Object> getFieldValues(String name)
          Get a collection of values for a given field name
 Map<String,Collection<Object>> getFieldValuesMap()
          Expose a Map interface to the solr field value collection.
 Object getFirstValue(String name)
          returns the first value for a field
 Iterator<Map.Entry<String,Object>> iterator()
          Iterate of String->Object keys
 boolean removeFields(String name)
          Remove all fields with the name
 void setField(String name, Object value)
          Set a field with the given object.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SolrDocument

public SolrDocument()
Method Detail

getFieldNames

public Collection<String> getFieldNames()
Returns:
a list of fields defined in this document

clear

public void clear()
Remove all fields from the document


removeFields

public boolean removeFields(String name)
Remove all fields with the name


setField

public void setField(String name,
                     Object value)
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


addField

public void addField(String name,
                     Object value)
This will add a field to the document. If fields already exist with this name it will append the collection


getFirstValue

public Object getFirstValue(String name)
returns the first value for a field


getFieldValue

public Object getFieldValue(String name)
Get the value or collection of values for a given field.


getFieldValues

public Collection<Object> getFieldValues(String name)
Get a collection of values for a given field name


toString

public String toString()
Overrides:
toString in class Object

iterator

public Iterator<Map.Entry<String,Object>> iterator()
Iterate of String->Object keys

Specified by:
iterator in interface Iterable<Map.Entry<String,Object>>

getFieldValuesMap

public Map<String,Collection<Object>> getFieldValuesMap()
Expose a Map interface to the solr field value collection.


getFieldValueMap

public Map<String,Object> getFieldValueMap()
Expose a Map interface to the solr fields. This function is useful for JSTL



Copyright © 2008 Apache Software Foundation. All Rights Reserved.