OK I definitely need a response parser. Thank you! 2012/7/28 Erik Hatcher <erik.hatc...@gmail.com>
> And by parser, what is meant is a ResponseParser. There is an example in > one of the Solr 4 test cases that goes like this: > > public void testGetRawFile() throws SolrServerException, IOException { > SolrServer server = getSolrServer(); > //assertQ(req("qt", "/admin/file")); TODO file bug that > SolrJettyTestBase extends SolrTestCaseJ4 > QueryRequest request = new QueryRequest(params("file","schema.xml")); > request.setPath("/admin/file"); > final AtomicBoolean readFile = new AtomicBoolean(); > request.setResponseParser(new ResponseParser() { > @Override > public String getWriterType() { > return "mock";//unfortunately this gets put onto params wt=mock > but it apparently has no effect > } > > @Override > public NamedList<Object> processResponse(InputStream body, String > encoding) { > try { > if (body.read() >= 0) > readFile.set(true); > } catch (IOException e) { > throw new RuntimeException(e); > } > return null; > } > > @Override > public NamedList<Object> processResponse(Reader reader) { > throw new UnsupportedOperationException("TODO > unimplemented");//TODO > } > }); > > server.request( request );//runs request > //request.process(server); but we don't have a NamedList response > assertTrue(readFile.get()); > } > > So... you can read the JSON, but you'll need to do something like the > above. > > Erik > > > On Jul 28, 2012, at 08:11 , in.abdul wrote: > > > Solrj can support only xml writer and binary writer . It not possible get > > the response in Json . If your requirement is to get response in Json > then > > you have to write parser .. > > Syed Abdul kather > > send from Samsung S3 > > On Jul 28, 2012 1:29 AM, "Federico Valeri [via Lucene]" < > > ml-node+s472066n3997784...@n3.nabble.com> wrote: > > > >> Hi, I'm trying to get a JSON response with this Java code: > >> > >> SolrServer solr = new HttpSolrServer("http://localhost:8080/solr"); > >> ModifiableSolrParams params = new ModifiableSolrParams(); > >> params.set("qt", "/select"); > >> params.set("q", "contenuto:(" + query + ")"); > >> params.set("hl", "true"); > >> params.set("hl.fl", "id,contenuto"); > >> params.set("wt", "json"); > >> QueryResponse response = solr.query(params); > >> log.debug(response.toString()); > >> > >> but from log i see "&wt=javabin" in query > >> and "..docs=[SolrDocument{id=452011.." in response .. > >> > >> instead I would expect "&wt=json" and "..docs=[{id=452011.." > >> > >> What I am missing? > >> > >> > >> ------------------------------ > >> If you reply to this email, your message will be added to the discussion > >> below: > >> > >> > http://lucene.472066.n3.nabble.com/Solr-4-0-ALPHA-and-ModifiableSolrParams-tp3997784.html > >> To unsubscribe from Lucene, click here< > http://lucene.472066.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=472066&code=aW4uYWJkdWxAZ21haWwuY29tfDQ3MjA2NnwxMDczOTUyNDEw > > > >> . > >> NAML< > http://lucene.472066.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml > > > >> > > > > > > > > > > ----- > > THANKS AND REGARDS, > > SYED ABDUL KATHER > > -- > > View this message in context: > http://lucene.472066.n3.nabble.com/Solr-4-0-ALPHA-and-ModifiableSolrParams-tp3997784p3997858.html > > Sent from the Solr - User mailing list archive at Nabble.com. > >