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 void
addChildDocument(SearchDocument value)
Add a child document.void
addValue(java.lang.String field, Point value)
Add aPoint
value tofield
.void
addValue(java.lang.String field, Shape value)
Add aShape
value tofield
.void
addValue(java.lang.String field, SearchFieldValue value)
Add avalue
tofield
.void
addValue(java.lang.String field, java.lang.Boolean value)
Add aBoolean
value tofield
.void
addValue(java.lang.String field, java.lang.Number value)
Add anumeric
value tofield
.void
addValue(java.lang.String field, java.lang.String value)
Add aString
value tofield
.void
addValue(java.lang.String field, java.util.Date value)
Add aDate
value tofield
.void
addValues(java.lang.String field, Point... values)
void
addValues(java.lang.String field, Shape... values)
void
addValues(java.lang.String field, java.lang.Boolean... values)
AddBoolean
values
tofield
.void
addValues(java.lang.String field, java.lang.Number... values)
Addnumeric
values
tofield
.void
addValues(java.lang.String field, java.lang.String... values)
AddString
values
tofield
.void
addValues(java.lang.String field, java.util.Date... values)
AddDate
values
tofield
.void
clear()
Remove all fields and child documents.SearchDocument
clone()
boolean
containsChildDocuments()
Get if this document contains child records.boolean
containsField(java.lang.String field)
Get if this document containsfield
.boolean
equals(java.lang.Object other)
void
forEach(java.util.function.Consumer<? super SearchField> consumer)
SearchDocument
getChildDocument(int index)
Get a child document byindex
.int
getChildDocumentCount()
Get the number of attached child documents.java.lang.Iterable<SearchDocument>
getChildDocuments()
Get all of the available child documents.RelevancyFeatureVector
getFeatures()
Get the feature vector for relevancy components.SearchField
getField(java.lang.String field)
Get afield
or null iffield
does not exist.java.lang.Iterable<java.lang.String>
getFieldNames()
Return anIterable
for iterating over all unique field names.SearchFieldValue
getFirstValue(java.lang.String field)
Get the firstSearchFieldValue
forfield
or null if the field does not exist.java.lang.String
getId()
The unique document id.float
getScore()
Get the document's score.long
getTotalChildren()
Get the total number of child documents available or-1
if this count is not known or was not calculated.java.lang.String
getZone()
Get the zone this document is inint
hashCode()
java.util.Iterator<SearchField>
iterator()
Get an iterator for iterating over allfields
.void
readExternal(java.io.ObjectInput in)
void
removeField(java.lang.String field)
Remove afield
from the document.void
renameField(java.lang.String oldName, java.lang.String newName)
Rename a field.void
setChildDocuments(SearchDocument... value)
Set the child documents.void
setChildDocuments(java.lang.Iterable<SearchDocument> value)
Set the child documents.void
setFeatures(RelevancyFeatureVector value)
Set the feature vector for relevancy components.void
setField(SearchField field)
Set afield
for this document.void
setTotalChildren(long value)
Set the total number of child documents available.int
size()
Get the number of fields in this document.java.lang.String
toString()
protected void
toString(java.lang.StringBuilder buffer, int depth)
void
writeExternal(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.0f
if no score was computed, or if score was requested with custom field name.- Throws:
java.lang.IllegalArgumentException
- if field namedFieldNames.SCORE
contains 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 anIterable
for iterating over all unique field names.
-
iterator
public java.util.Iterator<SearchField> iterator()
Get an iterator for iterating over allfields
.- Specified by:
iterator
in interfacejava.lang.Iterable<SearchField>
-
forEach
public void forEach(java.util.function.Consumer<? super SearchField> consumer)
- Specified by:
forEach
in 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 afield
or null iffield
does not exist.NOTE: if the field exists, but contains no field values,
null
will be returned.
-
setField
public void setField(SearchField field)
Set afield
for 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 firstSearchFieldValue
forfield
or 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 afield
from the document.
-
clear
public void clear()
Remove all fields and child documents.
-
addValues
public void addValues(java.lang.String field, java.lang.String... values)
AddString
values
tofield
.
-
addValues
public void addValues(java.lang.String field, java.lang.Number... values)
Addnumeric
values
tofield
.
-
addValues
public void addValues(java.lang.String field, java.util.Date... values)
AddDate
values
tofield
.
-
addValues
public void addValues(java.lang.String field, java.lang.Boolean... values)
AddBoolean
values
tofield
.
-
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 avalue
tofield
.
-
addValue
public void addValue(java.lang.String field, java.lang.String value)
Add aString
value tofield
.
-
addValue
public void addValue(java.lang.String field, java.lang.Number value)
Add anumeric
value tofield
.
-
addValue
public void addValue(java.lang.String field, java.util.Date value)
Add aDate
value tofield
.
-
addValue
public void addValue(java.lang.String field, java.lang.Boolean value)
Add aBoolean
value tofield
.
-
getTotalChildren
public long getTotalChildren()
Get the total number of child documents available or-1
if 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 atindex
is 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:
toString
in classjava.lang.Object
-
toString
protected void toString(java.lang.StringBuilder buffer, int depth)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
clone
public SearchDocument clone()
- Overrides:
clone
in classjava.lang.Object
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException
- Specified by:
readExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
- Specified by:
writeExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
-
-