Curl command from terminal works however, php CURL doesnt pull the records

(Bishwadeep Kc) #1

I have the following php curl commands running on the same server where the ES is installed and running on port 9200.

$ch = curl_init('http://localhost:9200/cfaq/_search');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
$result = curl_exec($ch);

This curl function is returning the following whatever Search Query i use.


However, when I try same search query on same server using terminal curl command (eg: curl -X POST 'http://localhost:9200/cfaq/_search?q=Job'), I get the desired
results. Here is my configuration on elasticsearch.yml file:

bootstrap.memory_lock: true localhost
http.port: 9200

My Elastic search version is 6.5.0
Please let me know if you have any questions.
Can you please let me know what I am doing wrong?

(system) closed #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.