opensearch-php icon indicating copy to clipboard operation
opensearch-php copied to clipboard

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

Open dblock opened this issue 1 year ago • 2 comments

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.

dblock avatar May 20 '24 13:05 dblock

Do we need this issue still? the linked PR is merged

shyim avatar Feb 10 '25 13:02 shyim

Yes, that PR does this:


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

we want this:


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

It's just syntax sugar.

dblock avatar Feb 10 '25 16:02 dblock