Class 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
      • 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)
        • getNullMarker

          public Object getNullMarker​(String fieldName)
        • getSortableFields

          public Set<String> getSortableFields()
        • configure

          public static void configure​(org.infinispan.protostream.config.Configuration.Builder builder)