-
-
Save reyhansofian/7a2b3581be22deb1428b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ch = curl_init(); | |
$method = "GET"; | |
$url = "localhost/cerberus/resraw/_search?pretty=true"; | |
$qry = '{ | |
"size" : 10, | |
"fields" : "usr", | |
"query" : { | |
"term" : { "usr":"stratawing"} | |
} | |
}'; | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_PORT, 9200); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($method)); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $qry); | |
$result = curl_exec($ch); | |
curl_close($ch); | |
// use the following if you want your result in a php array | |
//var_dump(json_decode($result, true)); | |
//use the following if you want the raw json format from es | |
echo $result; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment