gpt4 book ai didi

elasticsearch - 如何在Elasticsearch Spring数据的嵌套字段中添加分析器?

转载 作者:行者123 更新时间:2023-12-03 01:15:38 24 4
gpt4 key购买 nike

我的架构实际上包括嵌套类型,如下所示。
这是主要模式。

@Document(indexName = "agreement")
public class PromotionSearchSchema {

@Field(type = FieldType.Nested, includeInParent = true)
private Promotion promotionproduct;

}
现在,促销是主模式中的另一个实体。所以我将其标记为嵌套类型。在促销实体中,我尝试添加分析器,如下所示
@Setting(settingPath = "es-config/elastic-analyzer.json")
public class Promotion {

@Field(type = FieldType.Text, analyzer = "autocomplete_index", searchAnalyzer = "autocomplete_search")
private String promotionDescription;

}
这是我的elastic-analyzer.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"
]
}
}
}
}
当我喜欢时,根本就不会在Elasticsearch中创建完整的映射。如下图所示
{
"agreement" : {
"mappings" : { }
}
}
所以我的问题是如何在嵌套类型中添加分析器。任何帮助,将不胜感激。

最佳答案

@Setting批注添加到顶级实体。

关于elasticsearch - 如何在Elasticsearch Spring数据的嵌套字段中添加分析器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62664677/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com