Class IndexedField<I,T>
- Type Parameters:
I
- input type from which documents are created and search results are returned.T
- type that should be extracted from the input object when converting to an index document.
Each IndexedField, stored in index, may have multiple IndexedField<I,
which defines how it
can be searched and how the index tokens are generated.
Index implementations may choose to store IndexedField and IndexedField<I,
(search tokens)
separately, however IndexedQuery
always issues the queries
to IndexedField<I,
.
This allows index implementations to store IndexedField once, while enabling multiple
tokenization strategies on the same IndexedField with IndexedField<I,
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A builder forIndexedField
.class
Defines howIndexedField
can be searched and how the index tokens are generated. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.google.common.reflect.TypeToken<byte[]>
static final com.google.common.reflect.TypeToken<Integer>
static final com.google.common.reflect.TypeToken<Iterable<byte[]>>
static final com.google.common.reflect.TypeToken<Long>
static final com.google.common.reflect.TypeToken<String>
static final com.google.common.reflect.TypeToken<Timestamp>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddSearchSpec
(String name, SearchOption searchOption) AddsIndexedField<I,
to thisT>.SearchSpec IndexedField
static <I,
T> IndexedField.Builder<I, T> static <I> IndexedField.Builder<I,
byte[]> byteArrayBuilder
(String name) Optional description of the field data.abstract Optional<SchemaFieldDefs.Setter<I,
T>> abstract com.google.common.reflect.TypeToken<T>
TheTypeToken
describing the contents of the field.Get the field contents from the input object.com.google.common.collect.ImmutableMap<String,
IndexedField<I, T>.SearchSpec> Returns allIndexedField<I,
, enabled on this field.T>.SearchSpec abstract SchemaFieldDefs.Getter<I,
T> getter()
static <I> IndexedField.Builder<I,
Integer> integerBuilder
(String name) integerRange
(String name) boolean
Returns true if thefieldType()
is a list of proto messages.boolean
Returns true if thefieldType()
is a proto message.static <I> IndexedField.Builder<I,
Iterable<byte[]>> static <I> IndexedField.Builder<I,
Iterable<Integer>> iterableIntegerBuilder
(String name) static <I> IndexedField.Builder<I,
Iterable<String>> iterableStringBuilder
(String name) static <I> IndexedField.Builder<I,
Long> longBuilder
(String name) longSearch
(String name) abstract String
name()
The name to store this field under.abstract Optional<ProtoConverter<? extends com.google.protobuf.MessageLite,
?>> If thefieldType()
is proto, the converter to use on byte/proto conversions.abstract boolean
True if this field is repeatable.abstract boolean
required()
True if this field is mandatory.boolean
setIfPossible
(I object, StoredValue doc) size()
Optional size constrain on the field.abstract boolean
stored()
Allow reading the actual data from the index.storedOnly
(String name) static <I> IndexedField.Builder<I,
String> stringBuilder
(String name) static <I> IndexedField.Builder<I,
Timestamp> timestampBuilder
(String name)
-
Field Details
-
INTEGER_TYPE
-
ITERABLE_INTEGER_TYPE
-
LONG_TYPE
-
ITERABLE_LONG_TYPE
-
STRING_TYPE
-
ITERABLE_STRING_TYPE
-
BYTE_ARRAY_TYPE
public static final com.google.common.reflect.TypeToken<byte[]> BYTE_ARRAY_TYPE -
ITERABLE_BYTE_ARRAY_TYPE
-
TIMESTAMP_TYPE
-
-
Constructor Details
-
IndexedField
public IndexedField()
-
-
Method Details
-
builder
public static <I,T> IndexedField.Builder<I,T> builder(String name, com.google.common.reflect.TypeToken<T> fieldType) -
iterableStringBuilder
-
stringBuilder
-
integerBuilder
-
longBuilder
-
iterableIntegerBuilder
-
timestampBuilder
-
byteArrayBuilder
-
iterableByteArrayBuilder
-
addSearchSpec
AddsIndexedField<I,
to thisT>.SearchSpec IndexedField
- Parameters:
name
- the name to use for in the search.searchOption
- the tokenization option, enabled by the newIndexedField<I,
T>.SearchSpec - Returns:
- the added
IndexedField<I,
.T>.SearchSpec
-
exact
-
fullText
-
range
-
integerRange
-
integer
-
longSearch
-
prefix
-
storedOnly
-
timestamp
-
name
The name to store this field under.The name should use the UpperCamelCase format, see
IndexedField.Builder.checkName(java.lang.String)
. -
description
Optional description of the field data. -
required
public abstract boolean required()True if this field is mandatory. Default is false.This property is not enforced by the common indexing logic. It is up to the index implementations to enforce that the field is required.
-
stored
public abstract boolean stored()Allow reading the actual data from the index. Default is false. -
repeatable
public abstract boolean repeatable()True if this field is repeatable. -
size
Optional size constrain on the field. The size is not constrained if this property isOptional.empty()
This property is not enforced by the common indexing logic. It is up to the index implementations to enforce the size.
If the field is
repeatable()
, the constraint applies to each element separately. -
getter
-
fieldSetter
-
fieldType
TheTypeToken
describing the contents of the field. See static constants for the common supported types.- Returns:
TypeToken
of this field.
-
protoConverter
public abstract Optional<ProtoConverter<? extends com.google.protobuf.MessageLite,?>> protoConverter()If thefieldType()
is proto, the converter to use on byte/proto conversions. -
getSearchSpecs
Returns allIndexedField<I,
, enabled on this field.T>.SearchSpec Note: weather or not a search is supported by the index depends on
Schema
version. -
get
Get the field contents from the input object.- Parameters:
input
- input object.- Returns:
- the field value(s) to index.
-
setIfPossible
-
isProtoType
public boolean isProtoType()Returns true if thefieldType()
is a proto message. -
isProtoIterableType
public boolean isProtoIterableType()Returns true if thefieldType()
is a list of proto messages.
-