mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
# Backport This will backport the following commits from `main` to `8.10`: - [[Enterprise Search] Update Api examples (#165154)](https://github.com/elastic/kibana/pull/165154) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Rodney Norris","email":"rodney.norris@elastic.co"},"sourceCommit":{"committedDate":"2023-08-30T18:52:50Z","message":"[Enterprise Search] Update Api examples (#165154)\n\n## Summary\r\n\r\nUpdates and fixes new API Key overview examples. Code can be copied\r\nmostly now for a quick start.\r\n\r\nReplaces #164840 as I had to fix a merge conflict mistake\r\n\r\n---------\r\n\r\nCo-authored-by: Efe Gürkan YALAMAN <efeguerkan.yalaman@elastic.co>\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"ec8f5963ef443270370df290275dcca11a6b8bff","branchLabelMapping":{"^v8.11.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","Team:EnterpriseSearch","v8.10.0","v8.11.0"],"number":165154,"url":"https://github.com/elastic/kibana/pull/165154","mergeCommit":{"message":"[Enterprise Search] Update Api examples (#165154)\n\n## Summary\r\n\r\nUpdates and fixes new API Key overview examples. Code can be copied\r\nmostly now for a quick start.\r\n\r\nReplaces #164840 as I had to fix a merge conflict mistake\r\n\r\n---------\r\n\r\nCo-authored-by: Efe Gürkan YALAMAN <efeguerkan.yalaman@elastic.co>\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"ec8f5963ef443270370df290275dcca11a6b8bff"}},"sourceBranch":"main","suggestedTargetBranches":["8.10"],"targetPullRequestStates":[{"branch":"8.10","label":"v8.10.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.11.0","labelRegex":"^v8.11.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/165154","number":165154,"mergeCommit":{"message":"[Enterprise Search] Update Api examples (#165154)\n\n## Summary\r\n\r\nUpdates and fixes new API Key overview examples. Code can be copied\r\nmostly now for a quick start.\r\n\r\nReplaces #164840 as I had to fix a merge conflict mistake\r\n\r\n---------\r\n\r\nCo-authored-by: Efe Gürkan YALAMAN <efeguerkan.yalaman@elastic.co>\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"ec8f5963ef443270370df290275dcca11a6b8bff"}}]}] BACKPORT--> Co-authored-by: Rodney Norris <rodney.norris@elastic.co>
This commit is contained in:
parent
bf2b490855
commit
2eee40e4f0
10 changed files with 132 additions and 120 deletions
|
@ -23,6 +23,7 @@ export interface LanguageDefinitionSnippetArguments {
|
|||
url: string;
|
||||
apiKey: string;
|
||||
indexName?: string;
|
||||
cloudId?: string;
|
||||
}
|
||||
|
||||
type CodeSnippet = string | ((args: LanguageDefinitionSnippetArguments) => string);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
import React, { useState } from 'react';
|
||||
|
||||
import { css } from '@emotion/react';
|
||||
import dedent from 'dedent';
|
||||
import { useActions, useValues } from 'kea';
|
||||
|
||||
import {
|
||||
|
@ -27,6 +28,7 @@ import { i18n } from '@kbn/i18n';
|
|||
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||
import {
|
||||
SelectClientPanel,
|
||||
LanguageDefinition,
|
||||
LanguageClientPanel,
|
||||
InstallClientPanel,
|
||||
OverviewPanel,
|
||||
|
@ -35,8 +37,6 @@ import {
|
|||
getConsoleRequest,
|
||||
} from '@kbn/search-api-panels';
|
||||
|
||||
import { LanguageDefinition } from '@kbn/search-api-panels';
|
||||
|
||||
import { PLUGIN_ID } from '../../../../../../../common/constants';
|
||||
import { KibanaDeps } from '../../../../../../../common/types';
|
||||
|
||||
|
@ -61,12 +61,13 @@ export const APIGettingStarted = () => {
|
|||
const { openGenerateModal, closeGenerateModal } = useActions(OverviewLogic);
|
||||
const { indexName } = useValues(IndexViewLogic);
|
||||
const { services } = useKibana<KibanaDeps>();
|
||||
const { isCloud } = useValues(KibanaLogic);
|
||||
|
||||
const cloudContext = useCloudDetails();
|
||||
|
||||
const codeArgs = {
|
||||
apiKey,
|
||||
cloudId: cloudContext.cloudId,
|
||||
indexName,
|
||||
url: cloudContext.elasticsearchUrl || DEFAULT_URL,
|
||||
};
|
||||
const assetBasePath = http.basePath.prepend(`/plugins/${PLUGIN_ID}/assets/client_libraries/`);
|
||||
|
@ -207,39 +208,23 @@ export const APIGettingStarted = () => {
|
|||
/>
|
||||
|
||||
<OverviewPanel
|
||||
description={
|
||||
isCloud
|
||||
? i18n.translate(
|
||||
'xpack.enterpriseSearch.content.overview.gettingStarted.cloudId.description',
|
||||
{
|
||||
defaultMessage: "You'll need this to identify your deployment.",
|
||||
}
|
||||
)
|
||||
: i18n.translate(
|
||||
'xpack.enterpriseSearch.content.overview.gettingStarted.cloudId.descriptionElastic',
|
||||
{
|
||||
defaultMessage: "You'll need this to connect your elasticsearch deployment.",
|
||||
}
|
||||
)
|
||||
}
|
||||
description={i18n.translate(
|
||||
'xpack.enterpriseSearch.content.overview.gettingStarted.cloudId.description',
|
||||
{
|
||||
defaultMessage: "You'll need this to identify your deployment.",
|
||||
}
|
||||
)}
|
||||
rightPanelContent={
|
||||
<EuiSplitPanel.Outer>
|
||||
<EuiSplitPanel.Inner>
|
||||
<EuiTitle size="xs">
|
||||
<h5>
|
||||
{isCloud
|
||||
? i18n.translate(
|
||||
'xpack.enterpriseSearch.content.overview.gettingStarted.cloudId.cloudTitle',
|
||||
{
|
||||
defaultMessage: 'Store your unique Cloud ID',
|
||||
}
|
||||
)
|
||||
: i18n.translate(
|
||||
'xpack.enterpriseSearch.content.overview.gettingStarted.cloudId.elasticTitle',
|
||||
{
|
||||
defaultMessage: 'Store your elasticsearch URL',
|
||||
}
|
||||
)}
|
||||
{i18n.translate(
|
||||
'xpack.enterpriseSearch.content.overview.gettingStarted.cloudId.elasticTitle',
|
||||
{
|
||||
defaultMessage: 'Store your Elasticsearch URL',
|
||||
}
|
||||
)}
|
||||
</h5>
|
||||
</EuiTitle>
|
||||
<EuiText>
|
||||
|
@ -261,28 +246,24 @@ export const APIGettingStarted = () => {
|
|||
overflow-wrap: anywhere;
|
||||
`}
|
||||
>
|
||||
{codeArgs.url}
|
||||
{codeArgs.cloudId
|
||||
? dedent`{
|
||||
CloudID: "${codeArgs.cloudId}",
|
||||
Url: "${codeArgs.url}",
|
||||
}`
|
||||
: codeArgs.url}
|
||||
</EuiCodeBlock>
|
||||
</EuiSplitPanel.Inner>
|
||||
</EuiThemeProvider>
|
||||
</EuiSplitPanel.Outer>
|
||||
}
|
||||
links={[]}
|
||||
title={
|
||||
isCloud
|
||||
? i18n.translate(
|
||||
'xpack.enterpriseSearch.overview.gettingStarted.cloudId.panelTitleCloud',
|
||||
{
|
||||
defaultMessage: 'Copy your Cloud ID',
|
||||
}
|
||||
)
|
||||
: i18n.translate(
|
||||
'xpack.enterpriseSearch.overview.gettingStarted.cloudId.panelTitleElastic',
|
||||
{
|
||||
defaultMessage: 'Copy your elasticsearch URL',
|
||||
}
|
||||
)
|
||||
}
|
||||
title={i18n.translate(
|
||||
'xpack.enterpriseSearch.overview.gettingStarted.cloudId.panelTitleElastic',
|
||||
{
|
||||
defaultMessage: 'Copy your Elasticsearch URL',
|
||||
}
|
||||
)}
|
||||
overviewPanelProps={{ color: 'plain', hasShadow: false }}
|
||||
/>
|
||||
|
||||
|
@ -290,7 +271,7 @@ export const APIGettingStarted = () => {
|
|||
description={i18n.translate(
|
||||
'xpack.enterpriseSearch.overview.gettingStarted.configureClient.description',
|
||||
{
|
||||
defaultMessage: 'Initialize your client with your unique API key and Cloud ID',
|
||||
defaultMessage: 'Initialize your client with your unique API key',
|
||||
}
|
||||
)}
|
||||
rightPanelContent={
|
||||
|
|
|
@ -11,7 +11,7 @@ import { Languages, LanguageDefinition } from '@kbn/search-api-panels';
|
|||
import { docLinks } from '../../../../../../shared/doc_links';
|
||||
|
||||
export const curlDefinition: LanguageDefinition = {
|
||||
buildSearchQuery: `curl -X POST "\$\{ES_URL\}/books/_search?pretty" \\
|
||||
buildSearchQuery: ({ indexName }) => `curl -X POST "\$\{ES_URL\}/${indexName}/_search?pretty" \\
|
||||
-H "Authorization: ApiKey "\$\{API_KEY\}"" \\
|
||||
-H "Content-Type: application/json" \\
|
||||
-d'
|
||||
|
@ -33,21 +33,21 @@ export API_KEY="${apiKey}"`,
|
|||
},
|
||||
iconType: 'curl.svg',
|
||||
id: Languages.CURL,
|
||||
ingestData: `curl -X POST "\$\{ES_URL\}/_bulk?pretty" \\
|
||||
ingestData: ({ indexName }) => `curl -X POST "\$\{ES_URL\}/_bulk?pretty" \\
|
||||
-H "Authorization: ApiKey "\$\{API_KEY\}"" \\
|
||||
-H "Content-Type: application/json" \\
|
||||
-d'
|
||||
{ "index" : { "_index" : "books" } }
|
||||
{ "index" : { "_index" : "${indexName}" } }
|
||||
{"name": "Snow Crash", "author": "Neal Stephenson", "release_date": "1992-06-01", "page_count": 470}
|
||||
{ "index" : { "_index" : "books" } }
|
||||
{ "index" : { "_index" : "${indexName}" } }
|
||||
{"name": "Revelation Space", "author": "Alastair Reynolds", "release_date": "2000-03-15", "page_count": 585}
|
||||
{ "index" : { "_index" : "books" } }
|
||||
{ "index" : { "_index" : "${indexName}" } }
|
||||
{"name": "1984", "author": "George Orwell", "release_date": "1985-06-01", "page_count": 328}
|
||||
{ "index" : { "_index" : "books" } }
|
||||
{ "index" : { "_index" : "${indexName}" } }
|
||||
{"name": "Fahrenheit 451", "author": "Ray Bradbury", "release_date": "1953-10-15", "page_count": 227}
|
||||
{ "index" : { "_index" : "books" } }
|
||||
{ "index" : { "_index" : "${indexName}" } }
|
||||
{"name": "Brave New World", "author": "Aldous Huxley", "release_date": "1932-06-01", "page_count": 268}
|
||||
{ "index" : { "_index" : "books" } }
|
||||
{ "index" : { "_index" : "${indexName}" } }
|
||||
{"name": "The Handmaid'"'"'s Tale", "author": "Margaret Atwood", "release_date": "1985-06-01", "page_count": 311}
|
||||
'`,
|
||||
ingestDataIndex: '',
|
||||
|
@ -60,7 +60,7 @@ brew install curl`,
|
|||
defaultMessage: 'cURL',
|
||||
}),
|
||||
languageStyling: 'shell',
|
||||
testConnection: `curl "\$\{ES_URL\}" \\
|
||||
testConnection: ({ indexName }) => `curl "\$\{ES_URL\}/${indexName}" \\
|
||||
-H "Authorization: ApiKey "\$\{API_KEY\}"" \\
|
||||
-H "Content-Type: application/json"`,
|
||||
};
|
||||
|
|
|
@ -11,31 +11,42 @@ import { Languages, LanguageDefinition } from '@kbn/search-api-panels';
|
|||
import { docLinks } from '../../../../../../shared/doc_links';
|
||||
|
||||
export const goDefinition: LanguageDefinition = {
|
||||
buildSearchQuery: `searchResp, err := es.Search().
|
||||
Index("books").
|
||||
Q("snow").
|
||||
Do(context.Background())
|
||||
buildSearchQuery: ({ indexName }) => `searchResp, err := es.Search(
|
||||
es.Search.WithContext(context.Background()),
|
||||
es.Search.WithIndex("${indexName}"),
|
||||
es.Search.WithQuery("snow"),
|
||||
es.Search.WithTrackTotalHits(true),
|
||||
es.Search.WithPretty(),
|
||||
)
|
||||
|
||||
fmt.Println(searchResp, err)`,
|
||||
configureClient: ({ url, apiKey }) => `import (
|
||||
configureClient: ({ url, apiKey, cloudId }) => `import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
elasticsearch "github.com/elastic/go-elasticsearch/v8"
|
||||
|
||||
"github.com/elastic/go-elasticsearch/v8"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cfg := elasticsearch.Config{
|
||||
Address: "${url}",
|
||||
APIKey: "${apiKey}",
|
||||
// ...
|
||||
|
||||
cfg := elasticsearch.Config{
|
||||
${
|
||||
cloudId
|
||||
? `CloudID:"${cloudId}",`
|
||||
: `Addresses: []string{
|
||||
"${url}",
|
||||
},`
|
||||
}
|
||||
es, err := elasticsearch.NewClient(cfg)
|
||||
if err != nil {
|
||||
log.Fatalf("Error creating the client: %s", err)
|
||||
}
|
||||
}`,
|
||||
APIKey: "${apiKey}",
|
||||
}
|
||||
|
||||
es, err := elasticsearch.NewClient(cfg)
|
||||
if err != nil {
|
||||
log.Fatalf("Error creating the client: %s", err)
|
||||
}
|
||||
`,
|
||||
docLink: docLinks.clientsGoIndex,
|
||||
github: {
|
||||
label: i18n.translate('xpack.enterpriseSearch.languages.go.githubLink', {
|
||||
|
@ -45,9 +56,7 @@ func main() {
|
|||
},
|
||||
iconType: 'go.svg',
|
||||
id: Languages.GO,
|
||||
ingestData: `ingestResult, err := es.Bulk().
|
||||
Index("books").
|
||||
Raw(strings.NewReader(\`
|
||||
ingestData: ({ indexName }) => `buf := bytes.NewBufferString(\`
|
||||
{"index":{"_id":"9780553351927"}}
|
||||
{"name":"Snow Crash","author":"Neal Stephenson","release_date":"1992-06-01","page_count": 470}
|
||||
{ "index": { "_id": "9780441017225"}}
|
||||
|
@ -59,8 +68,13 @@ func main() {
|
|||
{ "index": { "_id": "9780060850524"}}
|
||||
{"name": "Brave New World", "author": "Aldous Huxley", "release_date": "1932-06-01", "page_count": 268}
|
||||
{ "index": { "_id": "9780385490818"}}
|
||||
{"name": "The Handmaid's Tale", "author": "Margaret Atwood", "release_date": "1985-06-01", "page_count": 311}\n\`)).
|
||||
Do(context.Background())
|
||||
{"name": "The Handmaid's Tale", "author": "Margaret Atwood", "release_date": "1985-06-01", "page_count": 311}
|
||||
\`)
|
||||
|
||||
ingestResult, err := es.Bulk(
|
||||
bytes.NewReader(buf.Bytes()),
|
||||
es.Bulk.WithIndex("${indexName}"),
|
||||
)
|
||||
|
||||
fmt.Println(ingestResult, err)`,
|
||||
ingestDataIndex: '',
|
||||
|
@ -68,10 +82,11 @@ fmt.Println(ingestResult, err)`,
|
|||
name: i18n.translate('xpack.enterpriseSearch.languages.go', {
|
||||
defaultMessage: 'Go',
|
||||
}),
|
||||
testConnection: `infores, err := es.Info().Do(context.Background())
|
||||
if err != nil {
|
||||
log.Fatalf("Error getting response: %s", err)
|
||||
}
|
||||
testConnection: `// API Key should have cluster monitoring rights
|
||||
infores, err := es.Info()
|
||||
if err != nil {
|
||||
log.Fatalf("Error getting response: %s", err)
|
||||
}
|
||||
|
||||
fmt.Println(infores)`,
|
||||
fmt.Println(infores)`,
|
||||
};
|
||||
|
|
|
@ -11,9 +11,9 @@ import { Languages, LanguageDefinition } from '@kbn/search-api-panels';
|
|||
import { docLinks } from '../../../../../../shared/doc_links';
|
||||
|
||||
export const javascriptDefinition: LanguageDefinition = {
|
||||
buildSearchQuery: `// Let's search!
|
||||
buildSearchQuery: ({ indexName }) => `// Let's search!
|
||||
const searchResult = await client.search({
|
||||
index: 'my-index-name',
|
||||
index: '${indexName}',
|
||||
q: '9HY9SWR'
|
||||
});
|
||||
|
||||
|
@ -35,7 +35,7 @@ const client = new Client({
|
|||
},
|
||||
iconType: 'javascript.svg',
|
||||
id: Languages.JAVASCRIPT,
|
||||
ingestData: `// Sample flight data
|
||||
ingestData: ({ indexName }) => `// Sample flight data
|
||||
const dataset = [
|
||||
{'flight': '9HY9SWR', 'price': 841.2656419677076, 'delayed': false},
|
||||
{'flight': 'X98CCZO', 'price': 882.9826615595518, 'delayed': false},
|
||||
|
@ -46,7 +46,7 @@ const dataset = [
|
|||
const result = await client.helpers.bulk({
|
||||
datasource: dataset,
|
||||
onDocument (doc) {
|
||||
return { index: { _index: 'my-index-name' }};
|
||||
return { index: { _index: '${indexName}' }};
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -68,7 +68,8 @@ console.log(result);
|
|||
name: i18n.translate('xpack.enterpriseSearch.languages.javascript', {
|
||||
defaultMessage: 'JavaScript',
|
||||
}),
|
||||
testConnection: `const resp = await client.info();
|
||||
testConnection: `// API Key should have cluster monitor rights.
|
||||
const resp = await client.info();
|
||||
|
||||
console.log(resp);
|
||||
/**
|
||||
|
|
|
@ -11,8 +11,8 @@ import { Languages, LanguageDefinition } from '@kbn/search-api-panels';
|
|||
import { docLinks } from '../../../../../../shared/doc_links';
|
||||
|
||||
export const phpDefinition: LanguageDefinition = {
|
||||
buildSearchQuery: `$params = [
|
||||
'index' => 'books',
|
||||
buildSearchQuery: ({ indexName }) => `$params = [
|
||||
'index' => '${indexName}',
|
||||
'body' => [
|
||||
'q' => 'snow'
|
||||
]
|
||||
|
@ -33,11 +33,11 @@ print_r($response->asArray());`,
|
|||
},
|
||||
iconType: 'php.svg',
|
||||
id: Languages.PHP,
|
||||
ingestData: `$params = [
|
||||
ingestData: ({ indexName }) => `$params = [
|
||||
'body' => [
|
||||
[
|
||||
'index' => [
|
||||
'_index' => 'books',
|
||||
'_index' => '${indexName}',
|
||||
'_id' => '9780553351927',
|
||||
],
|
||||
],
|
||||
|
@ -49,7 +49,7 @@ print_r($response->asArray());`,
|
|||
],
|
||||
[
|
||||
'index' => [
|
||||
'_index' => 'books',
|
||||
'_index' => '${indexName}',
|
||||
'_id' => '9780441017225',
|
||||
],
|
||||
],
|
||||
|
@ -61,7 +61,7 @@ print_r($response->asArray());`,
|
|||
],
|
||||
[
|
||||
'index' => [
|
||||
'_index' => 'books',
|
||||
'_index' => '${indexName}',
|
||||
'_id' => '9780451524935',
|
||||
],
|
||||
],
|
||||
|
@ -73,7 +73,7 @@ print_r($response->asArray());`,
|
|||
],
|
||||
[
|
||||
'index' => [
|
||||
'_index' => 'books',
|
||||
'_index' => '${indexName}',
|
||||
'_id' => '9781451673319',
|
||||
],
|
||||
],
|
||||
|
@ -85,7 +85,7 @@ print_r($response->asArray());`,
|
|||
],
|
||||
[
|
||||
'index' => [
|
||||
'_index' => 'books',
|
||||
'_index' => '${indexName}',
|
||||
'_id' => '9780060850524',
|
||||
],
|
||||
],
|
||||
|
@ -97,7 +97,7 @@ print_r($response->asArray());`,
|
|||
],
|
||||
[
|
||||
'index' => [
|
||||
'_index' => 'books',
|
||||
'_index' => '${indexName}',
|
||||
'_id' => '9780385490818',
|
||||
],
|
||||
],
|
||||
|
@ -118,7 +118,8 @@ print_r($response->asArray());`,
|
|||
name: i18n.translate('xpack.enterpriseSearch.languages.php', {
|
||||
defaultMessage: 'PHP',
|
||||
}),
|
||||
testConnection: `$response = $client->info();
|
||||
testConnection: `// API Key should have cluster monitor rights.
|
||||
$response = $client->info();
|
||||
echo $response->getStatusCode();
|
||||
echo (string) $response->getBody();`,
|
||||
};
|
||||
|
|
|
@ -11,7 +11,7 @@ import { Languages, LanguageDefinition } from '@kbn/search-api-panels';
|
|||
import { docLinks } from '../../../../../../shared/doc_links';
|
||||
|
||||
export const pythonDefinition: LanguageDefinition = {
|
||||
buildSearchQuery: `client.search(index="books", q="snow")`,
|
||||
buildSearchQuery: ({ indexName }) => `client.search(index="${indexName}", q="snow")`,
|
||||
configureClient: ({ url, apiKey }) => `from elasticsearch import Elasticsearch
|
||||
|
||||
client = Elasticsearch(
|
||||
|
@ -27,18 +27,18 @@ client = Elasticsearch(
|
|||
},
|
||||
iconType: 'python.svg',
|
||||
id: Languages.PYTHON,
|
||||
ingestData: `documents = [
|
||||
{ "index": { "_index": "books", "_id": "9780553351927"}},
|
||||
ingestData: ({ indexName }) => `documents = [
|
||||
{ "index": { "_index": "${indexName}", "_id": "9780553351927"}},
|
||||
{"name": "Snow Crash", "author": "Neal Stephenson", "release_date": "1992-06-01", "page_count": 470},
|
||||
{ "index": { "_index": "books", "_id": "9780441017225"}},
|
||||
{ "index": { "_index": "${indexName}", "_id": "9780441017225"}},
|
||||
{"name": "Revelation Space", "author": "Alastair Reynolds", "release_date": "2000-03-15", "page_count": 585},
|
||||
{ "index": { "_index": "books", "_id": "9780451524935"}},
|
||||
{ "index": { "_index": "${indexName}", "_id": "9780451524935"}},
|
||||
{"name": "1984", "author": "George Orwell", "release_date": "1985-06-01", "page_count": 328},
|
||||
{ "index": { "_index": "books", "_id": "9781451673319"}},
|
||||
{ "index": { "_index": "${indexName}", "_id": "9781451673319"}},
|
||||
{"name": "Fahrenheit 451", "author": "Ray Bradbury", "release_date": "1953-10-15", "page_count": 227},
|
||||
{ "index": { "_index": "books", "_id": "9780060850524"}},
|
||||
{ "index": { "_index": "${indexName}", "_id": "9780060850524"}},
|
||||
{"name": "Brave New World", "author": "Aldous Huxley", "release_date": "1932-06-01", "page_count": 268},
|
||||
{ "index": { "_index": "books", "_id": "9780385490818"}},
|
||||
{ "index": { "_index": "${indexName}", "_id": "9780385490818"}},
|
||||
{"name": "The Handmaid's Tale", "author": "Margaret Atwood", "release_date": "1985-06-01", "page_count": 311},
|
||||
]
|
||||
|
||||
|
@ -52,5 +52,6 @@ client.bulk(operations=documents)`,
|
|||
name: i18n.translate('xpack.enterpriseSearch.languages.python', {
|
||||
defaultMessage: 'Python',
|
||||
}),
|
||||
testConnection: `client.info()`,
|
||||
testConnection: `# API key should have cluster monitor rights
|
||||
client.info()`,
|
||||
};
|
||||
|
|
|
@ -11,10 +11,10 @@ import { Languages, LanguageDefinition } from '@kbn/search-api-panels';
|
|||
import { docLinks } from '../../../../../../shared/doc_links';
|
||||
|
||||
export const rubyDefinition: LanguageDefinition = {
|
||||
buildSearchQuery: `client.search(index: 'books', q: 'snow')`,
|
||||
configureClient: ({ url, apiKey }) => `client = ElasticsearchServerless::Client.new(
|
||||
buildSearchQuery: ({ indexName }) => `client.search(index: '${indexName}', q: 'snow')`,
|
||||
configureClient: ({ url, apiKey, cloudId }) => `client = Elasticsearch::Client.new(
|
||||
api_key: '${apiKey}',
|
||||
url: '${url}'
|
||||
${cloudId ? `cloud_id: ${cloudId},` : `url: '${url}',`}
|
||||
)
|
||||
`,
|
||||
docLink: docLinks.clientsRubyOverview,
|
||||
|
@ -26,19 +26,20 @@ export const rubyDefinition: LanguageDefinition = {
|
|||
},
|
||||
iconType: 'ruby.svg',
|
||||
id: Languages.RUBY,
|
||||
ingestData: `documents = [
|
||||
{ index: { _index: 'books', data: {name: "Snow Crash", "author": "Neal Stephenson", "release_date": "1992-06-01", "page_count": 470} } },
|
||||
{ index: { _index: 'books', data: {name: "Revelation Space", "author": "Alastair Reynolds", "release_date": "2000-03-15", "page_count": 585} } },
|
||||
{ index: { _index: 'books', data: {name: "1984", "author": "George Orwell", "release_date": "1985-06-01", "page_count": 328} } },
|
||||
{ index: { _index: 'books', data: {name: "Fahrenheit 451", "author": "Ray Bradbury", "release_date": "1953-10-15", "page_count": 227} } },
|
||||
{ index: { _index: 'books', data: {name: "Brave New World", "author": "Aldous Huxley", "release_date": "1932-06-01", "page_count": 268} } },
|
||||
{ index: { _index: 'books', data: {name: "The Handmaid's Tale", "author": "Margaret Atwood", "release_date": "1985-06-01", "page_count": 311} } }
|
||||
ingestData: ({ indexName }) => `documents = [
|
||||
{ index: { _index: '${indexName}', data: {name: "Snow Crash", "author": "Neal Stephenson", "release_date": "1992-06-01", "page_count": 470} } },
|
||||
{ index: { _index: '${indexName}', data: {name: "Revelation Space", "author": "Alastair Reynolds", "release_date": "2000-03-15", "page_count": 585} } },
|
||||
{ index: { _index: '${indexName}', data: {name: "1984", "author": "George Orwell", "release_date": "1985-06-01", "page_count": 328} } },
|
||||
{ index: { _index: '${indexName}', data: {name: "Fahrenheit 451", "author": "Ray Bradbury", "release_date": "1953-10-15", "page_count": 227} } },
|
||||
{ index: { _index: '${indexName}', data: {name: "Brave New World", "author": "Aldous Huxley", "release_date": "1932-06-01", "page_count": 268} } },
|
||||
{ index: { _index: '${indexName}', data: {name: "The Handmaid's Tale", "author": "Margaret Atwood", "release_date": "1985-06-01", "page_count": 311} } }
|
||||
]
|
||||
client.bulk(body: documents)`,
|
||||
ingestDataIndex: '',
|
||||
installClient: `$ gem install elasticsearch -v x.x.x`,
|
||||
installClient: `$ gem install elasticsearch`,
|
||||
name: i18n.translate('xpack.enterpriseSearch.languages.ruby', {
|
||||
defaultMessage: 'Ruby',
|
||||
}),
|
||||
testConnection: `client.info`,
|
||||
testConnection: `# API Key should have cluster monitoring rights.
|
||||
client.info`,
|
||||
};
|
||||
|
|
|
@ -10,6 +10,7 @@ import React from 'react';
|
|||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import { ELASTICSEARCH_PLUGIN } from '../../../../../common/constants';
|
||||
import { docLinks } from '../../../shared/doc_links';
|
||||
import { ProductCard } from '../product_card';
|
||||
|
||||
import { BehavioralAnalyticsProductCard } from './behavioral_analytics_product_card';
|
||||
|
@ -26,6 +27,11 @@ export const ElasticsearchProductCard = () => {
|
|||
icon="logoElasticsearch"
|
||||
name={ELASTICSEARCH_PLUGIN.NAME}
|
||||
productId={ELASTICSEARCH_PLUGIN.ID}
|
||||
emptyCta
|
||||
cta={i18n.translate('xpack.enterpriseSearch.elasticsearchCard.cta', {
|
||||
defaultMessage: 'Learn more',
|
||||
})}
|
||||
url={docLinks.elasticsearchGettingStarted}
|
||||
rightPanelItems={[
|
||||
<SearchApplicationsProductCard hasBorder={false} hasShadow={false} />,
|
||||
<BehavioralAnalyticsProductCard hasBorder={false} hasShadow={false} />,
|
||||
|
|
|
@ -13,6 +13,7 @@ import {
|
|||
ENTERPRISE_SEARCH_PRODUCT_NAME,
|
||||
ENTERPRISE_SEARCH_CONTENT_PLUGIN,
|
||||
} from '../../../../../common/constants';
|
||||
import { docLinks } from '../../../shared/doc_links';
|
||||
import { ProductCard } from '../product_card';
|
||||
|
||||
import { AppSearchProductCard } from './app_search_product_card';
|
||||
|
@ -25,6 +26,10 @@ export const EnterpriseSearchProductCard = () => (
|
|||
'Standalone applications tailored to simpler, user-friendly and business-focused search experiences.',
|
||||
})}
|
||||
emptyCta
|
||||
cta={i18n.translate('xpack.enterpriseSearch.enterpriseSearchCard.cta', {
|
||||
defaultMessage: 'Learn more',
|
||||
})}
|
||||
url={docLinks.start}
|
||||
icon="logoEnterpriseSearch"
|
||||
name={ENTERPRISE_SEARCH_PRODUCT_NAME}
|
||||
productId={ENTERPRISE_SEARCH_CONTENT_PLUGIN.ID}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue