Elasticsearch - 在path_route上找不到嵌套类型



错误导致:java.lang.IllegalStateException:路径 [path_route] 下的 [nested] 嵌套对象不是嵌套类型。相同的代码在另一台PC上完美运行。

GET content/_search
{
"from": 0,
"size": 0,
"query": {
"bool": {
"must": [
{
"nested": {
"path": "path_route",
"query": {
"bool": {
"must": {
"terms": {
"path_route.status": [
"approved"
]
}
}
}
}
}
}
]
}
}
}

此类错误消息不是编造的。您需要验证path_route是否确实属于nested类型。

运行GET content/_mapping并验证它是否如下所示:

{
"content": {
"mappings": {
"doc": {
"properties": {
"path_route": {
"type": "nested",         <-------
"properties": {
"status": {
"type": "text"
}
}
}
}
}
}
}
}

如果不是,请按如下方式指定:

PUT /content
{
"mappings": {
"doc": {
"properties": {
"path_route": {
"type": "nested",
"properties": {
"status": {
"type": "text"
}
}
}
}
}
}
}

最新更新