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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionReferenceFieldValue(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 TypeMethodDescriptionvoidAssign this non-fieldvalue value to this field value.voidclear()static ReferenceFieldValuecreateEmptyWithType(ReferenceDataType referenceType) voiddeserialize(Field field, FieldReader reader) Read a field value from the specified readerbooleanExpose target document ID as this value's wrapped value.inthashCode()voidDeprecated.voidserialize(Field field, FieldWriter writer) Write out field value to the specified writervoidsetDocumentId(DocumentId documentId) toString()Methods inherited from class com.yahoo.document.datatypes.FieldValue
clone, compareTo, create, deserialize, getRecursiveValue, getRecursiveValue, onDeserialize, onSerialize, serialize, toXmlMethods inherited from class com.yahoo.vespa.objects.Identifiable
create, createFromId, deserialize, deserializeOptional, deserializeWithId, equals, getClassId, getRawUtf8Bytes, getUtf8, onGetClassId, putUtf8, registerClass, registerClass, serialize, serializeOptional, serializeWithId, visitMembersMethods 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:
getDataTypein classFieldValue
-
getDocumentId
-
setDocumentId
-
printXml
Deprecated.- Specified by:
printXmlin classFieldValue
-
clear
public void clear()- Specified by:
clearin classFieldValue
-
assign
Description copied from class:FieldValueAssign 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:
assignin classFieldValue
-
equals
- Overrides:
equalsin classcom.yahoo.vespa.objects.Identifiable
-
hashCode
public int hashCode()- Overrides:
hashCodein classcom.yahoo.vespa.objects.Identifiable
-
serialize
Description copied from class:FieldValueWrite out field value to the specified writer- Specified by:
serializein classFieldValue
-
deserialize
Description copied from class:FieldValueRead a field value from the specified reader- Specified by:
deserializein 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:
getWrappedValuein classFieldValue- Returns:
- reference DocumentId, or null if none has been set
-
toString
- Overrides:
toStringin classcom.yahoo.vespa.objects.Identifiable
-