Steve L
Steve L

Reputation: 1635

Using the Solr api, it seems it's not handling the OR logic correctly

Here's the query response snippet showing the query params:

      "q":"title:bear",
      "indent":"true",
      "fl":"id",
      "q.op":"OR",
      "fq":"authors:bear",
      "sort":"id asc",
      "rows":"100"}},
  "response":{"numFound":2,"start":0,"numFoundExact":true,"docs":[
      {
        "id":"204921"},
      {
        "id":"228142"}]
  }}

These are the two records where bear appears both in the title and the authors list. If I just query for bear in the title or bear in the authors I get "numFound":688 and "numFound":35, respectively. I would expect that the OR of those two sets would be the union of those (having at least 688 items) not the intersection (2 items). I get the same two items if I switch the operation from OR to AND. Is this not the correct way to structure the OR query in the Solr API?

Upvotes: 0

Views: 36

Answers (1)

Mike Nord
Mike Nord

Reputation: 46

This query is filtering the results to contain only authors with the word "bear"(filter query) and then it is searching for the title bear in that result set. If you want to use the AND/OR functionality, you should be passing both params(title and author) as filter queries. You can also use the explain parameter to give you more context. https://solr.apache.org/guide/7_4/common-query-parameters.html#debug-parameter

Upvotes: 1

Related Questions