diff --git a/x-pack/plugins/serverless_search/public/application/components/languages/php.ts b/x-pack/plugins/serverless_search/public/application/components/languages/php.ts index e31f02e02595..4bf4cca29233 100644 --- a/x-pack/plugins/serverless_search/public/application/components/languages/php.ts +++ b/x-pack/plugins/serverless_search/public/application/components/languages/php.ts @@ -13,15 +13,9 @@ import { INDEX_NAME_PLACEHOLDER } from '../../constants'; export const phpDefinition: LanguageDefinition = { apiReference: docLinks.phpApiReference, basicConfig: docLinks.phpBasicConfig, - buildSearchQuery: `$params = [ - 'index' => 'books', - 'body' => [ - 'q' => 'snow' - ] -]; - -$response = $client->search($params); -print_r($response->asArray());`, + buildSearchQuery: `$params = [ 'q' => 'snow' ]; + $response = $client->search(index: "books", params: $params); + print_r($response['hits']['hits']); # list of books`, configureClient: ({ url, apiKey }) => `$client = ClientBuilder::create() ->setHosts(['${url}']) ->setApiKey('${apiKey}') @@ -35,111 +29,39 @@ print_r($response->asArray());`, }, iconType: 'php.svg', id: Languages.PHP, - ingestData: `$params = [ -'body' => [ -[ -'index' => [ -'_index' => 'books', -'_id' => '9780553351927', -], -], -[ -'name' => 'Snow Crash', -'author' => 'Neal Stephenson', -'release_date' => '1992-06-01', -'page_count' => 470, -], -[ -'index' => [ -'_index' => 'books', -'_id' => '9780441017225', -], -], -[ -'name' => 'Revelation Space', -'author' => 'Alastair Reynolds', -'release_date' => '2000-03-15', -'page_count' => 585, -], -[ -'index' => [ -'_index' => 'books', -'_id' => '9780451524935', -], -], -[ -'name' => '1984', -'author' => 'George Orwell', -'release_date' => '1985-06-01', -'page_count' => 328, -], -[ -'index' => [ -'_index' => 'books', -'_id' => '9781451673319', -], -], -[ -'name' => 'Fahrenheit 451', -'author' => 'Ray Bradbury', -'release_date' => '1953-10-15', -'page_count' => 227, -], -[ -'index' => [ -'_index' => 'books', -'_id' => '9780060850524', -], -], -[ -'name' => 'Brave New World', -'author' => 'Aldous Huxley', -'release_date' => '1932-06-01', -'page_count' => 268, -], -[ -'index' => [ -'_index' => 'books', -'_id' => '9780385490818', -], -], -[ -'name' => 'The Handmaid\'s Tale', -'author' => 'Margaret Atwood', -'release_date' => '1985-06-01', -'page_count' => 311, -], -], + ingestData: `$body = [ + [ "index" => [ "_index" => "books" ]], + [ "name" => "Snow Crash", "author" => "Neal Stephenson", "release_date" => "1992-06-01", "page_count" => 470], + [ "index" => [ "_index" => "books" ]], + [ "name" => "Revelation Space", "author" => "Alastair Reynolds", "release_date" => "2000-03-15", "page_count" => 585], + [ "index" => [ "_index" => "books" ]], + [ "name" => "1984", "author" => "George Orwell", "release_date" => "1949-06-08", "page_count" => 328], + [ "index" => [ "_index" => "books" ]], + [ "name" => "Fahrenheit 451", "author" => "Ray Bradbury", "release_date" => "1953-10-15", "page_count" => 227], + [ "index" => [ "_index" => "books" ]], + [ "name" => "Brave New World", "author" => "Aldous Huxley", "release_date" => "1932-06-01", "page_count" => 268], + [ "index" => [ "_index" => "books" ]], + [ "name" => "The Handmaid's Tale", "author" => "Margaret Atwood", "release_date" => "1985-06-01", "page_count" => 311] ]; -$response = $client->bulk($params); +$response = $client->bulk(body: $body); echo $response->getStatusCode(); echo (string) $response->getBody();`, ingestDataIndex: ({ apiKey, url, indexName }) => `$client = ClientBuilder::create() - ->setHosts(['${url}']) + ->setEndpoint('${url}') ->setApiKey('${apiKey}') ->build(); -$params = [ -'body' => [ -[ -'index' => [ -'_index' => '${indexName ?? INDEX_NAME_PLACEHOLDER}', -'_id' => '1', -], -], -[ -'name' => 'foo', -'title' => 'bar', -], -], +$body = [ + [ 'index' => [ '_index' => '${indexName ?? INDEX_NAME_PLACEHOLDER}', '_id' => '1' ]], + [ 'name' => 'foo', 'title' => 'bar' ] ]; -$response = $client->bulk($params); +$response = $client->bulk(body: $body); echo $response->getStatusCode(); echo (string) $response->getBody(); `, - installClient: 'composer require elasticsearch/elasticsearch', + installClient: 'composer require elastic/elasticsearch-serverless:0.1.0-alpha1', name: i18n.translate('xpack.serverlessSearch.languages.php', { defaultMessage: 'PHP', }),