Class ReferenceFieldValue
- All Implemented Interfaces:
Cloneable
,Comparable<FieldValue>
A reference field value allows search queries to access fields in other document instances as if they were fields natively stored within the searched document. This allows modelling one-to-many relations such as a parent document with many children containing references back to the parent.
Each ReferenceFieldValue
may contain a single document ID which specifies the
instance the field should refer to. This document ID must have a type matching that of the
reference data type of the field itself.
Note that references are not polymorphic. This means that if you have a document type
"foo" inheriting "bar", you cannot have a reference<bar>
field containing
a document ID for a "foo" document.
- Author:
- vekterli
-
Field Summary
-
Constructor Summary
ConstructorDescriptionReferenceFieldValue
(ReferenceDataType referenceType) Creates an empty reference of the provided reference type.ReferenceFieldValue
(ReferenceDataType referenceType, DocumentId documentId) Creates a reference pointing to a particular document instance in the document type referenced byreferenceType
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Assign this non-fieldvalue value to this field value.void
clear()
static ReferenceFieldValue
createEmptyWithType
(ReferenceDataType referenceType) void
deserialize
(Field field, FieldReader reader) Read a field value from the specified readerboolean
Expose target document ID as this value's wrapped value.int
hashCode()
void
void
serialize
(Field field, FieldWriter writer) Write out field value to the specified writervoid
setDocumentId
(DocumentId documentId) toString()
Methods inherited from class com.yahoo.document.datatypes.FieldValue
clone, compareTo, create, deserialize, getRecursiveValue, getRecursiveValue, onDeserialize, onSerialize, serialize, toXml
Methods inherited from class com.yahoo.vespa.objects.Identifiable
create, createFromId, deserialize, deserializeOptional, deserializeWithId, equals, getClassId, getRawUtf8Bytes, getUtf8, onGetClassId, putUtf8, registerClass, serialize, serializeOptional, serializeWithId, visitMembers
Methods inherited from class com.yahoo.vespa.objects.Selectable
select, select, selectMembers
-
Field Details
-
classId
public static final int classId
-
-
Constructor Details
-
ReferenceFieldValue
Creates an empty reference of the provided reference type.- Parameters:
referenceType
- reference target type
-
ReferenceFieldValue
Creates a reference pointing to a particular document instance in the document type referenced byreferenceType
.- Parameters:
referenceType
- reference target typedocumentId
- document ID of the same document type as that given byreferenceType
- Throws:
IllegalArgumentException
- if documentId is not of the expected document type
-
-
Method Details
-
createEmptyWithType
-
getDataType
- Specified by:
getDataType
in classFieldValue
-
getDocumentId
-
setDocumentId
-
printXml
- Specified by:
printXml
in classFieldValue
-
clear
public void clear()- Specified by:
clear
in classFieldValue
-
assign
Description copied from class:FieldValue
Assign this non-fieldvalue value to this field value. This is used to be able to assign ints to Integer field values and List to Array field values and such.Override to accept the specific types that should be legal.
- Specified by:
assign
in classFieldValue
-
equals
- Overrides:
equals
in classcom.yahoo.vespa.objects.Identifiable
-
hashCode
public int hashCode()- Overrides:
hashCode
in classcom.yahoo.vespa.objects.Identifiable
-
serialize
Description copied from class:FieldValue
Write out field value to the specified writer- Specified by:
serialize
in classFieldValue
-
deserialize
Description copied from class:FieldValue
Read a field value from the specified reader- Specified by:
deserialize
in classFieldValue
-
getWrappedValue
Expose target document ID as this value's wrapped value. Primarily implemented to allow for transparent interoperability when used in concrete document types.- Overrides:
getWrappedValue
in classFieldValue
- Returns:
- reference DocumentId, or null if none has been set
-
toString
- Overrides:
toString
in classcom.yahoo.vespa.objects.Identifiable
-