Reputation: 3702
I want to index a single field (name) multiple times with different analyzers (ngram and standard) so that I can search using partial words or full words. But I could not find Spring Data ElasticSearch's support for this. Since @Field
annotation can not be repeated, so how can I achieve this using Spring Data?
Upvotes: 0
Views: 998
Reputation: 433
import org.springframework.data.elasticsearch.annotations.InnerField;
import org.springframework.data.elasticsearch.annotations.MultiField;
@MultiField(
mainField = @Field(type = FieldType.String),
otherFields = {
@InnerField(index = FieldIndex.not_analyzed, suffix = "<suffix name>", type =FieldType.String)
}
)
private String <fieldname>;
This way you can store the same field multiple times with different analyzers, please remember to use the meaningful suffix name for searching that field
for more information please refer the following link:
Upvotes: 2