Build a compound query

533 views
Skip to first unread message

Will Liang

unread,
May 13, 2012, 7:54:27 PM5/13/12
to sol...@googlegroups.com

I am trying to build the following query using SolrNet.

(type:Contact) AND ((firstName:Jason)^100) OR ((lastName: Winters)^100)
 

I have tried to use the following code:

var query = new SolrQuery("type:Contact") &&
            new SolrQuery("firstName:Jason").Boost(100) ||
            new SolrQuery("lastName:Winters").Boost(100); 

Looking at the Catalina log in Tomcat, the following query was produced, the nested brackets is not what I expected, is this correct?

q=((type:Contact+AND+(firstName:Jason)^100)+OR+(lastName:Winters)^100)
 

Also, it would be perfect if I can embed this search logic using a request handler in Solr configuration, does anyone know how to do it?

Mauricio Scheffer

unread,
May 13, 2012, 9:47:37 PM5/13/12
to sol...@googlegroups.com
Just as you used parentheses to group both terms involved in the OR expression, you need to use parentheses in the SolrNet expression.
As in most languages, && has a higher precedence than ||.

As far as I know you can only set fixed parameters in Solr configuration. Look up "defaults", "appends", "invariants" in the sample Solr config: http://svn.apache.org/repos/asf/lucene/dev/trunk/solr/example/solr/conf/solrconfig.xml

Cheers,
Mauricio



--
You received this message because you are subscribed to the Google Groups "SolrNet" group.
To view this discussion on the web visit https://groups.google.com/d/msg/solrnet/-/UbYSLXiNKwYJ.
To post to this group, send email to sol...@googlegroups.com.
To unsubscribe from this group, send email to solrnet+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/solrnet?hl=en.

Reply all
Reply to author
Forward
0 new messages