我需要在我的elasticsearch索引中使用属性“相似度”,但在Springframework的Field注解中找不到该属性。看起来,Springframework Elasticsearch库没有这个功能。我是否需要使用其他库,或者有没有简单的方法可以做到这一点?你能推荐一个图书馆或一种方法吗?
发布于 2020-03-10 18:37:54
您可以使用Setting注释并在单独的文件中定义您的设置,该文件具有适当的相似性配置。
要执行此操作,只需在索引类中添加@Setting(settingPath = "/path/to/settings.json"),其中包含@Document注释。
例如:
@Setting(settingPath = "/path/to/settings.json")
@Document(indexName = "indexName")
public class IndexClass {
@Id
private String id;
private String name;
// getters and setters
}你的settings.json应该是这样的:
"index": {
"similarity": {
"my_similarity": {
"type": "DFR",
"basic_model": "g",
"after_effect": "l",
"normalization": "h2",
"normalization.h2.c": "3.0"
}
}
}您可以在documentation中找到更多信息。
https://stackoverflow.com/questions/60614739
复制相似问题