Class LuceneIndexExpressions
java.lang.Object
com.apple.foundationdb.record.lucene.LuceneIndexExpressions
The root expression of a
LUCENE
index specifies how select fields of a record are mapped to fields of a Lucene document.
The expression tree is made up of the following.
Structure
concat
includes multiple subexpressions in the index. Since these are flattened, order does not really matter.nest
traverses a nested subrecord. By default, the name of the parent field is prepended to the names of descendent fields.
Fields
field
is a record field whose value is added to the index. By default, a field is indexed as a scalar value. That is, even a string with whitespace is a single token.function(lucene_text)
annotates a document field as text so that it is tokenized in the Lucene index.function(lucene_stored)
annotates a document field as additionally stored in the document so that its value is returned in searches.
Names
By default, the name of each field in the hierarchy of nested subrecords is included in the name of flattened fields.
function(lucene_field_name)
overrides this.
value(null)
skips adding any name prefix, introducing the possibility of flattened name collisions.field(key)
allows another field to give the name. This is useful for map-like nested subrecords with well-known keys.
The expression tree can be walked in several different ways, either with an actual record to produce actual fields, or with record meta-data to determine what possible fields there are. Specifically,
- map a record into a document
- get a list of document field names
- validate the index expression at definition time
- compute correlated matching expressions for the query planner
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
An actual document / document meta-data.static class
Information about how a document field is derived from a record field.static enum
Possible types for document fields.static interface
An actual record / record meta-data. -
Method Summary
Modifier and TypeMethodDescriptionconstructPointConfigMap
(FDBRecordStoreBase<?> store, Index index) Constructs a point-config map for a givenIndex
fields.getDocumentFieldDerivations
(KeyExpression root, Descriptors.Descriptor recordType) Get the derivations of known document fields.getDocumentFieldDerivations
(Index index, RecordMetaData metadata) static <T extends LuceneIndexExpressions.RecordSource<T>>
voidgetFields
(KeyExpression root, T source, LuceneIndexExpressions.DocumentDestination<T> destination, String fieldNamePrefix) Interpret the index key expression, either concretely for an actual record, or symbolically using meta-data.static <T extends LuceneIndexExpressions.RecordSource<T>>
voidgetFieldsRecursively
(KeyExpression expression, T source, LuceneIndexExpressions.DocumentDestination<T> destination, String fieldNamePrefix, int keyIndex, int groupingCount, List<Integer> overriddenKeyRanges) static void
validate
(KeyExpression root, Descriptors.Descriptor recordType) Validate this key expression by interpreting it against the given meta-data.
-
Method Details
-
validate
public static void validate(@Nonnull KeyExpression root, @Nonnull Descriptors.Descriptor recordType) Validate this key expression by interpreting it against the given meta-data.- Parameters:
root
- theLUCENE
index root expresisonrecordType
- Protobuf meta-data for record type
-
getDocumentFieldDerivations
@Nonnull public static Map<String,LuceneIndexExpressions.DocumentFieldDerivation> getDocumentFieldDerivations(@Nonnull Index index, @Nonnull RecordMetaData metadata) -
getDocumentFieldDerivations
public static Map<String,LuceneIndexExpressions.DocumentFieldDerivation> getDocumentFieldDerivations(@Nonnull KeyExpression root, @Nonnull Descriptors.Descriptor recordType) Get the derivations of known document fields.- Parameters:
root
- theLUCENE
index root expressionrecordType
- Protobuf meta-data for record type- Returns:
- a map of document field names to
LuceneIndexExpressions.DocumentFieldDerivation
-
constructPointConfigMap
@Nonnull public static Map<String,org.apache.lucene.queryparser.flexible.standard.config.PointsConfig> constructPointConfigMap(@Nonnull FDBRecordStoreBase<?> store, @Nonnull Index index) Constructs a point-config map for a givenIndex
fields.- Parameters:
store
- The record store, used to retrieve metadata.index
- The index.- Returns:
- a mapping between an index field name and its
PointsConfig
.
-
getFields
@Nonnull public static <T extends LuceneIndexExpressions.RecordSource<T>> void getFields(@Nonnull KeyExpression root, @Nonnull T source, @Nonnull LuceneIndexExpressions.DocumentDestination<T> destination, @Nullable String fieldNamePrefix) Interpret the index key expression, either concretely for an actual record, or symbolically using meta-data.- Type Parameters:
T
- specific kind ofLuceneIndexExpressions.RecordSource
- Parameters:
root
- theLUCENE
index root expresisonsource
- the record / record meta-datadestination
- the document / document meta-datafieldNamePrefix
- prefix for generated field names
-
getFieldsRecursively
public static <T extends LuceneIndexExpressions.RecordSource<T>> void getFieldsRecursively(@Nonnull KeyExpression expression, @Nonnull T source, @Nonnull LuceneIndexExpressions.DocumentDestination<T> destination, @Nullable String fieldNamePrefix, int keyIndex, int groupingCount, @Nonnull List<Integer> overriddenKeyRanges)
-