Re: Converting XML response of Search query into HTML.
Hi Erik, I have tried by removing '&' and i got response as in text format but i don't want response in text form. We need to get response as in html form with out any exception(Expected mime type application/xml but got text/html).So could you please provide any suggestion. Thanks, venkata krishna tolusuri. -- View this message in context: http://lucene.472066.n3.nabble.com/Converting-XML-response-of-Search-query-into-HTML-tp4141456p4142546.html Sent from the Solr - User mailing list archive at Nabble.com.
Re: Converting XML response of Search query into HTML.
The ‘&’ is only for separating parameters when building a URL, but omit the ‘&’ when using SolrJ. You’ll probably need to do a little bit of SolrJ trickery to get the response back as text, such that SolrJ doesn’t try to interpret the response as XML or javabin. Erik On Jun 18, 2014, at 9:04 AM, Venkata krishna wrote: > Thanks for quick responses, > > Ahemt , i have tried by removing ampersand then xml response has not > converted to html response it is in just xml only. > > Erik , according to your suggestion i used VelocityResponseWriter. > like this manner >query.set("&wt", "velocity"); > query.set("&v.template","browse"); > query.set("&v.layout", "layout"); > then also it is throwing same exception as previous > Exception in thread "main" > org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException: > Expected mime type application/xml but got text/html. > at > org.apache.solr.client.solrj.impl.HttpSolrServer.executeMethod(HttpSolrServer.java:516) > at > org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:210) > at > org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:206) > at > org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:91) > > > but when i do searching through solr admin interface then response is > converted to html. > 1. using XslResponseWriter > > http://localhost:8983/solr/collection1/select?q=coby&df=text&wt=xslt&indent=true&tr=example.xsl&hl=true&hl.fl=content&hl.fragsize=1000&hl.simple.pre=%3Cem%3E&hl.simple.post=%3C%2Fem%3E > > 2. using VelocityResponseWriter > > http://localhost:8983/solr/collection1/select?q=coby&wt=velocity&indent=true&v.template=browse&v.layout=layout&hl=true&hl.fl=content&hl.fragsize=1000&hl.simple.pre=%3Cem%3E&hl.simple.post=%3C%2Fem%3E > > It seems like coding issue of solrj (HttpSolrServer class). > > > so could you please provide me suggestions. > > Thanks, > > Venkata krishna Tolusuri. > > > > > -- > View this message in context: > http://lucene.472066.n3.nabble.com/Converting-XML-response-of-Search-query-into-HTML-tp4141456p4142490.html > Sent from the Solr - User mailing list archive at Nabble.com.
Re: Converting XML response of Search query into HTML.
Thanks for quick responses, Ahemt , i have tried by removing ampersand then xml response has not converted to html response it is in just xml only. Erik , according to your suggestion i used VelocityResponseWriter. like this manner query.set("&wt", "velocity"); query.set("&v.template","browse"); query.set("&v.layout", "layout"); then also it is throwing same exception as previous Exception in thread "main" org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException: Expected mime type application/xml but got text/html. at org.apache.solr.client.solrj.impl.HttpSolrServer.executeMethod(HttpSolrServer.java:516) at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:210) at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:206) at org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:91) but when i do searching through solr admin interface then response is converted to html. 1. using XslResponseWriter http://localhost:8983/solr/collection1/select?q=coby&df=text&wt=xslt&indent=true&tr=example.xsl&hl=true&hl.fl=content&hl.fragsize=1000&hl.simple.pre=%3Cem%3E&hl.simple.post=%3C%2Fem%3E 2. using VelocityResponseWriter http://localhost:8983/solr/collection1/select?q=coby&wt=velocity&indent=true&v.template=browse&v.layout=layout&hl=true&hl.fl=content&hl.fragsize=1000&hl.simple.pre=%3Cem%3E&hl.simple.post=%3C%2Fem%3E It seems like coding issue of solrj (HttpSolrServer class). so could you please provide me suggestions. Thanks, Venkata krishna Tolusuri. -- View this message in context: http://lucene.472066.n3.nabble.com/Converting-XML-response-of-Search-query-into-HTML-tp4141456p4142490.html Sent from the Solr - User mailing list archive at Nabble.com.
Re: Converting XML response of Search query into HTML.
Or, ahem, use VelocityResponseWriter :) > On Jun 12, 2014, at 21:07, Alexandre Rafalovitch wrote: > > Why are you doing your conversion on Solr side and not on SolrJ > (client) side? Seems more efficient and you can control the lifecycle > of XSLT objects better yourself. > > Regards, > Alex. > Personal website: http://www.outerthoughts.com/ > Current project: http://www.solr-start.com/ - Accelerating your Solr > proficiency > > > On Thu, Jun 12, 2014 at 10:26 PM, Ahmet Arslan > wrote: >> Hi, >> >> I see that you have ampersand left when setting various parameters. >> >> query.set("&wt", "xslt"); >> >> should be >> >> query.set("wt", "xslt"); >> >> >> >> >> On Thursday, June 12, 2014 6:12 PM, Venkata krishna >> wrote: >> >> >> >> Hi, >> >> I am using solr4.8, solrj for to do searching, would like to get response >> of search query in html format,for that purpose i have written this code, >> private static final String urlString = "http://localhost:8983/solr";; >>private SolrServer solrServer; >>public SolrJ() { >>if (solrServer == null) { >>solrServer = new HttpSolrServer(urlString); >> >>} >>} >> >> public QueryResponse getRueryResponse(String queryString) { >>SolrQuery query = new SolrQuery(); >>query.setHighlight(true).setHighlightSnippets(20); //set other params >> as >> needed >>query.setParam("hl.fl", "content"); >>query.setQuery(queryString); >>query.set("&wt", "xslt"); >>query.set("&indent",true); >>query.set("&tr", "example.xsl"); >> >> >>QueryResponse queryResponse = null; >>try { >>((HttpSolrServer) solrServer).setParser(new XMLResponseParser()); >>queryResponse = solrServer.query(query); >>} catch (SolrServerException e) { >>e.printStackTrace(); >>} return queryResponse; >>} >> and in example.xsl media type is >> . >> >> but i am getting an exception >> Exception in thread "main" >> org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException: >> Expected mime type application/xml but got text/html. >> >> So could you please provide any solution to resolve issue. >> >> >> Thanks, >> >> Venkata Krishna Tolusuri. >> >> >> >> >> >> >> -- >> View this message in context: >> http://lucene.472066.n3.nabble.com/Converting-XML-response-of-Search-query-into-HTML-tp4141456.html >> Sent from the Solr - User mailing list archive at Nabble.com.
Re: Converting XML response of Search query into HTML.
Why are you doing your conversion on Solr side and not on SolrJ (client) side? Seems more efficient and you can control the lifecycle of XSLT objects better yourself. Regards, Alex. Personal website: http://www.outerthoughts.com/ Current project: http://www.solr-start.com/ - Accelerating your Solr proficiency On Thu, Jun 12, 2014 at 10:26 PM, Ahmet Arslan wrote: > Hi, > > I see that you have ampersand left when setting various parameters. > > query.set("&wt", "xslt"); > > should be > > query.set("wt", "xslt"); > > > > > On Thursday, June 12, 2014 6:12 PM, Venkata krishna > wrote: > > > > Hi, > > I am using solr4.8, solrj for to do searching, would like to get response > of search query in html format,for that purpose i have written this code, > private static final String urlString = "http://localhost:8983/solr";; > private SolrServer solrServer; > public SolrJ() { > if (solrServer == null) { > solrServer = new HttpSolrServer(urlString); > > } > } > > public QueryResponse getRueryResponse(String queryString) { > SolrQuery query = new SolrQuery(); > query.setHighlight(true).setHighlightSnippets(20); //set other params > as > needed > query.setParam("hl.fl", "content"); > query.setQuery(queryString); > query.set("&wt", "xslt"); > query.set("&indent",true); > query.set("&tr", "example.xsl"); > > > QueryResponse queryResponse = null; > try { > ((HttpSolrServer) solrServer).setParser(new XMLResponseParser()); > queryResponse = solrServer.query(query); > } catch (SolrServerException e) { > e.printStackTrace(); > } return queryResponse; > } > and in example.xsl media type is > . > > but i am getting an exception > Exception in thread "main" > org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException: > Expected mime type application/xml but got text/html. > > So could you please provide any solution to resolve issue. > > > Thanks, > > Venkata Krishna Tolusuri. > > > > > > > -- > View this message in context: > http://lucene.472066.n3.nabble.com/Converting-XML-response-of-Search-query-into-HTML-tp4141456.html > Sent from the Solr - User mailing list archive at Nabble.com.
Re: Converting XML response of Search query into HTML.
Hi, I see that you have ampersand left when setting various parameters. query.set("&wt", "xslt"); should be query.set("wt", "xslt"); On Thursday, June 12, 2014 6:12 PM, Venkata krishna wrote: Hi, I am using solr4.8, solrj for to do searching, would like to get response of search query in html format,for that purpose i have written this code, private static final String urlString = "http://localhost:8983/solr";; private SolrServer solrServer; public SolrJ() { if (solrServer == null) { solrServer = new HttpSolrServer(urlString); } } public QueryResponse getRueryResponse(String queryString) { SolrQuery query = new SolrQuery(); query.setHighlight(true).setHighlightSnippets(20); //set other params as needed query.setParam("hl.fl", "content"); query.setQuery(queryString); query.set("&wt", "xslt"); query.set("&indent",true); query.set("&tr", "example.xsl"); QueryResponse queryResponse = null; try { ((HttpSolrServer) solrServer).setParser(new XMLResponseParser()); queryResponse = solrServer.query(query); } catch (SolrServerException e) { e.printStackTrace(); } return queryResponse; } and in example.xsl media type is . but i am getting an exception Exception in thread "main" org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException: Expected mime type application/xml but got text/html. So could you please provide any solution to resolve issue. Thanks, Venkata Krishna Tolusuri. -- View this message in context: http://lucene.472066.n3.nabble.com/Converting-XML-response-of-Search-query-into-HTML-tp4141456.html Sent from the Solr - User mailing list archive at Nabble.com.