es排序时 [nested_path] has been deprecated in favor of the [nested] parameter
时间: 2023-11-20 19:06:23 浏览: 38
这个警告是因为在 Elasticsearch 7.x 版本中,[nested_path] 参数已被弃用,使用[nested]参数代替。这是因为在旧版本中使用[nested_path]参数时,Elasticsearch会遍历整个文档来查找嵌套字段,这会导致性能问题。
如果你想使用新的[nested]参数,你需要将你的映射更新为使用[nested]参数。例如,如果你的映射如下所示:
```
{
"properties": {
"comments": {
"type": "nested",
"properties": {
"message": {"type": "text"},
"user": {"type": "text"}
}
}
}
}
```
你可以使用以下方式进行查询:
```
{
"query": {
"nested": {
"path": "comments",
"query": {
"bool": {
"must": [
{"match": {"comments.message": "good"}},
{"match": {"comments.user": "john"}}
]
}
}
}
}
}
```
请注意,[nested]参数只能用于[nested]类型的字段。如果你的字段不是嵌套类型的字段,则无法使用[nested]参数。