Package io.jmix.search.index.mapping
Class MappingDefinition
java.lang.Object
io.jmix.search.index.mapping.MappingDefinition
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:
- Annotated with
ManualMappingDefinition
- with any name
- default
- With return type -
MappingDefinition
- With Spring beans as parameters
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
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
-
Method Summary
-
Field Details
-
elements
-
-
Constructor Details
-
MappingDefinition
-
-
Method Details
-
getElements
Gets allMappingDefinitionElement
- Returns:
- List of
MappingDefinitionElement
-
builder
-