I folgenden Code zum Indexieren Dokument in solr curl Anfrage durch die C++ für die Indizierung solr Dokument
CURL *curl = curl_easy_init();
CURLcode res;
if(curl) {
/* First set the URL that is about to receive our POST. This URL can
just as well be a https:// URL if that is what should receive the
data. */
curl_easy_setopt(curl, CURLOPT_URL, "http://192.168.0.164:8983/solr/collection1/update?replacefields=false -H 'Content-type: application/json' -d '[{\"id\":\"4000\", \"to\":\"Life is to.\", \"cc\":\"unknown \", \"subject\":\"Life\"}]'");
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
if(CURLE_OK == res){
logger.LogError("res value CURLE_OK");
}
/* always cleanup */
curl_easy_cleanup(curl);
}
und den Rückgabewert von curl_easy_perform (curl)
dh verwenden res ist CURLE_OK aber die Platten indizieren keine in collection1 von solr und während der Buchung folgenden Befehl aus dem Terminal-Datensatz wird indiziertcurl http://192.168.0.164:8983/solr/collection1/update?replacefields=false -H 'Content-type: application/json' -d '[{"id":"4000", "to":"Life is to.", "cc":"unknown ", "subject":"Life"}]'
Hallo oben Vorschlag versucht hatte, aber als Antwort auf Terminal i Störung erhalten als:. xml version = "1.0" encoding = "UTF-8"> 400 5 fehlender content stream 400 –
Anuja
Ich denke, dass ich Parameter nicht richtig zur Verfügung stelle. Wie sollte ich -H 'übergeben Content-Typ: Anwendung/Json' -d Parameter – Anuja
@Anuja Das ist irgendwie der Inhalt meines Beitrags. Verwenden Sie 'CURLOPT_POSTFIELDS', um die Daten auf POST (den Parameter' -d') und 'CURLOPT_HTTPHEADER' festzulegen, um einen' Content-Type: '-Header festzulegen. – MatsLindh