Es 5.5.1 [size]查询格式错误,查询名称后没有start_object

时间:2017-08-10 16:25:51

标签: php symfony elasticsearch

我们正在将公司的Elasticsearch 1.7升级到5.5。

始终有这样的例外:

{"error":{"root_cause":[{"type":"parsing_exception","reason":"[size]
query malformed, no start_object after query name","line":1,"col":355}],"type":"parsing_exception","reason":"
[field_sort] failed to parse field [nested_filter]","line":1,"col":355,"caused_by":
{"type":"parsing_exception","reason":"Expected nested_filter element.","line":1,"col":355,"caused_by":
{"type":"parsing_exception","reason":"[size] query malformed, no start_object after query 
name","line":1,"col":355}}},"status":400}

查询:

{
   "from": 0,
   "size": 48,
   "query": {
      "bool": {
         "must": null,
         "filter": {
            "bool": {
               "must": [
                  {
                     "term": {
                        "published_countries.raw": "FR"
                     }
                  },
                  {
                     "nested": {
                        "path": "categories",
                        "query": {
                           "term": {
                              "categories.slug.raw": "engrais/engrais-complexes"
                           }
                        }
                     }
                  }
               ]
            }
         }
      }
   },
   "sort": [
      {
         "isProductRunOut": {
            "order": "asc"
         }
      },
      {
         "is_featured": {
            "order": "desc"
         }
      },
      {
         "total_va": {
            "order": "desc",
            "nested_filter": {
               "size": 12
            }
         }
      },
      {
         "createdAt": {
            "order": "desc"
         }
      }
   ],
   "aggs": {
      "top_12_total_va": {
         "top_hits": {
            "sort": {
               "total_va": {
                  "order": "desc"
               }
            },
            "size": 12
         }
      }
   }
}

我知道问题来自于nested_filter下的大小,因为当我删除thoses行时,没有更多问题(事实上,我还有另一个问题)。但我不知道如何通过这个问题。

我在symfony项目中使用Elasticsearch php客户端。

编辑:

Thx to Val,我忘了在文档中说的第3种添加nested_pa​​th。所以它看起来像这样:

       {
            "total_va": {
                "order": "desc",
                "nested_path": "variants",
                "nested_filter": {
                    "size": 12
                }
            }
        }

但我仍然有例外。

0 个答案:

没有答案