我已将下面的记录编入索引
[0] => Array
(
[_index] => test_index
[_type] => cool_type
[_id] => AVy-s52Kahn1F1gX3B0K
[_score] => 1
[_source] => Array
(
[name] => TEST
[name_alias] =>
[webiste] => www.test.com
[directions] =>
[narrative] =>
[office_function] =>
[deleted_by] =>
[created_at] => 2017-06-09 11:03:27
[updated_at] => 2017-06-09 11:03:27
[deleted_at] =>
)
)
[1] => Array
(
[_index] => test_index
[_type] => cool_type
[_id] => AVy-s52Kahn1F1gX3B0L
[_score] => 1
[_source] => Array
(
[name] => new
[name_alias] =>
[webiste] => www.new.com
[directions] =>
[narrative] =>
[office_function] =>
[deleted_by] =>
[created_at] => 2017-06-18 10:00:00
[updated_at] => 2017-06-18 10:00:00
[deleted_at] =>
)
)
我想只获得给定日期之间的记录(2个日期范围和过去30天的记录之间的记录以及今天的记录等)。所以我使用Elasticsearch文档Link编写了这样的代码。但我无法获得记录。
$params = [
'query' => [
'match_all' => []
],
'filter' => [
'range' => [
'created_at' => [
'gte' => '2017-06-18 00:00:00',
'lte' => '2017-06-19 00:00:00'
]
]
],
'size' => 10
];
在点击弹性搜索时会像这样转换
{
"query": {
"match_all": []
},
"filter": {
"range": {
"created_at": {
"gte": "2017-06-18 00:00:00",
"lte": "2017-06-19 00:00:00"
}
}
},
"size": 10
}
以下方式尝试
$params = [
'query' => [
'range' => [
'created_at' => [
'gte' => '2017-06-18 00:00:00',
'lte' => '2017-06-19 00:00:00'
]
]
],
'size' => 10
];
在点击弹性搜索时会像这样转换
{
"query": {
"range": {
"created_at": {
"gte": "2017-06-18 00:00:00",
"lte": "2017-06-19 00:00:00"
}
}
},
"size": 10
}
请帮助我。