Class IndexingMetadata
- java.lang.Object
-
- org.infinispan.query.remote.impl.indexing.IndexingMetadata
-
public final class IndexingMetadata extends Object
All fields of Protobuf types are indexed and stored by default if no indexing annotations are present. This behaviour exists only for compatibility with first release of remote query; it is deprecated and will be removed in Infinispan 10.0 (the lack of annotations on your message/field definition will imply no indexing support in this future release, but you will still be able to perform unindexed query). Indexing all fields is sometimes acceptable but it can become a performance problem if there are many or very large fields. To avoid such problems Infinispan allows and encourages you to specify which fields to index and store by means of two annotations (@Indexed and @Field) that behave very similarly to the identically named Hibernate Search annotations and which can be directly added to your Protobuf schema files in the documentation comments of your message type definitions as demonstrated in the example below: Example:/** * This message type is indexed, but not all of its fields are. *@Indexed */ message Note { /** * This field is indexed and analyzed but not stored. It can be full-text queried but cannot be used for projections. *@Field(index=Index.YES, store=Store.NO, analyze=Analyze.YES) */ optional string text = 1; /** * A field that is both indexed and stored but not analyzed (the defaults - if no attributes are specified). It can be * queried with relational operators but not with full-text operators (since it is not analyzed). *@Field */ optional string author = 2; /** @Field(index=Index.NO, store=Store.YES) */ optional bool isRead = 3; /** This field is not annotated, so it is neither indexed nor stored. */ optional int32 priority = 4; }Documentation annotations can be added after the human-readable text on the last lines of the documentation comment that precedes the element to be annotated (a message type definition or a field definition). The syntax for defining these pseudo-annotations is identical to the one use by the Java language.
The '@Indexed' annotation applies to message types only. The presence of this annotation indicates the type is to be indexed and we intend to selectively specify which of the fields of this message type are to be indexed. To turn off indexing for a type just do not add '@Indexed to its definition. The @Indexed annotation has an optional 'index' attribute which allow you to specify the name of the index for this message type. If left unspecified it defaults to the fully qualified type name.
The '@Field' annotation applies to fields only and has three attributes, 'index', 'store' and 'analyze', which default to @Field(index=Index.YES, store=Store.NO, analyze=Analyze.NO). The 'index' attribute indicates whether the field will be indexed, so it can be used for indexed queries, while the 'store' attribute indicates whether the field value is to be stored in the index too, so it becomes useable for projections. The analyze attribute control analysis. Analyzing must be turned on in order to use the field in full-text searches.
The '@Analyzer' annotation applies to messages and fields and allows you to specify which analyzer to use if analysis was enabled. If has a single attribute name 'definition' which must contain a valid analyzer definition name specified as a String.
NOTE:
- 1. The @Field and @Analyzer annotations have effect only if the containing message type was annotated as '@Indexed' or '@Indexed(true)', otherwise they are ignored.
- 2. Unindexed fields can still be queried in non-indexed mode or with hybrid queries.
- Since:
- 7.0
- Author:
- anistor@redhat.com
-
-
Field Summary
Fields Modifier and Type Field Description static StringANALYZE_NOstatic StringANALYZE_YESstatic StringANALYZER_ANNOTATIONSimilar to org.hibernate.search.annotations.Analyzer.static StringANALYZER_DEFINITION_ATTRIBUTEstatic StringDO_NOT_INDEX_NULLA marker value that indicates nulls should not be indexed.static StringFIELD_ANALYZE_ATTRIBUTEstatic StringFIELD_ANALYZER_ATTRIBUTEstatic StringFIELD_ANNOTATIONstatic StringFIELD_INDEX_ATTRIBUTEstatic StringFIELD_INDEX_NULL_AS_ATTRIBUTEstatic StringFIELD_NAME_ATTRIBUTEstatic StringFIELD_STORE_ATTRIBUTEstatic StringFIELDS_ANNOTATIONSimilar to org.hibernate.search.annotations.Fields/Field.static StringINDEX_NOstatic StringINDEX_YESstatic StringINDEXED_ANNOTATIONSimilar to org.hibernate.search.annotations.Indexed.static StringINDEXED_INDEX_ATTRIBUTEstatic StringSORTABLE_FIELD_ANNOTATIONstatic StringSORTABLE_FIELDS_ANNOTATIONstatic StringSTORE_NOstatic StringSTORE_YES
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringanalyzer()static voidconfigure(org.infinispan.protostream.config.Configuration.Builder builder)FieldMappinggetFieldMapping(String name)ObjectgetNullMarker(String fieldName)Set<String>getSortableFields()StringindexName()booleanisFieldAnalyzed(String fieldName)booleanisFieldIndexed(String fieldName)booleanisFieldStored(String fieldName)booleanisIndexed()StringtoString()
-
-
-
Field Detail
-
INDEXED_ANNOTATION
public static final String INDEXED_ANNOTATION
Similar to org.hibernate.search.annotations.Indexed. Indicates if a type will be indexed or not. Has just two attributes:- 'index' - the name of the index; if unspecified it defaults to the fully qualified type name
- 'value' - a boolean that indicates if this type is indexed; defaults to
true; this attribute is deprecated and will be removed in Infinispan 10.0. It can be used to turn off indexing but the preferred way to turn off indexing after Infinispan 10.0 will be to just remove the @Indexed annotation completely.
- See Also:
- Constant Field Values
-
INDEXED_INDEX_ATTRIBUTE
public static final String INDEXED_INDEX_ATTRIBUTE
- See Also:
- Constant Field Values
-
FIELDS_ANNOTATION
public static final String FIELDS_ANNOTATION
Similar to org.hibernate.search.annotations.Fields/Field.- See Also:
- Constant Field Values
-
FIELD_ANNOTATION
public static final String FIELD_ANNOTATION
- See Also:
- Constant Field Values
-
FIELD_NAME_ATTRIBUTE
public static final String FIELD_NAME_ATTRIBUTE
- See Also:
- Constant Field Values
-
FIELD_INDEX_ATTRIBUTE
public static final String FIELD_INDEX_ATTRIBUTE
- See Also:
- Constant Field Values
-
FIELD_ANALYZE_ATTRIBUTE
public static final String FIELD_ANALYZE_ATTRIBUTE
- See Also:
- Constant Field Values
-
FIELD_STORE_ATTRIBUTE
public static final String FIELD_STORE_ATTRIBUTE
- See Also:
- Constant Field Values
-
FIELD_ANALYZER_ATTRIBUTE
public static final String FIELD_ANALYZER_ATTRIBUTE
- See Also:
- Constant Field Values
-
FIELD_INDEX_NULL_AS_ATTRIBUTE
public static final String FIELD_INDEX_NULL_AS_ATTRIBUTE
- See Also:
- Constant Field Values
-
INDEX_YES
public static final String INDEX_YES
- See Also:
- Constant Field Values
-
INDEX_NO
public static final String INDEX_NO
- See Also:
- Constant Field Values
-
ANALYZE_YES
public static final String ANALYZE_YES
- See Also:
- Constant Field Values
-
ANALYZE_NO
public static final String ANALYZE_NO
- See Also:
- Constant Field Values
-
STORE_YES
public static final String STORE_YES
- See Also:
- Constant Field Values
-
STORE_NO
public static final String STORE_NO
- See Also:
- Constant Field Values
-
DO_NOT_INDEX_NULL
public static final String DO_NOT_INDEX_NULL
A marker value that indicates nulls should not be indexed.- See Also:
- Constant Field Values
-
ANALYZER_ANNOTATION
public static final String ANALYZER_ANNOTATION
Similar to org.hibernate.search.annotations.Analyzer. Can be placed at both message and field level.- See Also:
- Constant Field Values
-
ANALYZER_DEFINITION_ATTRIBUTE
public static final String ANALYZER_DEFINITION_ATTRIBUTE
- See Also:
- Constant Field Values
-
SORTABLE_FIELD_ANNOTATION
public static final String SORTABLE_FIELD_ANNOTATION
- See Also:
- Constant Field Values
-
SORTABLE_FIELDS_ANNOTATION
public static final String SORTABLE_FIELDS_ANNOTATION
- See Also:
- Constant Field Values
-
-
Method Detail
-
isIndexed
public boolean isIndexed()
-
indexName
public String indexName()
-
analyzer
public String analyzer()
-
isFieldIndexed
public boolean isFieldIndexed(String fieldName)
-
isFieldAnalyzed
public boolean isFieldAnalyzed(String fieldName)
-
isFieldStored
public boolean isFieldStored(String fieldName)
-
getFieldMapping
public FieldMapping getFieldMapping(String name)
-
configure
public static void configure(org.infinispan.protostream.config.Configuration.Builder builder)
-
-