You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by nagarjuna <na...@gmail.com> on 2011/08/17 17:19:16 UTC

is it possible to remove response header from the JSON fromat?

Hi every body
  i have the following response fromat

            {
  "responseHeader":{
    "status":0,
    "QTime":47,
    "params":{
      "fl":"keywords",
      "indent":"on",
      "start":"0",
      "q":"test",
      "version":"2.2",
      "rows":"30"}},
  "response":{"numFound":9,"start":0,"docs":[
                {
        "keywords":"test"},
      {
        "keywords":"test"},
      {
        "keywords":"Test"},
      {
        "keywords":"Test"},
      {
        "keywords":"Test"},
            {
        "keywords":"test"},
      {
        "keywords":"testing"},
      {
        "keywords":"testing"},
      {
        "keywords":"test iphone android"}]
  }}

from the above response fromat i need to remove the responseHeader...
i.e  {
  "responseHeader":{
    "status":0,
    "QTime":47,
    "params":{
      "fl":"keywords",
      "indent":"on",
      "start":"0",
      "q":"test",
      "version":"2.2",
      "rows":"30"}},
the above part i dont want to display ...please help me to do this

Thanks in advance

--
View this message in context: http://lucene.472066.n3.nabble.com/is-it-possible-to-remove-response-header-from-the-JSON-fromat-tp3261957p3261957.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: is it possible to remove response header from the JSON fromat?

Posted by Alexei Martchenko <al...@superdownloads.com.br>.
I believe your problem is not in Jquery or JSON. Solr's JSON can be parsed
by jQuery as any other. Try this test:

<html>
<head><title></title></head>
<script src="http://localhost:81/templates/js/jquery-1.4.2.min.js"></script>
<body>
<div id="test"></div>
<script>
url="
http://localhost:8983/solr/{CORENAMEHERE}/select/?q=whatever&version=2.2&start=0&rows=10&wt=json
";
url="solr_jquery.js";
$.getJSON(url, function(data) {
$("#test").append("status:"+data.responseHeader.status);
$("#test").append("<br />numfound:"+data.response.numFound);
$("#test").append("<br />response:"+data.response.docs.toString());
}
);
</script>
</body>
</html>

change your json script location and the variable url to perform a query.
comment the second url declaration and test.

If not working, try to save the JS generated by the solr request in the same
folder as this html page, uncomment the second url declaration and run. The
response should be something like

status:0
numfound:5873
response:[object Object],[object Object],[object Object],[object
Object],[object Object],[object Object],[object Object],[object
Object],[object Object],[object Object]

IF you wanna jQuery to communicate with your SOLR database directly be aware
of serious security issues. otherwise people can easily query your solr
database directly via normal http request and delete things. In my hosting,
almost all ports and protocols are firewalled and protected so no direct
query to solr is possible so we always use our application as another step
between solr and the public.

try this example and we'll see later what happens.

2011/8/18 nagarjuna <na...@gmail.com>

> Thank u very much Filype Pereira ....it works well but i have an another
> problem when ever i tried to use the url in my jquery page to get the
> "keywords" from the response it is saying tht it is not a pure json
> format...and i tested that url in REST client and i am not getting
> formatted
> JSON ...please help me to get pure json format...then only i can use in my
> jquery page...
>
>
>
> Thanx in advance
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/is-it-possible-to-remove-response-header-from-the-JSON-fromat-tp3261957p3263968.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>



-- 

*Alexei Martchenko* | *CEO* | Superdownloads
alexei@superdownloads.com.br | alexei@martchenko.com.br | (11)
5083.1018/5080.3535/5080.3533

Re: is it possible to remove response header from the JSON fromat?

Posted by nagarjuna <na...@gmail.com>.
Thank u very much Filype Pereira ....it works well but i have an another
problem when ever i tried to use the url in my jquery page to get the
"keywords" from the response it is saying tht it is not a pure json
format...and i tested that url in REST client and i am not getting formatted
JSON ...please help me to get pure json format...then only i can use in my
jquery page...



Thanx in advance

--
View this message in context: http://lucene.472066.n3.nabble.com/is-it-possible-to-remove-response-header-from-the-JSON-fromat-tp3261957p3263968.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: is it possible to remove response header from the JSON fromat?

Posted by Filype Pereira <pe...@gmail.com>.
I reckon you can use &omitHeader=true on the URL, hope that it helps

On Thu, Aug 18, 2011 at 5:21 PM, nagarjuna <na...@gmail.com>wrote:

> Thank u very much for ur reply   Erik Hatcher...
>      actually i thought to use my solr response in Jquery page.....
>
> i have one sample url
>
> http://api.geonames.org/postalCodeSearchJSON?postalcode=9011&maxRows=10&username=demo
>
> http://api.geonames.org/postalCodeSearchJSON?postalcode=9011&maxRows=10&username=demo
> which will produce json response and i successfully got the data from that
> url but i am unable to get the data from my solr url which will give the
> following response
>
> {
>  "response":{"numFound":20,"start":0,"docs":[
>      {
>        "keywords":"test"},
>      {
>        "keywords":"test"},
>      {
>        "keywords":"test"},
>      {
>        "keywords":"Test"},
>      {
>        "keywords":"test"},
>      {
>        "keywords":"test"},
>      {
>        "keywords":"test"},
>      {
>        "keywords":"test"},
>      {
>        "keywords":"test"},
>      {
>        "keywords":"Test"}]
>  }} so i need to format the above response as pure json response but i am
> unable to do that...so please help me
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/is-it-possible-to-remove-response-header-from-the-JSON-fromat-tp3261957p3263891.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: is it possible to remove response header from the JSON fromat?

Posted by nagarjuna <na...@gmail.com>.
Thank u very much for ur reply   Erik Hatcher...
      actually i thought to use my solr response in Jquery page.....

i have one sample url 
http://api.geonames.org/postalCodeSearchJSON?postalcode=9011&maxRows=10&username=demo
http://api.geonames.org/postalCodeSearchJSON?postalcode=9011&maxRows=10&username=demo 
which will produce json response and i successfully got the data from that
url but i am unable to get the data from my solr url which will give the
following response

{
  "response":{"numFound":20,"start":0,"docs":[
      {
        "keywords":"test"},
      {
        "keywords":"test"},
      {
        "keywords":"test"},
      {
        "keywords":"Test"},
      {
        "keywords":"test"},
      {
        "keywords":"test"},
      {
        "keywords":"test"},
      {
        "keywords":"test"},
      {
        "keywords":"test"},
      {
        "keywords":"Test"}]
  }} so i need to format the above response as pure json response but i am
unable to do that...so please help me

--
View this message in context: http://lucene.472066.n3.nabble.com/is-it-possible-to-remove-response-header-from-the-JSON-fromat-tp3261957p3263891.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: is it possible to remove response header from the JSON fromat?

Posted by Erik Hatcher <er...@gmail.com>.
What do you mean you don't want to "display" it?   Generally you'd just navigate to solr_response['response'] to ignore the header and just deal with the main body.

But, there is an omitHeader parameter - <http://wiki.apache.org/solr/CommonQueryParameters#omitHeader>

	Erik


On Aug 17, 2011, at 11:19 , nagarjuna wrote:

> Hi every body
>  i have the following response fromat
> 
>            {
>  "responseHeader":{
>    "status":0,
>    "QTime":47,
>    "params":{
>      "fl":"keywords",
>      "indent":"on",
>      "start":"0",
>      "q":"test",
>      "version":"2.2",
>      "rows":"30"}},
>  "response":{"numFound":9,"start":0,"docs":[
>                {
>        "keywords":"test"},
>      {
>        "keywords":"test"},
>      {
>        "keywords":"Test"},
>      {
>        "keywords":"Test"},
>      {
>        "keywords":"Test"},
>            {
>        "keywords":"test"},
>      {
>        "keywords":"testing"},
>      {
>        "keywords":"testing"},
>      {
>        "keywords":"test iphone android"}]
>  }}
> 
> from the above response fromat i need to remove the responseHeader...
> i.e  {
>  "responseHeader":{
>    "status":0,
>    "QTime":47,
>    "params":{
>      "fl":"keywords",
>      "indent":"on",
>      "start":"0",
>      "q":"test",
>      "version":"2.2",
>      "rows":"30"}},
> the above part i dont want to display ...please help me to do this
> 
> Thanks in advance
> 
> --
> View this message in context: http://lucene.472066.n3.nabble.com/is-it-possible-to-remove-response-header-from-the-JSON-fromat-tp3261957p3261957.html
> Sent from the Solr - User mailing list archive at Nabble.com.