[英]Elasticsearch get data using search in PHP
我正在尝试从PHP中的弹性搜索获取数据。 以下是我的弹性类型(精选)结构:
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 1,
"hits": [
{
"_index": "qwerty",
"_type": "curated",
"_id": "2",
"_score": 1,
"_source": {
"shows_on_lfz": [
{
"sh_id": 14,
"sh_parent_id": 102,
"sh_name": "Veg Versions Of Global Dishes"
}
]
}
},
{
"_index": "qwerty",
"_type": "curated",
"_id": "1",
"_score": 1,
"_source": {
"top_stories": [
{
"ts_id": 515,
"ts_parent_id": 485,
}
]
}
}
]
}
}
如何使用PHP中的搜索查询获取top_stories
所有数据? 我正在使用match_all
和get()
查询获取数据,但我需要使用search()
获取数据。
我试过了- $body['query']['bool']['should'] = ['match' => ['top_stories'=> '']];
但是得到一个空响应。
这是查询,将带所有具有字段top_stories
条目
GET qwerty/_search
{
"query": {
"exists": {
"field": "top_stories"
}
}
}
您可以将其转换为代码,也可以通过kibana对其进行测试
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.