我需要支持使用ElasticSearch作为数据存储的Spring应用程序,并且需要按术语提取一些数据过滤,例如
POST http://localhost:1234/library/myType/_search
{
"query": {
"bool": {
"filter": {"term": {"myTextField": "filterValue"}}
}
}
}问题是Java模型中的字段注释如下
@Field(type = FieldType.String)不像
@Field(type = FieldType.Keyword)我已经尝试谷歌关键词注释,但看起来有一个解决办法,我不能透露。如何注释模型字段,以便在查询中按术语进行过滤?
发布于 2017-07-14 21:20:30
spring数据类型是在ES 5中添加的,因此在keyword - data -es 2.0.3中找不到它。
您需要将字段声明为not_analyzed,即如下所示:
@Field(type = FieldType.String, index = FieldIndex.not_analyzed)https://stackoverflow.com/questions/45103209
复制相似问题