# \_delete\_by\_query must match exactly

**URL:** <https://discuss.elastic.co/t/delete-by-query-must-match-exactly/223030>\
**Category:** Elasticsearch\
**Created:** [March 10, 2020, 11:17pm UTC](https://discuss.elastic.co/t/delete-by-query-must-match-exactly/223030 "2020-03-10T23:17:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![puks1978](https://avatars.discourse-cdn.com/v4/letter/p/f14d63/32.png) [@puks1978](https://discuss.elastic.co/u/puks1978)\
**Post date:** [March 10, 2020, 11:17pm UTC](https://discuss.elastic.co/t/delete-by-query-must-match-exactly/223030/1 "2020-03-10T23:17:08Z")

</div>

Hi,

I am trying to delete an index by using the \_delete\_by\_query command and passing in a term I would like removed. The issue I am having is that if there are matching indexes that have any part of the term are being removed however I would only like the exact match to be removed.

For example:  
Index: How to  
Index: How to do  
Index: How to do something

\_delete\_by\_query: How to do something

Desired result is to only have the index "How to do something" removed. Currently all 3 indexes are removed.

My CURL request is:

```
'{
"query": {
	"match": {
		"title": "' . $q . '"
	}
}
}'

```

Thanks

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 11, 2020, 1:23am UTC](https://discuss.elastic.co/t/delete-by-query-must-match-exactly/223030/2 "2020-03-11T01:23:52Z")

</div>

It depends on the analyzer you used.  
But here may be try a `match_phrase` instead.

---

<div class="post-metadata">

**Author:** ![puks1978](https://avatars.discourse-cdn.com/v4/letter/p/f14d63/32.png) [@puks1978](https://discuss.elastic.co/u/puks1978)\
**Post date:** [March 11, 2020, 9:07pm UTC](https://discuss.elastic.co/t/delete-by-query-must-match-exactly/223030/3 "2020-03-11T21:07:58Z")

</div>

Thank you. This worked great. Had to use a different analyzer (as mentioned).

---

<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:** [April 8, 2020, 9:08pm UTC](https://discuss.elastic.co/t/delete-by-query-must-match-exactly/223030/4 "2020-04-08T21:08:00Z")

</div>

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