@Documented @Target({METHOD,FIELD}) @Retention(RUNTIME) @Repeatable(List.class) @PropertyMapping(processor=@PropertyMappingAnnotationProcessorRef(type=org.hibernate.search.mapper.pojo.mapping.definition.annotation.processing.impl.KeywordFieldProcessor.class,retrieval=CONSTRUCTOR)) public @interface KeywordField
Maps a property to a keyword field in the index, holding a single token (word) of text.

On contrary to FullTextField, this annotation only creates non-tokenized (single-word) text fields. As a result:

  • The field value (the value of your annotated property, or at least the value produced by your custom value bridge must be of type String
  • You cannot assign an analyzer when using this annotation
  • You can, however, assign a normalizer (which is an analyzer that doesn't perform tokenization) when using this annotation
  • This annotation allows to make the field sortable

If you want to index a non-String value, use the GenericField annotation instead. If you want to index a String value, but want the field to be tokenized, use FullTextField instead.

  • Element Details

    • name

      String name
      Returns:
      The name of the index field.
      Default:
      ""
    • normalizer

      String normalizer
      Returns:
      A reference to the normalizer to use for this field. Defaults to an empty string, meaning no normalization at all. See the documentation of your backend to know how to define normalization.
      Default:
      ""
    • norms

      Norms norms
      Returns:
      Whether index time scoring information should be stored or not.
      See Also:
      Default:
      DEFAULT
    • projectable

      Projectable projectable
      Returns:
      Whether projections are enabled for this field.
      See Also:
      Default:
      DEFAULT
    • sortable

      Sortable sortable
      Returns:
      Whether this field should be sortable.
      See Also:
      Default:
      DEFAULT
    • searchable

      Searchable searchable
      Returns:
      Whether this field should be searchable.
      See Also:
      Default:
      DEFAULT
    • aggregable

      Aggregable aggregable
      Returns:
      Whether aggregations are enabled for this field.
      See Also:
      Default:
      DEFAULT
    • indexNullAs

      String indexNullAs
      Returns:
      A value used instead of null values when indexing.
      See Also:
      Default:
      "__HibernateSearch_indexNullAs_default"
    • valueBridge

      ValueBridgeRef valueBridge
      Returns:
      A reference to the value bridge to use for this field. Must not be set if valueBinder() is set.
      See Also:
      Default:
      @org.hibernate.search.mapper.pojo.bridge.mapping.annotation.ValueBridgeRef
    • valueBinder

      ValueBinderRef valueBinder
      Returns:
      A reference to the value binder to use for this field. Must not be set if valueBridge() is set.
      See Also:
      Default:
      @org.hibernate.search.mapper.pojo.bridge.mapping.annotation.ValueBinderRef
    • extraction

      Returns:
      A definition of container extractors to be applied to the property, allowing the binding of a value bridge to container elements. By default, Hibernate Search will try to apply a set of extractors for common container types.
      See Also:
      Default:
      @org.hibernate.search.mapper.pojo.extractor.mapping.annotation.ContainerExtraction