# Omit Zero Score Results From Filtered Query?

**URL:** https://discuss.elastic.co/t/omit-zero-score-results-from-filtered-query/218224
**Category:** Elasticsearch
**Created:** [February 6, 2020, 5:04pm UTC](https://discuss.elastic.co/t/omit-zero-score-results-from-filtered-query/218224 "2020-02-06T17:04:53Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![codyspeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/codyspeck/32/45611_2.png) [@codyspeck](https://discuss.elastic.co/u/codyspeck)
#### Post date: [February 6, 2020, 5:04pm UTC](https://discuss.elastic.co/t/omit-zero-score-results-from-filtered-query/218224/1 "2020-02-06T17:04:53Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [February 7, 2020, 2:55pm UTC](https://discuss.elastic.co/t/omit-zero-score-results-from-filtered-query/218224/2 "2020-02-07T14:55:52Z")

</div>

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

That said, there is also the [min\_score](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/search-request-body.html#request-body-search-min-score) parameter.

---

<div class="post-metadata">

### Author: ![codyspeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/codyspeck/32/45611_2.png) [@codyspeck](https://discuss.elastic.co/u/codyspeck)
#### Post date: [February 11, 2020, 3:15pm UTC](https://discuss.elastic.co/t/omit-zero-score-results-from-filtered-query/218224/3 "2020-02-11T15:15:19Z")

</div>

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

Thank you very much!

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [March 10, 2020, 3:15pm UTC](https://discuss.elastic.co/t/omit-zero-score-results-from-filtered-query/218224/4 "2020-03-10T15:15:25Z")

</div>

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