bool查询格式错误,查询名称后没有start_object

时间:2018-12-07 20:38:18

标签: php elasticsearch

我已经把这个弄乱了一段时间,但无法正确解决。我尝试了几种显示此查询的方法。例如,我已将bool内的每个参数作为键而不是数组元素。现在,它是一个数组元素。无论哪种方式,ES似乎都不喜欢它。以下查询的正确格式是什么?

应该做什么:

这是PHP。应该查询应该在两个日期之间,并且状态必须为结束,或者必须在一个日期开始,并且状态不能结束。

                      [
                            'index' => 'quotes',
                            'type' => 'title',
                            'body' => [
                            'query' => [
                                "function_score" => [
                                    'query' => [
                                    'bool' => [
                                        'filter' => [
                                            ["range"  => ["number_of_quotes" => ["gt" => 0]]],
                                            ["exists" => ["field" => "vote-average"]],
                                            ["exists" =>["field" => "first-air-date"]],
                                            ["exists" =>["field" => "last-air-date"]],

                                        ],
                                        'should' => [
                                            ['bool' => [
                                                ["range" => ["first-air-date" => [
                                                        "gte" => "$begin",
                                                        "format" => "yyyy"
                                                    ],
                                                    ["last-air-date" => [
                                                        "lte" => $begin,
                                                        "format" => "yyyy"
                                                    ]],
                                                ]],
                                                ["must" => [
                                                    "match" => [
                                                        "status" => "Ended"
                                                    ]
                                                ]
                                            ]], 

                                        ],
                                        ['bool' => [
                                            ["range" => ["first-air-date" => [
                                                "gte" => "$begin",
                                                 "format" => "yyyy"
                                            ]]],
                                            ["must_not" => [
                                                "match" => [
                                                    "status" => "Ended"
                                                ]
                                            ]
                                        ]], 

                                    ]]],
                                    ]
                                ],
                            ],  
                        ],       
                        "from" => (int) $skip,
                        "size" => (int) $take,
                        ];

0 个答案:

没有答案