如何检查solr服务器是否正在运行

时间:2011-07-23 11:30:54

标签: ajax json solr

我在我的电子商务应用程序中实现了搜索。命中solr(在端口8983上运行)以获取搜索结果

solr url是

url =solrURL+"/solr/db/select/?qt=dismax&wt=json&&start="+start+"&rows="+end+"&q="+lowerCaseQuery+"&hl=true&hl.fl=text&hl.usePhraseHighlighter=true&sort= score desc ,"+sort+" "+order+"&json.wrf=?"

并使用getJson我得到了solr响应。

 $.getJSON(url, function(result){

现在我的问题是如何确定solr服务器正在运行。

修改

$

.ajax({
                url: "http://192.168.1.9:8983/solr/db/admin/ping",
                    success:function(){
                            alert("ok");
                        },
                        error: function()
                        {
                            alert("dsd");                       
                        }
            })      

1 个答案:

答案 0 :(得分:1)

您需要指定超时值。虽然getJSON未指定一个,但您可以使用jquery方法$.ajax,请参阅:http://api.jquery.com/jQuery.ajax/

$.ajax({
  url: url,
  dataType: 'json',
  data: data,
  success: callback,
  timeout: 3000 //3 second timeout
});

对于ping,您可以查看以下代码段:

$.ajax({
  url: 'http://192.168.1.9:8983/solr/db/admin/ping',
  type: 'GET',
  complete: function(transport) {
     if(transport.status == 200) {
         alert('Success');
     } else {
         alert('Failed');
     }
  }
 });
相关问题