# Query deleted the entire events in Index

**URL:** <https://discuss.elastic.co/t/query-deleted-the-entire-events-in-index/70109>\
**Category:** Elasticsearch\
**Created:** [December 28, 2016, 7:00am UTC](https://discuss.elastic.co/t/query-deleted-the-entire-events-in-index/70109 "2016-12-28T07:00:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![VijayKarthikeyan](https://avatars.discourse-cdn.com/v4/letter/v/8491ac/32.png) [@VijayKarthikeyan](https://discuss.elastic.co/u/VijayKarthikeyan)\
**Post date:** [December 28, 2016, 7:00am UTC](https://discuss.elastic.co/t/query-deleted-the-entire-events-in-index/70109/1 "2016-12-28T07:00:41Z")

</div>

Hi,

I have been running ELK for a while and during the course of learning, i have been exercising with some sample data stashed in Elasticsearch.

I used the below query once to delete a particular set of events in the Kibana Console.

> POST logstash-2016.12.21/\_delete\_by\_query  
> {  
> "query":{  
> "match":{ "path":"C:\Users\547213\elk\tutorialdata\vendor\_sales\vendorsaleswithnewformats.LOG"  
> }  
> }  
> }

But this deleted entire events in the index instead of deleting the events with "path" matching up the phrase given above. Is it something wrong in the query?

---

<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:** [December 28, 2016, 7:33am UTC](https://discuss.elastic.co/t/query-deleted-the-entire-events-in-index/70109/2 "2016-12-28T07:33:18Z")

</div>

If you are using the default analyzer for path field, I'd expect that.

Run a search before the delete and will have an idea of is going to be removed.

---

<div class="post-metadata">

**Author:** ![VijayKarthikeyan](https://avatars.discourse-cdn.com/v4/letter/v/8491ac/32.png) [@VijayKarthikeyan](https://discuss.elastic.co/u/VijayKarthikeyan)\
**Post date:** [January 2, 2017, 8:33am UTC](https://discuss.elastic.co/t/query-deleted-the-entire-events-in-index/70109/3 "2017-01-02T08:33:01Z")

</div>

but why would the select or delete takes entire index as i have given a search phrase with double quotes to search.

It should only pick the documents which matches with the search phrase, shouldn't it?

---

<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:** [January 2, 2017, 8:55am UTC](https://discuss.elastic.co/t/query-deleted-the-entire-events-in-index/70109/4 "2017-01-02T08:55:10Z")

</div>

Have a look at the \_analyze API and you will have a better understanding of what is indexed and what is searched.

In the case of the path field, I'd use a keyword field type probably.

Note that match query here is not a phrase query.

---

<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:** [January 30, 2017, 8:55am UTC](https://discuss.elastic.co/t/query-deleted-the-entire-events-in-index/70109/5 "2017-01-30T08:55:10Z")

</div>

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