Created
June 22, 2016 03:29
-
-
Save brianwhigham/bc3f7e8e6d252e8bbfaf1d6545a32ebb to your computer and use it in GitHub Desktop.
quick test of AWS elasticsearch with PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
$hosts = [ | |
'https://yourhostname.us-east-1.es.amazonaws.com:443' | |
]; | |
$client = Elasticsearch\ClientBuilder::create() // Instantiate a new ClientBuilder | |
->setHosts($hosts) // Set the hosts | |
->build(); | |
$params = [ | |
'index' => 'brianwhigham_test_index', | |
'body' => [ | |
'settings' => [ | |
'number_of_shards' => 2, | |
'number_of_replicas' => 0 | |
] | |
] | |
]; | |
$response = $client->indices()->create($params); | |
print_r($response); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I came up with this test, thanks to the ES docs, after I ran into this error trying to run a php artisan command: