[英]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.