I am trying to add new document in the solr server using ajax.
To add a new document in the solr server we have to write
http:// 192.168.10.113:8080/solr/update/?commit=true%20-H%20%22Content-Type:%20text/xml%22%20–data-binary%20%20%3Cadd%3E%3Cdoc%3E%3Cfield%20name=’id’%3E19990%3C/field%3E%3C/doc%3E%3C/add%3E
actual Code:
< add>< doc> < field name=’id>19990>< /field> < /doc> < /add>
Now i tried to add the document in the server .
My AJAX Code:
$.ajax({
url: "http://192.168.10.113:8080/solr/update/?commit=true%20-H%20%22Content-Type:%20text/xml%22%20--data-binary%20'<add><response><doc><field%20name='id'>19990</field></doc></response></add>'",
type: 'POST',
success: function (data) {
alert(data);
}
});
ajax call didn’t show any error.
then i try to fetch the data
like this:
http:// 192.168.10.113:8080/solr/select/?q=19990&version=2.2&start=0&rows=10&indent=on
it is not showing that data.
Please help
It might take sometime till the solr repository get updated. look on your commit strategy and maybe try to commit on your own.
How did you tried to add it? using curl? or using some browser? cause the request might be an update or a post request…
use this: https://github.com/evolvingweb/ajax-solr
the “–data-binary” is a curl flag and not should be in the url, you should put your xml data in the ajax request’s data and not in the url: