是否可以使用 jquery AJAX 索引(添加/更新)solr?
网上没有例子,我一直在尝试但没有成功。下面是我的代码
try {
$.ajax({
type: "POST",
url: "http://192.168.10.113:8080/solr/update/json?commit=true",
data: { "add": { "doc": { "id": "222222", "name": "Ruby on Trails"}} },
contentType: "application/json",
dataType: 'jsonp',
crossDomain: true,
jsonp: 'json.wrf',
success: function (data) { alert(data); },
failure: function (errMsg) {
alert(errMsg);
}
});
}
catch (err) {
alert(err);
}
我的 tomcat 服务器日志如下所述。[31/Oct/2012:15:56:24 +0530] "GET /solr/update/json?commit=true&json.wrf=jQuery1820996771614998579_1351662048057&add%5Bdoc%5D%5Bid%5D=222222&add%5Bdoc%5D%5Bname%5D=Ruby+on+Trails&_=1351678643653 HTTP/1.1" 200 159
虽然它说 200,但该文档并未添加到 solr。我已经等待了足够多的时间并重复了几次该过程,以消除 solr server 的提交策略是这里的罪魁祸首。在 chrome 浏览器中,它说 Uncaught SyntaxError: Unexpected token < 但这太笼统了,无法猜测。这是另一个问题。任何帮助表示赞赏。