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 homernabble <ho...@gmail.com> on 2012/08/08 16:07:01 UTC

Setting "df" (default field) from solrj?

I see in Solr 4 the defaultSearchField tag in schema.xml has been deprecated. 
I was looking in the Solrj API and I don't see a method for setting the
default field on a SolrQuery object.  

This is basically what the code looks like now (stripped down):
solrQuery = SolrQuery.new()
solrQuery.setQuery(queryText)
queryResponse = solrServer.query(solrQuery)

Before Solr 4 this would work fine because defaultSearchField was set in
schema.xml.  Now I need to be able to set it from my solrj call.

Am I missing something, how can I set this for my queries via solrj?

As I'm typing this I realize I can do something like I have below (and this
is fine) but still wondering if there is a dedicated method for setting this
somewhere:

solrQuery.add("df", "SearchText")





--
View this message in context: http://lucene.472066.n3.nabble.com/Setting-df-default-field-from-solrj-tp3999794.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Setting "df" (default field) from solrj?

Posted by homernabble <ho...@gmail.com>.
Perfect.  Thanks!


Jack Krupansky-2 wrote
> 
> You should simply set the default value for the "df" request parameter in 
> your Solr request handlers in solrconfig.xml. It is set to "text" out of
> the 
> box, but you can set it to your desired field.
> 
> If you still want to set/override "df" from SolrJ anyway, use the 
> SolrQuery.setParam method:
> 
> solrQuery.setParam("df", "SearchText");
> 
> -- Jack Krupansky
> 
> 




--
View this message in context: http://lucene.472066.n3.nabble.com/Setting-df-default-field-from-solrj-tp3999794p3999916.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Setting "df" (default field) from solrj?

Posted by Jack Krupansky <ja...@basetechnology.com>.
You should simply set the default value for the "df" request parameter in 
your Solr request handlers in solrconfig.xml. It is set to "text" out of the 
box, but you can set it to your desired field.

If you still want to set/override "df" from SolrJ anyway, use the 
SolrQuery.setParam method:

solrQuery.setParam("df", "SearchText");

-- Jack Krupansky

-----Original Message----- 
From: homernabble
Sent: Wednesday, August 08, 2012 10:07 AM
To: solr-user@lucene.apache.org
Subject: Setting "df" (default field) from solrj?

I see in Solr 4 the defaultSearchField tag in schema.xml has been 
deprecated.
I was looking in the Solrj API and I don't see a method for setting the
default field on a SolrQuery object.

This is basically what the code looks like now (stripped down):
solrQuery = SolrQuery.new()
solrQuery.setQuery(queryText)
queryResponse = solrServer.query(solrQuery)

Before Solr 4 this would work fine because defaultSearchField was set in
schema.xml.  Now I need to be able to set it from my solrj call.

Am I missing something, how can I set this for my queries via solrj?

As I'm typing this I realize I can do something like I have below (and this
is fine) but still wondering if there is a dedicated method for setting this
somewhere:

solrQuery.add("df", "SearchText")





--
View this message in context: 
http://lucene.472066.n3.nabble.com/Setting-df-default-field-from-solrj-tp3999794.html
Sent from the Solr - User mailing list archive at Nabble.com.