lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Heisey <>
Subject Re: Solrj
Date Fri, 04 Nov 2016 17:04:22 GMT
On 11/4/2016 10:22 AM, Furkan KAMACI wrote:
> I send a query to Solr to get information about each day of current week
> via this way:
> &q=*:*
> &fq=type:dps
> &rows=0
> &facet=true
> &
> &
> &
> &
> I want to make that query over Solrj.

This code would do it:

   * The client creation would probably be elsewhere, just putting it here
   * for a complete example.
  SolrClient client = new HttpSolrClient("http://server:8983/solr");
  SolrQuery query = new SolrQuery();
  query.add("facet", "true");
  query.add("", "date");
  query.add("", "NOW/DAY-6DAYS");
  query.add("", "NOW/DAY+1DAY");
  query.add("", "+1DAY");
  String collection = "gettingstarted";
  client.query(collection, query);

One possible problem in the attempts you've made:  In the parameters
you've provided, %2B is a URL-encoded plus sign.  It is shown in the
documentation that way because a plus sign in a URL is a URL-encoded
space.  If your SolrJ code tries to use "%2B" like you would need when
doing the query in a browser, then Solr will not receive a plus sign. 
It would receive the literal string "%2B" which it won't understand. 
SolrJ performs URL encoding on all parameters, so you don't want to do
the URL encoding yourself.


View raw message