Omit Zero Score Results From Filtered Query?

Is it possible to omit results with a zero score when doing a filtered query? Take the following query for example:

GET demo/_search?pretty
{
	"query": {
		"bool": {
			"should": {
				"match": {
					"part_number": {
						"query": "S1-SS2"
					}
				}
			},
			"filter": {
				"nested": {
					"path": "categories",
					"query": {
						"term": {
							"categories.omit": false
						}
					}
				}
			}
		}
	}
}

Without the filter clause, this query only returns scored results where the "part_number" matches "S1-SS2". With the filter clause, however, I'm getting those scored matches alongside hundreds of results with score of "0.0" -- seemingly every document in my index that matches the filter clause. I'm hoping there is a way I can remove these non-matching results from my query.

Thank you!

if you are not interested in those documents, why not do a must clause instead?

That said, there is also the min_score parameter.

Ahh using must clause instead of the should clause is exactly what I needed.

Thank you very much!

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