# Percolate already indexed documents in bulk

**URL:** <https://discuss.elastic.co/t/percolate-already-indexed-documents-in-bulk/127554>\
**Category:** Elasticsearch\
**Created:** [April 10, 2018, 11:08pm UTC](https://discuss.elastic.co/t/percolate-already-indexed-documents-in-bulk/127554 "2018-04-10T23:08:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aravind](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aravind/32/45644_2.png) [@Aravind](https://discuss.elastic.co/u/Aravind)\
**Post date:** [April 10, 2018, 11:08pm UTC](https://discuss.elastic.co/t/percolate-already-indexed-documents-in-bulk/127554/1 "2018-04-10T23:08:40Z")

</div>

We would like to perform percolate on documents which are already indexed in elastic.

Ofcourse it is possible to do this as document here -  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-percolate-query.html#\_percolating\_an\_existing\_document](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-percolate-query.html#_percolating_an_existing_document)

My first question is can I perform the same in bulk, not just a single document.

Further extending that question, can I request percolation on all documents within an index ?

---

<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:** [April 11, 2018, 3:03am UTC](https://discuss.elastic.co/t/percolate-already-indexed-documents-in-bulk/127554/2 "2018-04-11T03:03:01Z")

</div>

a percolate query is applied at search time within the search API.

the documents parameter helps you to pass a list of `documents` instead of a single doc with `document`  
Also you can use \_msearch if you wish but I suspect the previous option will be faster.

---

<div class="post-metadata">

**Author:** ![Aravind](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aravind/32/45644_2.png) [@Aravind](https://discuss.elastic.co/u/Aravind)\
**Post date:** [April 11, 2018, 4:33pm UTC](https://discuss.elastic.co/t/percolate-already-indexed-documents-in-bulk/127554/3 "2018-04-11T16:33:55Z")

</div>

Sure I'm exploring msearch as well.

Going back to the percolate search, are you saying that its possible to pass "documents" parameter in the context of **already indexed document**?

Please note in my case both the search query and the actual document that contains the data are indexed within elastic as 2 separate indices.

As per - [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-percolate-query.html#\_parameters\_10](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-percolate-query.html#_parameters_10)

the following are the only parameters (with few more optional which I'm not mentioning here)  
index - The index the document resides in. This is a required parameter.  
type - The type of the document to fetch. This is a required parameter.  
id - The id of the document to fetch. This is a required parameter.

Am I missing something ?

---

<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:** [April 11, 2018, 4:51pm UTC](https://discuss.elastic.co/t/percolate-already-indexed-documents-in-bulk/127554/4 "2018-04-11T16:51:57Z")

</div>

I think you can. But @mvg can probably tell more.

---

<div class="post-metadata">

**Author:** ![Aravind](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aravind/32/45644_2.png) [@Aravind](https://discuss.elastic.co/u/Aravind)\
**Post date:** [April 11, 2018, 10:56pm UTC](https://discuss.elastic.co/t/percolate-already-indexed-documents-in-bulk/127554/5 "2018-04-11T22:56:51Z")

</div>

Thanks David.

Hi @mvg , I came across this in the documentation -  
[https://www.elastic.co/guide/en/elasticsearch/reference/6.2/breaking\_60\_percolator\_changes.html#\_deprecated\_percolator\_and\_mpercolate\_apis\_have\_been\_removed](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/breaking_60_percolator_changes.html#_deprecated_percolator_and_mpercolate_apis_have_been_removed)

msearch replacing mpercolate. I'm trying to get my head around how msearch works with percolate.

Could you pls point to any simple example ?

---

<div class="post-metadata">

**Author:** ![Aravind](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aravind/32/45644_2.png) [@Aravind](https://discuss.elastic.co/u/Aravind)\
**Post date:** [April 11, 2018, 11:10pm UTC](https://discuss.elastic.co/t/percolate-already-indexed-documents-in-bulk/127554/6 "2018-04-11T23:10:50Z")

</div>

I got it working. My bad ! It was the way with which I structured the query in Kibana.

Thanks @dadoonet for responding. I'll take @mvg help for something interesting later.

---

<div class="post-metadata">

**Author:** ![Aravind](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aravind/32/45644_2.png) [@Aravind](https://discuss.elastic.co/u/Aravind)\
**Post date:** [April 11, 2018, 11:13pm UTC](https://discuss.elastic.co/t/percolate-already-indexed-documents-in-bulk/127554/7 "2018-04-11T23:13:28Z")

</div>

For the benefit of someone looking for something similar at a later point., here is an example of msearch with percolate ...

```
GET _msearch
{ "index" : "segmentation_filter"}
{"query" : { "percolate" : {"field": "criteria", "index" : "account", "type" : "default", "id" : 1 } } }
{ "index" : "segmentation_filter"}
{"query" : { "percolate" : {"field": "criteria", "index" : "account", "type" : "default", "id" : 2 } } }
{ "index" : "segmentation_filter"}
{"query" : { "percolate" : {"field": "criteria", "index" : "account", "type" : "default", "id" : 3 } } }
```

---

<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:** [May 9, 2018, 11:13pm UTC](https://discuss.elastic.co/t/percolate-already-indexed-documents-in-bulk/127554/8 "2018-05-09T23:13:44Z")

</div>

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