Re: Solr client in JavaScript

2020-10-01 Thread Shawn Heisey

On 10/1/2020 3:55 AM, Sunil Dash wrote:

This is my javascript code ,from where I am calling solr ,which has a
loaded nutch core (index).
My java script client ( runs on TOMCAT server) and Solr
server are on the same machine (10.21.6.100) . May be due to cross
domain references issues OR something is missing I don't know.
I expected Response from Solr server (search result) as raw JASON
object. Kindly help me fix it.Thanks in advance .


As far as I can tell, your message doesn't tell us what the problem is. 
So I'm having a hard time coming up with a useful response.


If the problem is that the response isn't JSON, then either you need to 
tell Solr that you want JSON, or run a new enough version that the 
default response format *IS* JSON.  I do not recall which version we 
changed the default from XML to JSON.


One thing you should be aware of ... if the javascript is running in the 
end user's browser, then the end user has direct access to your Solr 
install.  That is a bad idea.


Thanks,
Shawn


Solr client in JavaScript

2020-10-01 Thread Sunil Dash
This is my javascript code ,from where I am calling solr ,which has a
loaded nutch core (index).
My java script client ( runs on TOMCAT server) and Solr
server are on the same machine (10.21.6.100) . May be due to cross
domain references issues OR something is missing I don't know.
I expected Response from Solr server (search result) as raw JASON
object. Kindly help me fix it.Thanks in advance .

Rgds
Sunil Kumar



  Solr Search  


function search()
{
 var xmlHttpReq =false;
 var  xmlHttpClient=this;

 var hostURL='http://10.21.6.100:8983/solr/nutch/select';
 var querystring=document.getElementById("querystring").value;
 qstr='q='+escape(querystring)+"&fl=content";

 if(window.XMLHttpRequest){  xmlHttpClient.xmlHttpReq=new
XMLHttpRequest(); }

 xmlHttpClient.xmlHttpReq.open('POST',hostURL,true);


xmlHttpClient.xmlHttpReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

 xmlHttpClient.xmlHttpReq.send(qstr);

 xmlHttpClient.xmlHttpReq.onreadystatechange=function()
  {
  if(xmlHttpClient.xmlHttpReq.readyState ==4 )
{ showresponse(xmlHttpClient.xmlHttpReq.responseText);}
  }

}

 function showResponse(str)
{
   document.getElementById("responsestring").innerHTML=str;
}



 Solr Search [ From Javascript ]