Search code examples
solrsolrnet

SolrNet building a compound query


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?


Solution

  • Mauricio's link in the comments answers this question.

    http://groups.google.com/d/topic/solrnet/NSfX31acJ5M/discussion