Skip to content

Commit

Permalink
Updated the getting started page for PHP in serverless_search (elasti…
Browse files Browse the repository at this point in the history
…c#168456)

As titled
  • Loading branch information
ezimuel authored Oct 10, 2023
1 parent 9f06e30 commit b641a69
Showing 1 changed file with 23 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}')
Expand All @@ -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',
}),
Expand Down

0 comments on commit b641a69

Please sign in to comment.