Class MappingDefinition

java.lang.Object
io.jmix.search.index.mapping.MappingDefinition

public class MappingDefinition extends Object
Contains information about indexed properties defined within index definition interface marked with JmixEntitySearchIndex

It can be created automatically according to field-mapping annotations used in index definition or manually within mapping method implementation. Such method should fulfil the following requirements:

builder() and MappingDefinitionElement.builder() should be used to create content.

Example:

 @JmixEntitySearchIndex(entity = Customer.class)
 public interface CustomerIndexDefinition {

     @ManualMappingDefinition
     default MappingDefinition mapping(AutoMappingStrategy autoMappingStrategy,
                                       SimplePropertyValueExtractor simplePropertyValueExtractor) {
         return MappingDefinition.builder()
                 .addElement(
                         MappingDefinitionElement.builder()
                                 .includeProperties("*")
                                 .excludeProperties("name", "description")
                                 .withFieldMappingStrategyClass(AutoMappingStrategy.class)
                                 .build()
                 )
                 .addElement(
                         MappingDefinitionElement.builder()
                                 .includeProperties("name")
                                 .withFieldMappingStrategy(autoMappingStrategy)
                                 .withFieldConfiguration(
                                         "{\n" +
                                         "    \"type\": \"text\",\n" +
                                         "    \"analyzer\": \"standard\",\n" +
                                         "    \"boost\": 2\n" +
                                         "}"
                                 )
                                 .build()
                 )
                 .addElement(
                         MappingDefinitionElement.builder()
                                 .includeProperties("description")
                                 .withFieldConfiguration(
                                         "{\n" +
                                         "    \"type\": \"text\",\n" +
                                         "    \"analyzer\": \"english\"\n" +
                                         "}"
                                 )
                                 .withPropertyValueExtractor(simplePropertyValueExtractor)
                                 .withOrder(1)
                                 .build()
                 )
                 .build();
     }
 }
 

Note: if definition method has implementation any field-mapping annotations on it will be ignored