我不知道我做錯了什麼。該記錄不會被添加。通過PHP將文檔添加到Apache Solr cURL
這裏是我的代碼:
$ch = curl_init("http://127.0.0.1:8983/solr/collection1/update/json?commit=true");
$data = array(
"add" => array("doc" => array(
"id" => "HW132",
"name" => "Hello World"
))
);
$data_string = json_encode($data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
$response = curl_exec($ch);
這裏是我從Solr的得到響應:
{"responseHeader":{"status":0,"QTime":4}}