Missing parenthesis in query built by SolrNet

52 views Asked by At

I'm building a Solr query with SolrNet and found that the resulting query is missing parenthesis in order for it to return my expected result. I wonder if I'm doing something wrong here, or if this is perhaps an issue in SolrNet or Solr. The fishy part of my SolrNet query in C# looks like this:

...
var filters = new List<ISolrQuery>();
filters.Add(new SolrMultipleCriteriaQuery(new ISolrQuery[] {
  new SolrNotQuery (new SolrQueryByField("ispage_b", "true")), // This line!
  new SolrQueryInList ("myfield_sm", arrayOfStringValues)
}, SolrMultipleCriteriaQuery.Operator.OR));
var options = new QueryOptions() { FilterQueries = filters };
...

The resulting query of this sent to Solr looks like this:

?q=*:*&fq(-ispage_b:(true) OR (myfield_sm:((value1) OR (value2) OR (value3)))&...

This doesn't give me my expected result. I'm not entirely sure why other than something going on with the priority of the minus - sign. I want all documents where either one of the values matches in myfield_sm OR the ispage_b isn't set to true (i.e. false or not present at all in the document.

From a Solr query perspective, this query works if I just add a set of parenthesis around the -ispage_b query, like this:

?q=*:*&fq((-ispage_b:(true)) OR (myfield_sm:((value1) OR (value2) OR (value3)))
          ^                ^

So translating this into a SolrNet query, I craft the query manually like this and it works:

new SolrMultipleCriteriaQuery(new ISolrQuery[] {
  new SolrQuery ("(-ispage_b:(true))"),  // raw query instead
  new SolrQueryInList ("myfield_sm", arrayOfStringValues)
}, SolrMultipleCriteriaQuery.Operator.OR)

I guess I'm missing something here. Am I doing something wrong in the initial query, or should SolrNet add a second set of parenthesis in SolrNotQuery or something else going on here?

0

There are 0 answers