Package com.attivio.sdk.search
Class SearchDocument
- java.lang.Object
-
- com.attivio.sdk.search.SearchDocument
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,java.lang.Cloneable,java.lang.Iterable<SearchField>
public class SearchDocument extends java.lang.Object implements java.lang.Iterable<SearchField>, java.lang.Cloneable, java.io.Externalizable
A document returned from a search.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SearchDocument()Construct a new SearchDocument.SearchDocument(java.lang.String id)Construct a new SearchDocument with anid.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChildDocument(SearchDocument value)Add a child document.voidaddValue(java.lang.String field, Point value)Add aPointvalue tofield.voidaddValue(java.lang.String field, Shape value)Add aShapevalue tofield.voidaddValue(java.lang.String field, SearchFieldValue value)Add avaluetofield.voidaddValue(java.lang.String field, java.lang.Boolean value)Add aBooleanvalue tofield.voidaddValue(java.lang.String field, java.lang.Number value)Add anumericvalue tofield.voidaddValue(java.lang.String field, java.lang.String value)Add aStringvalue tofield.voidaddValue(java.lang.String field, java.util.Date value)Add aDatevalue tofield.voidaddValues(java.lang.String field, Point... values)voidaddValues(java.lang.String field, Shape... values)voidaddValues(java.lang.String field, java.lang.Boolean... values)AddBooleanvaluestofield.voidaddValues(java.lang.String field, java.lang.Number... values)Addnumericvaluestofield.voidaddValues(java.lang.String field, java.lang.String... values)AddStringvaluestofield.voidaddValues(java.lang.String field, java.util.Date... values)AddDatevaluestofield.voidclear()Remove all fields and child documents.SearchDocumentclone()booleancontainsChildDocuments()Get if this document contains child records.booleancontainsField(java.lang.String field)Get if this document containsfield.booleanequals(java.lang.Object other)voidforEach(java.util.function.Consumer<? super SearchField> consumer)SearchDocumentgetChildDocument(int index)Get a child document byindex.intgetChildDocumentCount()Get the number of attached child documents.java.lang.Iterable<SearchDocument>getChildDocuments()Get all of the available child documents.RelevancyFeatureVectorgetFeatures()Get the feature vector for relevancy components.SearchFieldgetField(java.lang.String field)Get afieldor null iffielddoes not exist.java.lang.Iterable<java.lang.String>getFieldNames()Return anIterablefor iterating over all unique field names.SearchFieldValuegetFirstValue(java.lang.String field)Get the firstSearchFieldValueforfieldor null if the field does not exist.java.lang.StringgetId()The unique document id.floatgetScore()Get the document's score.longgetTotalChildren()Get the total number of child documents available or-1if this count is not known or was not calculated.java.lang.StringgetZone()Get the zone this document is ininthashCode()java.util.Iterator<SearchField>iterator()Get an iterator for iterating over allfields.voidreadExternal(java.io.ObjectInput in)voidremoveField(java.lang.String field)Remove afieldfrom the document.voidrenameField(java.lang.String oldName, java.lang.String newName)Rename a field.voidsetChildDocuments(SearchDocument... value)Set the child documents.voidsetChildDocuments(java.lang.Iterable<SearchDocument> value)Set the child documents.voidsetFeatures(RelevancyFeatureVector value)Set the feature vector for relevancy components.voidsetField(SearchField field)Set afieldfor this document.voidsetTotalChildren(long value)Set the total number of child documents available.intsize()Get the number of fields in this document.java.lang.StringtoString()protected voidtoString(java.lang.StringBuilder buffer, int depth)voidwriteExternal(java.io.ObjectOutput out)
-
-
-
Method Detail
-
getId
public java.lang.String getId()
The unique document id.NOTE: the document id may not be populated for SearchDocuments if not requested. If not populated, an empty string will be returned.
-
getZone
public java.lang.String getZone()
Get the zone this document is inNOTE: the zone name may not be populated for SearchDocuments if not requested. If not populated, null will be returned.
-
getFeatures
public RelevancyFeatureVector getFeatures()
Get the feature vector for relevancy components.
-
setFeatures
public void setFeatures(RelevancyFeatureVector value)
Set the feature vector for relevancy components.
-
getScore
public float getScore()
Get the document's score.NOTE: May return
0.0fif no score was computed, or if score was requested with custom field name.- Throws:
java.lang.IllegalArgumentException- if field namedFieldNames.SCOREcontains non-numeric values.
-
size
public int size()
Get the number of fields in this document.
-
getFieldNames
public java.lang.Iterable<java.lang.String> getFieldNames()
Return anIterablefor iterating over all unique field names.
-
iterator
public java.util.Iterator<SearchField> iterator()
Get an iterator for iterating over allfields.- Specified by:
iteratorin interfacejava.lang.Iterable<SearchField>
-
forEach
public void forEach(java.util.function.Consumer<? super SearchField> consumer)
- Specified by:
forEachin interfacejava.lang.Iterable<SearchField>
-
containsField
public boolean containsField(java.lang.String field)
Get if this document containsfield.
-
getField
public SearchField getField(java.lang.String field)
Get afieldor null iffielddoes not exist.NOTE: if the field exists, but contains no field values,
nullwill be returned.
-
setField
public void setField(SearchField field)
Set afieldfor this document.If a field already exists with the same name, it will be replaced.
-
getFirstValue
public SearchFieldValue getFirstValue(java.lang.String field)
Get the firstSearchFieldValueforfieldor null if the field does not exist.
-
renameField
public void renameField(java.lang.String oldName, java.lang.String newName)Rename a field.If the field does not exist no action is taken.
-
removeField
public void removeField(java.lang.String field)
Remove afieldfrom the document.
-
clear
public void clear()
Remove all fields and child documents.
-
addValues
public void addValues(java.lang.String field, java.lang.String... values)AddStringvaluestofield.
-
addValues
public void addValues(java.lang.String field, java.lang.Number... values)Addnumericvaluestofield.
-
addValues
public void addValues(java.lang.String field, java.util.Date... values)AddDatevaluestofield.
-
addValues
public void addValues(java.lang.String field, java.lang.Boolean... values)AddBooleanvaluestofield.
-
addValues
public void addValues(java.lang.String field, Point... values)
-
addValues
public void addValues(java.lang.String field, Shape... values)
-
addValue
public void addValue(java.lang.String field, SearchFieldValue value)Add avaluetofield.
-
addValue
public void addValue(java.lang.String field, java.lang.String value)Add aStringvalue tofield.
-
addValue
public void addValue(java.lang.String field, java.lang.Number value)Add anumericvalue tofield.
-
addValue
public void addValue(java.lang.String field, java.util.Date value)Add aDatevalue tofield.
-
addValue
public void addValue(java.lang.String field, java.lang.Boolean value)Add aBooleanvalue tofield.
-
getTotalChildren
public long getTotalChildren()
Get the total number of child documents available or-1if this count is not known or was not calculated.NOTE: the is the total number of possible child documents. Use
getChildDocumentCount()to get the actual number of child documents returned with this SearchDocument.
-
setTotalChildren
public void setTotalChildren(long value)
Set the total number of child documents available.
-
containsChildDocuments
public boolean containsChildDocuments()
Get if this document contains child records.
-
getChildDocumentCount
public int getChildDocumentCount()
Get the number of attached child documents.
-
getChildDocument
public SearchDocument getChildDocument(int index)
Get a child document byindex.- Throws:
java.lang.IndexOutOfBoundsException- if child document atindexis not available.
-
getChildDocuments
public java.lang.Iterable<SearchDocument> getChildDocuments()
Get all of the available child documents.
-
setChildDocuments
public void setChildDocuments(SearchDocument... value)
Set the child documents.
-
setChildDocuments
public void setChildDocuments(java.lang.Iterable<SearchDocument> value)
Set the child documents.
-
addChildDocument
public void addChildDocument(SearchDocument value)
Add a child document.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toString
protected void toString(java.lang.StringBuilder buffer, int depth)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
clone
public SearchDocument clone()
- Overrides:
clonein classjava.lang.Object
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException- Specified by:
readExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
writeExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException
-
-