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 darul <da...@gmail.com> on 2011/10/11 17:31:10 UTC
Query url escape caracters ?
Hello,
We use SolrJ for building and sending request to Solr server. (working well)
On the other part, we want to use HttpClient to request server and get
result in Json or Xml result ouput format.
Scenario:
- building SolrQuery object with SolrJ.
- getting parameters with SolrQuery.toString() method
- appending to my server url..
- sending with HttpClient
Problem is the following, for complex query parameters like the following
url :
http://192.168.10.233:8984/solr/mycore/select?q=test+&start=0&rows=5&qt=myrequestHandler&hl=true&hl.snippets=5&hl.fragsize=150&hl.fl=body%2C+title%2C+comments&fl=*%2C+score&sort=score+desc&facet.range=creation_date&facet.range=creation_date&f.creation_date.facet.range.start=2010-10-01T15%3A23%3A04.118Z&f.creation_date.facet.range.start=2010-10-01T15%3A23%3A04.118Z&f.creation_date.facet.range.end=2011-10-11T15%3A23%3A04.118Z&f.creation_date.facet.range.end=2011-10-11T15%3A23%3A04.118Z&f.creation_date.facet.range.gap=%2B10DAY&f.creation_date.facet.range.gap=%2B1MONTH&facet=true&facet.field=context&facet.field=type&facet.field=author&facet.field=commentCount&facet.query=commentCount%3A%5B*+TO+5%5D&facet.query=myfield%3A%5B5+TO+*%5D&wt=json&indent=on
I got this :
<pre> Can't parse value 2010-10-01T15%3A22%3A58.768Z for field:
creation_date</pre></p><hr />/<small>Powered by Jetty://</small>/<br/>
How to get good caracter syntax, when pasting this url to browser, it is
ok...what syntax to use to send with httpclient. Here, ", " is replace by
"%2C+", etc....many caracters replaced
Extract of my code :
final SolrQuery newQuery = SolrQueryBuilder.buildQuery(.....);
String queryUrl = urlServer + "/select?" + newQuery.toString();
HttpClient client = new HttpClient();
GetMethod method = null;
try
{
URI uri = new URI(queryUrl);
method = new GetMethod(uri.getEscapedURI());
Thanks,
Jul
sorry for poor english
--
View this message in context: http://lucene.472066.n3.nabble.com/Query-url-escape-caracters-tp3412912p3412912.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Query url escape caracters ?
Posted by darul <da...@gmail.com>.
*ClientUtils.toQueryString()* saved my life ! I was boring for hours before
finding solutions with my favourite search engine ;)
http://lucene.472066.n3.nabble.com/Does-SOLR-provide-a-java-class-to-perform-url-encoding-td842660.html
final SolrQuery newQuery = SolrQueryBuilder.buildQuery(queryParam);
.....
String queryUrl = url + "/select" + ClientUtils.toQueryString(newQuery,
false);
--
View this message in context: http://lucene.472066.n3.nabble.com/Query-url-escape-caracters-tp3412912p3413178.html
Sent from the Solr - User mailing list archive at Nabble.com.