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 Chris Hostetter <ho...@fucit.org> on 2011/06/21 21:33:16 UTC
Re: Question about SolrResponseBase.toString()
: I'm working with Solrj, and I like to use the SolrResponseBase.toString()
: method, as it seems to return JSON. However, the JSON returned is not
many of the toString methods on internal solr objects use {} to show
encapsulation when recursively calling toString() on sub objects, but they
are not intended to be parsed as JSON -- they are just for
debugging/hjuman consumption.
: valid, as it misses quotes. If I search directly against Solr using
: http://localhost:8080/apache-solr-3.1-SNAPSHOT/select/?q=*%3A*&version=2.2&start=0&rows=10&indent=on&wt=json
...
: When I search through the Solrj API, and to a SolrResponseBase.toString(),
: it looks like this:
the former is the output from the JSONResponseWriter, the later is the
simple toString of the SolrJ client side objects (which may hve been
parsed from the Binary format, or xml depending on how your SolrJ client
was configured).
If you want access to the JSON String produced by the JSONResponseWriter
(on the server side), i suggest you either access the server directly
(bypassing SolrJ completely) or use SolrJ just for constructing/executing
the requests, but implement your own ResponseParser with a getWriterType()
that returns "json" and does nothing in the processResponse(...) methods
except to slurp down the raw JSON string.
-Hoss