How to add queries into percolator using elasticsearch-php


(Amit Shah) #1

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.


(Daniel Mitterdorfer) #2

Hi @Amit_Shah,

I am not familiar with PHP but reading the PHP client docs on how to work with JSON objects and PHP clients docs on indexing documents, adding the example percolate query from the Elasticsearch docs, should work as follows:

$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


(Amit Shah) #3

Kool thanx Daniel,

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


(system) #4

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