opensearch-project / opensearch-php

Official PHP Client for OpenSearch
Other
91 stars 54 forks source link

[FEATURE] Expose an HTTP namespace with a higher level get/put/post #192

Open dblock opened 1 month ago

dblock commented 1 month ago

Is your feature request related to a problem?

To make a raw HTTP request one has to write this.

$response = $client->request('GET', '/shakespeare/_search', [
    'body' => [
        'query' => [
            'match' => [
                'text_entry' => 'long live king'
            ]
        ]
    ]
]);

What solution would you like?

I'd like a higher level DSL so I could write this:

$response = $client->http()->get('/shakespeare/_search', [
    'body' => [
        'query' => [
            'match' => [
                'text_entry' => 'long live king'
            ]
        ]
    ]
]);

This would be consistent with other clients (see https://code.dblock.org/2023/10/16/making-raw-json-rest-requests-to-opensearch.html) and make it a bit easier on the user.

Let's make sure to have a full working sample along the lines of https://github.com/dblock/opensearch-php-client-demo/blob/main/json.php and a user guide.