Providing custom query parameters

edit

Providing custom query parameters

edit

Sometimes you need to provide custom query params, such as authentication tokens for a third-party plugin or proxy. All query parameters are white-listed in Elasticsearch-php, which is to protect you from specifying a param which is not accepted by Elasticsearch.

If you need custom parameters, you need to bypass this whitelisting mechanism. To do so, add them to the custom parameter as an array of values:

$client = ClientBuilder::create()->build();

$params = [
    'index' => 'test',
    'type' => 'test',
    'id' => 1,
    'parent' => 'abc',              // white-listed Elasticsearch parameter
    'client' => [
        'custom' => [
            'customToken' => 'abc', // user-defined, not white listed, not checked
            'otherToken' => 123
        ]
    ]
];
$exists = $client->exists($params);