How to filter with a query with scoring as an "AND" instead of an "OR"?


(Patrick Collins) #1

I am trying to search for documents that have a level of "series", and a full_name of "awesome name", and filter by
description of "lol". It seems that this query actually performs an OR, so it in addition to returning the records I expect, it also is returning documents that have a description "lol" but don't have "awesome name" or "series"...

I was under the impression that the solution to this problem was to add to the top level bool object "minimum_number_should_match" with the value of 2, to turn the OR into an AND... However when I try that then I get no results back... Can anyone explain what I am doing wrong and how to properly do this?

Here is a simplified version of the query I am using:

query: {
  bool: {
    should: [
      {
        bool: {
          must: [
            { match: { level: 'series' } },
            { bool:
              { should: [
                  {
                    match_phrase: {
                      full_name: {
                        query: 'awesome name',
                        boost: 3
                      }
                    }
                  }
                ]
              }
            }
          ]
        }
      }
  	],
	filter: {
		bool: {
			must: [
				{
					match: {
						filter: {
							'description': 'lol',
						}
					}
				}
			]
		}
	}
  }
}

(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.