com.sun.labs.minion
Interface Document

All Known Implementing Classes:
DocumentImpl

public interface Document

A document abstraction for the search engine. This interface is meant to be used as a way for an application to retrieve (some) of the contents of a document out of the index, make some modifications to the index and then resubmit the document to the index.

Note that this representation of a document will contain only the fields that have the SAVED and VECTORED attributes set. Data that was indexed, but not vectored cannot be recovered for such a representation.

See Also:
SearchEngine.getDocument(java.lang.String), FieldInfo

Method Summary
 java.lang.String getKey()
          Gets the key associated with this document.
 java.util.Iterator<java.util.Map.Entry<java.lang.String,java.util.List<Posting>>> getPostings()
          Gets an iterator for the vectored fields in this document.
 java.util.List<Posting> getPostings(java.lang.String field)
          Gets the list of postings associated with a given field.
 java.util.List<java.lang.Object> getSavedField(java.lang.String field)
          Gets the values of a given saved field from the index.
 java.util.Iterator<java.util.Map.Entry<java.lang.String,java.util.List>> getSavedFields()
          Gets an iterator for all of the saved field values in a document.
 void setKey(java.lang.String key)
          Sets the key for this document.
 void setPostings(java.lang.String field, java.util.List<Posting> postings)
          Sets the list of postings associated with a given field.
 void setSavedField(java.lang.String field, java.util.List values)
          Sets the values of a saved field.
 

Method Detail

getKey

java.lang.String getKey()
Gets the key associated with this document.

Returns:
the key for this document.

setKey

void setKey(java.lang.String key)
Sets the key for this document. Note that this change does not affect the engine from which this document was drawn. If you change the key for a document you will need to resubmit the document for indexing. Note that if you change the key and reindex the document, you are responsible for deleting the document under it's old key! Note that the other methods for this class will continue to function, even if the document's key is changed using this method.

Parameters:
key - the key for the document

getSavedField

java.util.List<java.lang.Object> getSavedField(java.lang.String field)
Gets the values of a given saved field from the index.

Parameters:
field - the name of the saved field whose values should be retrieved.
Returns:
a list of the values for the saved field. If there are no values for the given saved field in this document, an empty list is returned.
Throws:
java.lang.IllegalArgumentException - if the given field is not the name of a saved field.

getSavedFields

java.util.Iterator<java.util.Map.Entry<java.lang.String,java.util.List>> getSavedFields()
Gets an iterator for all of the saved field values in a document.

Returns:
an iterator for all of the saved fields that occur in this document.

setSavedField

void setSavedField(java.lang.String field,
                   java.util.List values)
Sets the values of a saved field. Note that this will not affect the underlying index. If modifications are made to a document, the modified document must be re-submitted to the search engine for indexing.

Parameters:
field - the name of the saved field whose values should be set.
values - a list of values to assign to the saved field. These values should be of a type appropriate to the saved field.
Throws:
java.lang.IllegalArgumentException - if the named field is not a saved field.
See Also:
SearchEngine.index(Document)

getPostings

java.util.List<Posting> getPostings(java.lang.String field)
Gets the list of postings associated with a given field.

Parameters:
field - the name of a field that was indexed and vectored. If this value is null then the postings returned are for terms that were not added to any explicit field.
Returns:
the list of postings associated with the given field in this document
Throws:
java.lang.IllegalArgumentException - if the named field is not a vectored field.

getPostings

java.util.Iterator<java.util.Map.Entry<java.lang.String,java.util.List<Posting>>> getPostings()
Gets an iterator for the vectored fields in this document.

Returns:
an iterator for the vectored fields in this document.

setPostings

void setPostings(java.lang.String field,
                 java.util.List<Posting> postings)
Sets the list of postings associated with a given field. Note that this will not affect the underlying index. If modifications are made to a document, the modified document must be re-submitted to the search engine for indexing.

Parameters:
field - the name of the field whose postings should be modified. If this value is null then the postings will be used for the default unnamed field.
postings - a list of postings to associate with the field. If the named field has no postings for this field, then an empty list is returned.
Throws:
java.lang.IllegalArgumentException - if the named field is not a vectored field.