[英]How to add analyzer to the nested fields in elasticsearch spring data?
I have schema which actually includes the nested type as shown below.我有实际上包含嵌套类型的架构,如下所示。
This is main schema.这是主要模式。
@Document(indexName = "agreement")
public class PromotionSearchSchema {
@Field(type = FieldType.Nested, includeInParent = true)
private Promotion promotionproduct;
}
Now, the Promotion is the another entity inside main schema.现在,Promotion 是主模式中的另一个实体。 So i have marked it as nested type.
所以我把它标记为嵌套类型。 In the Promotion entity i'm trying to add analyzer as shown below
在 Promotion 实体中,我正在尝试添加分析器,如下所示
@Setting(settingPath = "es-config/elastic-analyzer.json")
public class Promotion {
@Field(type = FieldType.Text, analyzer = "autocomplete_index", searchAnalyzer = "autocomplete_search")
private String promotionDescription;
}
This is my elastic-analyzer.json这是我的弹性分析仪。json
{
"analysis": {
"filter": {
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 20
}
},
"analyzer": {
"autocomplete_search": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase"
]
},
"autocomplete_index": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"autocomplete_filter"
]
}
}
}
}
When i do like, it's not at all creating the complete mappings in the Elasticsearch.当我喜欢时,它根本不会在 Elasticsearch 中创建完整的映射。 It's just creating as shown below
它只是创建如下所示
{
"agreement" : {
"mappings" : { }
}
}
So my question is how to add the analyzers in the nested type.所以我的问题是如何在嵌套类型中添加分析器。 Any help would be appreciated.
任何帮助,将不胜感激。
Add the @Setting
annotation to the top level entitty.将
@Setting
注释添加到顶级实体。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.