嵌套字段上的日期范围过滤器。弹性搜索

时间:2018-06-20 08:09:04

标签: php elasticsearch elasticsearch-5

映射:

        'working_time' => [
            'include_in_root' => 1,
            'type' => 'nested',
            'properties' => [
                'opens_at' => [
                    'type' => 'date',
                    'format' => 'E, HH:mm Z',
                ],
                'closes_at' => [
                    'type' => 'date',
                    'format' => 'E, HH:mm Z',
                ],
            ],
        ],

我需要找到在当前时间开放的那些地方,这样做:

            'nested' => [
                    'path' => 'working_time',
                    'query' => [
                        'bool' => [
                            'must' => [
                                [
                                    'range' => [
                                        'working_time.opens_at' => [
                                            'gte' => "now-1h/d",
                                            'lte' => 'now',
                                            'format' => 'E, HH:mm Z',
                                        ],
                                    ],
                                ],
                                [
                                    'range' => [
                                        'working_time.closes_at' => [
                                            'lte' => 'now+1d',
                                            'gte' => 'now',
                                            'format' => 'E, HH:mm Z',
                                        ],
                                    ],
                                ],
                            ],
                        ]
                    ]
                ],

但是它根本不起作用,没有错误,只是一个空的结果。如何找到目前开放的地方?

0 个答案:

没有答案
相关问题