# How to add queries into percolator using elasticsearch-php

**URL:** <https://discuss.elastic.co/t/how-to-add-queries-into-percolator-using-elasticsearch-php/95881>\
**Category:** Elasticsearch\
**Created:** [August 4, 2017, 12:38pm UTC](https://discuss.elastic.co/t/how-to-add-queries-into-percolator-using-elasticsearch-php/95881 "2017-08-04T12:38:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amit\_Shah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amit_shah/32/20805_2.png) [@Amit\_Shah](https://discuss.elastic.co/u/Amit_Shah)\
**Post date:** [August 4, 2017, 12:38pm UTC](https://discuss.elastic.co/t/how-to-add-queries-into-percolator-using-elasticsearch-php/95881/1 "2017-08-04T12:38:35Z")

</div>

I am new to using elasticsearch-php. I was looking to work with percolator. I was able to map through - it was straight forward. But now i was stuck when was looking to find a way to add queries in percolator.

I failed to actually find any method in the same. If there are mechanism to do the same, please guide.

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [August 11, 2017, 6:41am UTC](https://discuss.elastic.co/t/how-to-add-queries-into-percolator-using-elasticsearch-php/95881/2 "2017-08-11T06:41:34Z")

</div>

Hi @Amit_Shah,

I am not familiar with PHP but reading the PHP client docs on [how to work with JSON objects](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/php_json_objects.html) and PHP clients docs on [indexing documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/_indexing_documents.html), adding the [example percolate query from the Elasticsearch docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-percolate-query.html), should work as follows:

```auto
$params = [
    'index' => 'my_index',
    'type' => 'query',
    'id' => '1',
    'body' => [
        'query' => [
            'match' => [
                 'message' => 'bonsai tree'
             ]
        ]
    ]
];

// Document will be indexed to my_index/query/1
$response = $client->index($params);

```

Daniel

---

<div class="post-metadata">

**Author:** ![Amit\_Shah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amit_shah/32/20805_2.png) [@Amit\_Shah](https://discuss.elastic.co/u/Amit_Shah)\
**Post date:** [August 17, 2017, 5:50am UTC](https://discuss.elastic.co/t/how-to-add-queries-into-percolator-using-elasticsearch-php/95881/3 "2017-08-17T05:50:29Z")

</div>

Kool thanx Daniel,

I definitely will look into the same .. hope that it helps me sort things without writing custom CURL stuff..

---

<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:** [September 14, 2017, 5:50am UTC](https://discuss.elastic.co/t/how-to-add-queries-into-percolator-using-elasticsearch-php/95881/4 "2017-09-14T05:50:37Z")

</div>

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