Last active
August 29, 2015 13:59
-
-
Save vojty/10647458 to your computer and use it in GitHub Desktop.
Apache Solr 4.0+ Update document
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 | |
// https://wiki.apache.org/solr/UpdateJSON | |
$data = array( | |
array( | |
'id' => $id, | |
'field' => array( | |
'set' => 'value', // set is keyword | |
) | |
) | |
); | |
$json = json_encode($data); | |
$ch = curl_init('http://localhost:8985/solr/collection1/update?commit=true'); | |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $json); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array( | |
'Content-Type: application/json', | |
'Content-Length: ' . strlen($json)) | |
); | |
$result = curl_exec($ch); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment