On 3/18/2014 7:48 AM, Cynthia Park wrote:
> What is the difference between setting parameters via SolrQuery vs
> ModifiableSolrParams? If there is a difference,  is there a preferred
> choice?  I'm using Solr 4.6.1.
> 
> SolrQuery query = new SolrQuery();
> query.setParam("wt", "json");
> 
> ModifiableSolrParams params = new ModifiableSolrParams();
> 
> params.set("wt", "json");
> 

A SolrQuery object actually IS an instance of ModifiableSolrParams, so
everything you can do on params will also work on query.  This is the
first line of the class definition:

public class SolrQuery extends ModifiableSolrParams

The difference is that SolrQuery includes a whole bunch of query-related
methods that let you write code that is much easier to understand.

Just so you know, it doesn't make much sense to set the "wt" parameter.
 SolrJ works best when the response writer is binary, and this is
automatically set by default on requests.  In fact, I think it's
possible that your manual setting of wt will be ignored on a standard
query, although if you use a more specialized type of query that gets
you access to the raw HTTP response data, it might be honored.

Thanks,
Shawn

Reply via email to