我有一个Person类:
@Document(indexName = "person")
@Data
@EqualsAndHashCode(callSuper = true)
public class Person extends BaseEntity implements Serializable {
@Field(type=FieldType.Keyword)
private String firstName;
@Field(type=FieldType.Keyword)
private String lastName;
@MultiField(
mainField = @Field(type = FieldType.Keyword),
otherFields = {
@InnerField(type = FieldType.Text, suffix = "ngrams", analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
})
private String fullName;
@Field
private String maidenName;
}
我有一个在启动时创建索引的现有代码:
final IndexOperations indexOperations = this.elasticsearchOperations.indexOps(clazz);
indexOperations.putMapping();
现在,我有一个需求,从它生成Map,并创建Map一次。有人能帮助我如何将它与现有的代码集成,以包括字段的Map,使他们成为静态的?
1条答案
按热度按时间eh57zj3b1#
只需检查是否需要创建索引,如果需要,则创建索引并写入Map: