# Deleted documents in search results

**URL:** <https://discuss.elastic.co/t/deleted-documents-in-search-results/9872>\
**Category:** Elasticsearch\
**Created:** [November 28, 2012, 10:02pm UTC](https://discuss.elastic.co/t/deleted-documents-in-search-results/9872 "2012-11-28T22:02:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Petr\_Jancarik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/petr_jancarik/32/93503_2.png) [@Petr\_Jancarik](https://discuss.elastic.co/u/Petr_Jancarik)\
**Post date:** [November 28, 2012, 10:02pm UTC](https://discuss.elastic.co/t/deleted-documents-in-search-results/9872/1 "2012-11-28T22:02:06Z")

</div>

Hi,

I have index for examle "twitter" with 2 shards and 1 replica in the 5 node  
cluster (master node has no data). Several documents was deleted from index  
like this:

curl -XDELETE '[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)'

but they still appear in search response and it doesn't matter wheather it  
is filter or query. When I try to get document directly by GET for example:

curl -XGET '[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)'

{  
\_index: "twitter",  
\_type: "tweet",  
\_id: "1",  
exists: false  
}

So I tried call several APIs for fixing it, but it is still same:

curl -XPOST '[http://localhost:9200/twitter/\_refresh](http://localhost:9200/twitter/_refresh)'  
curl -XPOST '[http://localhost:9200/twitter/\_flush](http://localhost:9200/twitter/_flush)'  
curl -XPOST '[http://localhost:9200/twitter/\_cache/clear](http://localhost:9200/twitter/_cache/clear)'  
curl -XPOST '[http://localhost:9200/twitter/](http://localhost:9200/twitter/)  
\_optimize?only\_expunge\_deletes=true'

How can I force Lucine/Elasticsearch to delete documents?

Can you help me please? 🙂

--

---

<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:** [November 29, 2012, 6:49am UTC](https://discuss.elastic.co/t/deleted-documents-in-search-results/9872/2 "2012-11-29T06:49:00Z")

</div>

Can you reproduce it with a curl recreation?  
Did you try to delete it, then refresh, then search?

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 28 nov. 2012 à 23:02, Petr Jancarik [jancarikpetr@gmail.com](mailto:jancarikpetr@gmail.com) a écrit :

Hi,

I have index for examle "twitter" with 2 shards and 1 replica in the 5 node cluster (master node has no data). Several documents was deleted from index like this:

curl -XDELETE '[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)'

but they still appear in search response and it doesn't matter wheather it is filter or query. When I try to get document directly by GET for example:

curl -XGET '[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)'

{  
\_index: "twitter",  
\_type: "tweet",  
\_id: "1",  
exists: false  
}

So I tried call several APIs for fixing it, but it is still same:

curl -XPOST '[http://localhost:9200/twitter/\_refresh](http://localhost:9200/twitter/_refresh)'  
curl -XPOST '[http://localhost:9200/twitter/\_flush](http://localhost:9200/twitter/_flush)'  
curl -XPOST '[http://localhost:9200/twitter/\_cache/clear](http://localhost:9200/twitter/_cache/clear)'  
curl -XPOST '[http://localhost:9200/twitter/\_optimize?only\_expunge\_deletes=true](http://localhost:9200/twitter/_optimize?only_expunge_deletes=true)'

How can I force Lucine/Elasticsearch to delete documents?

Can you help me please? 🙂

--

--

---

<div class="post-metadata">

**Author:** ![Petr\_Jancarik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/petr_jancarik/32/93503_2.png) [@Petr\_Jancarik](https://discuss.elastic.co/u/Petr_Jancarik)\
**Post date:** [November 29, 2012, 11:57am UTC](https://discuss.elastic.co/t/deleted-documents-in-search-results/9872/3 "2012-11-29T11:57:40Z")

</div>

So I tried to reindex deleted document again:

curl -XPUT '[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)' -d '{something: "aaa"}'

{"ok":true,"\_index":"twitter,"\_type":"entity","\_id":"1","\_version":2}

After that I performed a search:

curl -XPOST '[http://localhost:9200/twitter/tweet/](http://localhost:9200/twitter/tweet/)[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)  
\_search' -d '{filter: {term: {something: "aaa"}}}'

{  
"took" : 20,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 2,  
"successful" : 2,  
"failed" : 0  
},  
"hits" : {  
"total" : 2,  
"max\_score" : 1.0,  
"hits" : [ {  
"\_index" : "twitter",  
"\_type" : "tweet",  
"\_id" : "1",  
"\_score" : 1.0,  
"\_source" : {something: "aaa"}  
}, {  
"\_index" : "twitter",  
"\_type" : "tweet",  
"\_id" : "1",  
"\_score" : 1.0,  
"\_source" : {something: "aaa"}  
}]  
}  
}

and I dont't understand at all how can be possible to have 2 totaly same  
documents!

curl -XDELETE '[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)'

{"ok":true,"found":false,"\_index":"twitter,"\_type":"entity","\_id":"1","\_version":3}

I performed a search again, only one document was returned. So I tried this  
process of reindexing and delete several times and now I can not even  
delete "duplicit" document... 😃 So I wait for a few minutes and tried  
delete document again and duplicit one was succesfully deleted.

On Thursday, November 29, 2012 7:49:00 AM UTC+1, David Pilato wrote:

> Can you reproduce it with a curl recreation?  
> Did you try to delete it, then refresh, then search?
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 28 nov. 2012 à 23:02, Petr Jancarik \<[jancar...@gmail.com](mailto:jancar...@gmail.com) \<javascript:\>\>  
> a écrit :
> 
> Hi,
> 
> I have index for examle "twitter" with 2 shards and 1 replica in the 5  
> node cluster (master node has no data). Several documents was deleted  
> from index like this:
> 
> curl -XDELETE '[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)'
> 
> but they still appear in search response and it doesn't matter wheather it  
> is filter or query. When I try to get document directly by GET for example:
> 
> curl -XGET '[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)'
> 
> {  
> \_index: "twitter",  
> \_type: "tweet",  
> \_id: "1",  
> exists: false  
> }
> 
> So I tried call several APIs for fixing it, but it is still same:
> 
> curl -XPOST '[http://localhost:9200/twitter/\_refresh](http://localhost:9200/twitter/_refresh)'  
> curl -XPOST '[http://localhost:9200/twitter/\_flush](http://localhost:9200/twitter/_flush)'  
> curl -XPOST '[http://localhost:9200/twitter/\_cache/clear](http://localhost:9200/twitter/_cache/clear)'  
> curl -XPOST '[http://localhost:9200/twitter/](http://localhost:9200/twitter/)  
> \_optimize?only\_expunge\_deletes=true'
> 
> How can I force Lucine/Elasticsearch to delete documents?
> 
> Can you help me please? 🙂
> 
> --

--

---

<div class="post-metadata">

**Author:** ![Petr\_Jancarik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/petr_jancarik/32/93503_2.png) [@Petr\_Jancarik](https://discuss.elastic.co/u/Petr_Jancarik)\
**Post date:** [November 29, 2012, 12:27pm UTC](https://discuss.elastic.co/t/deleted-documents-in-search-results/9872/4 "2012-11-29T12:27:23Z")

</div>

But I can not still delete original document ☹ Neither clear cache, flush  
or refresh of index doesn't help...

On Thursday, November 29, 2012 12:57:40 PM UTC+1, Petr Jancarik wrote:

> So I tried to reindex deleted document again:
> 
> curl -XPUT '[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)' -d '{something: "aaa"}'
> 
> {"ok":true,"\_index":"twitter,"\_type":"entity","\_id":"1","\_version":2}
> 
> After that I performed a search:
> 
> curl -XPOST '[http://localhost:9200/twitter/tweet/](http://localhost:9200/twitter/tweet/)[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)  
> \_search' -d '{filter: {term: {something: "aaa"}}}'
> 
> {  
> "took" : 20,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 2,  
> "successful" : 2,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 2,  
> "max\_score" : 1.0,  
> "hits" : [ {  
> "\_index" : "twitter",  
> "\_type" : "tweet",  
> "\_id" : "1",  
> "\_score" : 1.0,  
> "\_source" : {something: "aaa"}  
> }, {  
> "\_index" : "twitter",  
> "\_type" : "tweet",  
> "\_id" : "1",  
> "\_score" : 1.0,  
> "\_source" : {something: "aaa"}  
> }]  
> }  
> }
> 
> and I dont't understand at all how can be possible to have 2 totaly same  
> documents!
> 
> curl -XDELETE '[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)'
> 
> {"ok":true,"found":false,"\_index":"twitter,"\_type":"entity","\_id":"1","\_version":3}
> 
> I performed a search again, only one document was returned. So I tried  
> this process of reindexing and delete several times and now I can not even  
> delete "duplicit" document... 😃 So I wait for a few minutes and tried  
> delete document again and duplicit one was succesfully deleted.
> 
> On Thursday, November 29, 2012 7:49:00 AM UTC+1, David Pilato wrote:
> 
> > Can you reproduce it with a curl recreation?  
> > Did you try to delete it, then refresh, then search?
> > 
> > --  
> > David 😉  
> > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > 
> > Le 28 nov. 2012 à 23:02, Petr Jancarik [jancar...@gmail.com](mailto:jancar...@gmail.com) a écrit :
> > 
> > Hi,
> > 
> > I have index for examle "twitter" with 2 shards and 1 replica in the 5  
> > node cluster (master node has no data). Several documents was deleted  
> > from index like this:
> > 
> > curl -XDELETE '[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)'
> > 
> > but they still appear in search response and it doesn't matter wheather  
> > it is filter or query. When I try to get document directly by GET for  
> > example:
> > 
> > curl -XGET '[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)'
> > 
> > {  
> > \_index: "twitter",  
> > \_type: "tweet",  
> > \_id: "1",  
> > exists: false  
> > }
> > 
> > So I tried call several APIs for fixing it, but it is still same:
> > 
> > curl -XPOST '[http://localhost:9200/twitter/\_refresh](http://localhost:9200/twitter/_refresh)'  
> > curl -XPOST '[http://localhost:9200/twitter/\_flush](http://localhost:9200/twitter/_flush)'  
> > curl -XPOST '[http://localhost:9200/twitter/\_cache/clear](http://localhost:9200/twitter/_cache/clear)'  
> > curl -XPOST '[http://localhost:9200/twitter/](http://localhost:9200/twitter/)  
> > \_optimize?only\_expunge\_deletes=true'
> > 
> > How can I force Lucine/Elasticsearch to delete documents?
> > 
> > Can you help me please? 🙂
> > 
> > --

--

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [November 29, 2012, 12:37pm UTC](https://discuss.elastic.co/t/deleted-documents-in-search-results/9872/5 "2012-11-29T12:37:08Z")

</div>

> ```
> After that I performed a search:
>     
>     
> curl -XPOST 'http://localhost:9200/twitter/tweet/_search' -d
> '{filter: {term: {something: "aaa"}}}'
>     
>     
>     
> {
> "took" : 20,
> "timed_out" : false,
> "_shards" : {
> "total" : 2,
> "successful" : 2,
> "failed" : 0
> },
> "hits" : {
> "total" : 2,
> "max_score" : 1.0,
> "hits" : [ {
> "_index" : "twitter",
> "_type" : "tweet",
> "_id" : "1",
> "_score" : 1.0, 
> "_source" : {something: "aaa"}
> }, {
> "_index" : "twitter",
> "_type" : "tweet",
> "_id" : "1",
> "_score" : 1.0, 
> "_source" : {something: "aaa"}
> }]
> }
> }
>     
>     
> and I dont't understand at all how can be possible to have 2
> totaly same documents!
> 
> ```

Did you index the first doc with routing or parent?

Try repeating your search but ask for the \_routing:

curl -XGET '[http://127.0.0.1:9200/ia/\_search?pretty=1](http://127.0.0.1:9200/ia/_search?pretty=1)' -d '  
{  
"fields" : [  
"\_routing"  
],  
"filter" : {  
"term" : {  
"\_id" : 1  
}  
}  
}  
'

clint

--

---

<div class="post-metadata">

**Author:** ![Petr\_Jancarik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/petr_jancarik/32/93503_2.png) [@Petr\_Jancarik](https://discuss.elastic.co/u/Petr_Jancarik)\
**Post date:** [November 29, 2012, 2:34pm UTC](https://discuss.elastic.co/t/deleted-documents-in-search-results/9872/6 "2012-11-29T14:34:33Z")

</div>

Great, it helps !!!

Thanks a lot Clint 🙂

On Thursday, November 29, 2012 1:37:08 PM UTC+1, Clinton Gormley wrote:

> > ```
> > After that I performed a search: 
> >     
> >     
> > curl -XPOST 'http://localhost:9200/twitter/tweet/_search' -d 
> > '{filter: {term: {something: "aaa"}}}' 
> >     
> >     
> >     
> > { 
> > "took" : 20, 
> > "timed_out" : false, 
> > "_shards" : { 
> > "total" : 2, 
> > "successful" : 2, 
> > "failed" : 0 
> > }, 
> > "hits" : { 
> > "total" : 2, 
> > "max_score" : 1.0, 
> > "hits" : [ { 
> > "_index" : "twitter", 
> > "_type" : "tweet", 
> > "_id" : "1", 
> > "_score" : 1.0, 
> > "_source" : {something: "aaa"} 
> > }, { 
> > "_index" : "twitter", 
> > "_type" : "tweet", 
> > "_id" : "1", 
> > "_score" : 1.0, 
> > "_source" : {something: "aaa"} 
> > }] 
> > } 
> > } 
> >     
> >     
> > and I dont't understand at all how can be possible to have 2 
> > totaly same documents! 
> > 
> > ```
> 
> Did you index the first doc with routing or parent?
> 
> Try repeating your search but ask for the \_routing:
> 
> curl -XGET '[http://127.0.0.1:9200/ia/\_search?pretty=1](http://127.0.0.1:9200/ia/_search?pretty=1)' -d '  
> {  
> "fields" : [  
> "\_routing"  
> ],  
> "filter" : {  
> "term" : {  
> "\_id" : 1  
> }  
> }  
> }  
> '
> 
> clint

--

---

<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:** [July 6, 2017, 3:02am UTC](https://discuss.elastic.co/t/deleted-documents-in-search-results/9872/7 "2017-07-06T03:02:11Z")

</div>


