Added doc examples (#1011)
* Added generate-docs-examples script * Added doc_examples folder wth the initial examples
This commit is contained in:
committed by
GitHub
parent
177aae20e6
commit
1e1252383d
17
docs/doc_examples/048d8abd42d094bbdcf4452a58ccb35b.asciidoc
Normal file
17
docs/doc_examples/048d8abd42d094bbdcf4452a58ccb35b.asciidoc
Normal file
@ -0,0 +1,17 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.create({
|
||||
index: 'twitter',
|
||||
id: '1',
|
||||
body: {
|
||||
user: 'kimchy',
|
||||
post_date: '2009-11-15T14:12:12',
|
||||
message: 'trying out Elasticsearch'
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
19
docs/doc_examples/0ba0b2db24852abccb7c0fc1098d566e.asciidoc
Normal file
19
docs/doc_examples/0ba0b2db24852abccb7c0fc1098d566e.asciidoc
Normal file
@ -0,0 +1,19 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.index({
|
||||
index: 'twitter',
|
||||
id: '2',
|
||||
routing: 'user1',
|
||||
body: {
|
||||
counter: 1,
|
||||
tags: [
|
||||
'white'
|
||||
]
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
18
docs/doc_examples/0ce3606f1dba490eef83c4317b315b62.asciidoc
Normal file
18
docs/doc_examples/0ce3606f1dba490eef83c4317b315b62.asciidoc
Normal file
@ -0,0 +1,18 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
index: 'twitter',
|
||||
body: {
|
||||
query: {
|
||||
term: {
|
||||
user: 'kimchy'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
13
docs/doc_examples/138ccd89f72aa7502dd9578403dcc589.asciidoc
Normal file
13
docs/doc_examples/138ccd89f72aa7502dd9578403dcc589.asciidoc
Normal file
@ -0,0 +1,13 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.get({
|
||||
index: 'twitter',
|
||||
id: '0',
|
||||
_source: 'false'
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
13
docs/doc_examples/1d65cb6d055c46a1bde809687d835b71.asciidoc
Normal file
13
docs/doc_examples/1d65cb6d055c46a1bde809687d835b71.asciidoc
Normal file
@ -0,0 +1,13 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.get({
|
||||
index: 'twitter',
|
||||
id: '2',
|
||||
routing: 'user1'
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
17
docs/doc_examples/1f336ecc62480c1d56351cc2f82d0d08.asciidoc
Normal file
17
docs/doc_examples/1f336ecc62480c1d56351cc2f82d0d08.asciidoc
Normal file
@ -0,0 +1,17 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.index({
|
||||
index: 'twitter',
|
||||
id: '1',
|
||||
version: '2',
|
||||
version_type: 'external',
|
||||
body: {
|
||||
message: 'elasticsearch now has versioning support, double cool!'
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
18
docs/doc_examples/231aa0bb39c35fe199d28fe0e4a62b2e.asciidoc
Normal file
18
docs/doc_examples/231aa0bb39c35fe199d28fe0e4a62b2e.asciidoc
Normal file
@ -0,0 +1,18 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
index: 'bank',
|
||||
body: {
|
||||
query: {
|
||||
match_phrase: {
|
||||
address: 'mill lane'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
12
docs/doc_examples/2468ab381257d759d8a88af1141f6f9c.asciidoc
Normal file
12
docs/doc_examples/2468ab381257d759d8a88af1141f6f9c.asciidoc
Normal file
@ -0,0 +1,12 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.existsSource({
|
||||
index: 'twitter',
|
||||
id: '1'
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
28
docs/doc_examples/251ea12c1248385ab409906ac64d9ee9.asciidoc
Normal file
28
docs/doc_examples/251ea12c1248385ab409906ac64d9ee9.asciidoc
Normal file
@ -0,0 +1,28 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
index: 'bank',
|
||||
body: {
|
||||
query: {
|
||||
bool: {
|
||||
must: {
|
||||
match_all: {}
|
||||
},
|
||||
filter: {
|
||||
range: {
|
||||
balance: {
|
||||
gte: 20000,
|
||||
lte: 30000
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
20
docs/doc_examples/28aad2c5942bfb221c2bf1bbdc01658e.asciidoc
Normal file
20
docs/doc_examples/28aad2c5942bfb221c2bf1bbdc01658e.asciidoc
Normal file
@ -0,0 +1,20 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
body: {
|
||||
query: {
|
||||
query_string: {
|
||||
fields: [
|
||||
'city.*'
|
||||
],
|
||||
query: 'this AND that OR thus'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
15
docs/doc_examples/311c4b632a29b9ead63b02d01f10096b.asciidoc
Normal file
15
docs/doc_examples/311c4b632a29b9ead63b02d01f10096b.asciidoc
Normal file
@ -0,0 +1,15 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.index({
|
||||
index: 'customer',
|
||||
id: '1',
|
||||
body: {
|
||||
name: 'John Doe'
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
16
docs/doc_examples/36818c6d9f434d387819c30bd9addb14.asciidoc
Normal file
16
docs/doc_examples/36818c6d9f434d387819c30bd9addb14.asciidoc
Normal file
@ -0,0 +1,16 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.index({
|
||||
index: 'twitter',
|
||||
body: {
|
||||
user: 'kimchy',
|
||||
post_date: '2009-11-15T14:12:12',
|
||||
message: 'trying out Elasticsearch'
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.info()
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
12
docs/doc_examples/3f3b3e207f79303ce6f86e03e928e062.asciidoc
Normal file
12
docs/doc_examples/3f3b3e207f79303ce6f86e03e928e062.asciidoc
Normal file
@ -0,0 +1,12 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.get({
|
||||
index: 'customer',
|
||||
id: '1'
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
13
docs/doc_examples/47b5ff897f26e9c943cee5c06034181d.asciidoc
Normal file
13
docs/doc_examples/47b5ff897f26e9c943cee5c06034181d.asciidoc
Normal file
@ -0,0 +1,13 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.delete({
|
||||
index: 'twitter',
|
||||
id: '1',
|
||||
routing: 'kimchy'
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
31
docs/doc_examples/47bb632c6091ad0cd94bc660bdd309a5.asciidoc
Normal file
31
docs/doc_examples/47bb632c6091ad0cd94bc660bdd309a5.asciidoc
Normal file
@ -0,0 +1,31 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
index: 'bank',
|
||||
body: {
|
||||
query: {
|
||||
bool: {
|
||||
must: [
|
||||
{
|
||||
match: {
|
||||
age: '40'
|
||||
}
|
||||
}
|
||||
],
|
||||
must_not: [
|
||||
{
|
||||
match: {
|
||||
state: 'ID'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
23
docs/doc_examples/4b90feb9d5d3dbfce424dac0341320b7.asciidoc
Normal file
23
docs/doc_examples/4b90feb9d5d3dbfce424dac0341320b7.asciidoc
Normal file
@ -0,0 +1,23 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
index: 'bank',
|
||||
body: {
|
||||
query: {
|
||||
match_all: {}
|
||||
},
|
||||
sort: [
|
||||
{
|
||||
account_number: 'asc'
|
||||
}
|
||||
],
|
||||
from: 10,
|
||||
size: 10
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
21
docs/doc_examples/506844befdc5691d835771bcbb1c1a60.asciidoc
Normal file
21
docs/doc_examples/506844befdc5691d835771bcbb1c1a60.asciidoc
Normal file
@ -0,0 +1,21 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
index: 'bank',
|
||||
body: {
|
||||
query: {
|
||||
match_all: {}
|
||||
},
|
||||
sort: [
|
||||
{
|
||||
account_number: 'asc'
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
21
docs/doc_examples/58b5003c0a53a39bf509aa3797aad471.asciidoc
Normal file
21
docs/doc_examples/58b5003c0a53a39bf509aa3797aad471.asciidoc
Normal file
@ -0,0 +1,21 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
body: {
|
||||
query: {
|
||||
query_string: {
|
||||
fields: [
|
||||
'content',
|
||||
'name.*^5'
|
||||
],
|
||||
query: 'this AND that OR thus'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
18
docs/doc_examples/5eabcdbf61bfcb484dc694f25c2bba36.asciidoc
Normal file
18
docs/doc_examples/5eabcdbf61bfcb484dc694f25c2bba36.asciidoc
Normal file
@ -0,0 +1,18 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.index({
|
||||
index: 'twitter',
|
||||
id: '1',
|
||||
body: {
|
||||
counter: 1,
|
||||
tags: [
|
||||
'red'
|
||||
]
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
11
docs/doc_examples/609260ad1d5998be2ca09ff1fe237efa.asciidoc
Normal file
11
docs/doc_examples/609260ad1d5998be2ca09ff1fe237efa.asciidoc
Normal file
@ -0,0 +1,11 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.getMapping({
|
||||
index: 'my-index'
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
21
docs/doc_examples/60ee33f3acfdd0fe6f288ac77312c780.asciidoc
Normal file
21
docs/doc_examples/60ee33f3acfdd0fe6f288ac77312c780.asciidoc
Normal file
@ -0,0 +1,21 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
body: {
|
||||
query: {
|
||||
query_string: {
|
||||
fields: [
|
||||
'title'
|
||||
],
|
||||
query: 'this that thus',
|
||||
minimum_should_match: 2
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
17
docs/doc_examples/625dc94df1f9affb49a082fd99d41620.asciidoc
Normal file
17
docs/doc_examples/625dc94df1f9affb49a082fd99d41620.asciidoc
Normal file
@ -0,0 +1,17 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.index({
|
||||
index: 'twitter',
|
||||
routing: 'kimchy',
|
||||
body: {
|
||||
user: 'kimchy',
|
||||
post_date: '2009-11-15T14:12:12',
|
||||
message: 'trying out Elasticsearch'
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
31
docs/doc_examples/645796e8047967ca4a7635a22a876f4c.asciidoc
Normal file
31
docs/doc_examples/645796e8047967ca4a7635a22a876f4c.asciidoc
Normal file
@ -0,0 +1,31 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
index: 'bank',
|
||||
body: {
|
||||
size: 0,
|
||||
aggs: {
|
||||
group_by_state: {
|
||||
terms: {
|
||||
field: 'state.keyword',
|
||||
order: {
|
||||
average_balance: 'desc'
|
||||
}
|
||||
},
|
||||
aggs: {
|
||||
average_balance: {
|
||||
avg: {
|
||||
field: 'balance'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
14
docs/doc_examples/69a7be47f85138b10437113ab2f0d72d.asciidoc
Normal file
14
docs/doc_examples/69a7be47f85138b10437113ab2f0d72d.asciidoc
Normal file
@ -0,0 +1,14 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.get({
|
||||
index: 'twitter',
|
||||
id: '2',
|
||||
routing: 'user1',
|
||||
stored_fields: 'tags,counter'
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
23
docs/doc_examples/6f21a878fee3b43c5332b81aaddbeac7.asciidoc
Normal file
23
docs/doc_examples/6f21a878fee3b43c5332b81aaddbeac7.asciidoc
Normal file
@ -0,0 +1,23 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
body: {
|
||||
query: {
|
||||
query_string: {
|
||||
fields: [
|
||||
'title',
|
||||
'content'
|
||||
],
|
||||
query: 'this OR that OR thus',
|
||||
type: 'cross_fields',
|
||||
minimum_should_match: 2
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
13
docs/doc_examples/710c7871f20f176d51209b1574b0d61b.asciidoc
Normal file
13
docs/doc_examples/710c7871f20f176d51209b1574b0d61b.asciidoc
Normal file
@ -0,0 +1,13 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.get({
|
||||
index: 'twitter',
|
||||
id: '1',
|
||||
stored_fields: 'tags,counter'
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
19
docs/doc_examples/71ba9033107882f61cdc3b32fc73568d.asciidoc
Normal file
19
docs/doc_examples/71ba9033107882f61cdc3b32fc73568d.asciidoc
Normal file
@ -0,0 +1,19 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.putMapping({
|
||||
index: 'my-index',
|
||||
body: {
|
||||
properties: {
|
||||
'employee-id': {
|
||||
type: 'keyword',
|
||||
index: false
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
13
docs/doc_examples/745f9b8cdb8e91073f6e520e1d9f8c05.asciidoc
Normal file
13
docs/doc_examples/745f9b8cdb8e91073f6e520e1d9f8c05.asciidoc
Normal file
@ -0,0 +1,13 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.get({
|
||||
index: 'twitter',
|
||||
id: '0',
|
||||
_source: '*.id,retweeted'
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
33
docs/doc_examples/804a97ff4d0613e6568e4efb19c52021.asciidoc
Normal file
33
docs/doc_examples/804a97ff4d0613e6568e4efb19c52021.asciidoc
Normal file
@ -0,0 +1,33 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response0 = await client.cluster.putSettings({
|
||||
body: {
|
||||
persistent: {
|
||||
'action.auto_create_index': 'twitter,index10,-index1*,+ind*'
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response0)
|
||||
|
||||
const response1 = await client.cluster.putSettings({
|
||||
body: {
|
||||
persistent: {
|
||||
'action.auto_create_index': 'false'
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response1)
|
||||
|
||||
const response2 = await client.cluster.putSettings({
|
||||
body: {
|
||||
persistent: {
|
||||
'action.auto_create_index': 'true'
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response2)
|
||||
----
|
||||
|
||||
12
docs/doc_examples/89a8ac1509936acc272fc2d72907bc45.asciidoc
Normal file
12
docs/doc_examples/89a8ac1509936acc272fc2d72907bc45.asciidoc
Normal file
@ -0,0 +1,12 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.getSource({
|
||||
index: 'twitter',
|
||||
id: '1'
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
14
docs/doc_examples/8fdf2344c4fb3de6902ad7c5735270df.asciidoc
Normal file
14
docs/doc_examples/8fdf2344c4fb3de6902ad7c5735270df.asciidoc
Normal file
@ -0,0 +1,14 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.get({
|
||||
index: 'twitter',
|
||||
id: '0',
|
||||
_source_includes: '*.id',
|
||||
_source_excludes: 'entities'
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
25
docs/doc_examples/913770050ebbf3b9b549a899bc11060a.asciidoc
Normal file
25
docs/doc_examples/913770050ebbf3b9b549a899bc11060a.asciidoc
Normal file
@ -0,0 +1,25 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.create({
|
||||
index: 'twitter',
|
||||
body: {
|
||||
mappings: {
|
||||
properties: {
|
||||
counter: {
|
||||
type: 'integer',
|
||||
store: false
|
||||
},
|
||||
tags: {
|
||||
type: 'keyword',
|
||||
store: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
12
docs/doc_examples/98234499cfec70487cec5d013e976a84.asciidoc
Normal file
12
docs/doc_examples/98234499cfec70487cec5d013e976a84.asciidoc
Normal file
@ -0,0 +1,12 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.exists({
|
||||
index: 'twitter',
|
||||
id: '0'
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
12
docs/doc_examples/99a52be903945b17e734a1d02a57e958.asciidoc
Normal file
12
docs/doc_examples/99a52be903945b17e734a1d02a57e958.asciidoc
Normal file
@ -0,0 +1,12 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.getFieldMapping({
|
||||
index: 'my-index',
|
||||
fields: 'employee-id'
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
22
docs/doc_examples/a2a25aad1fea9a541b52ac613c78fb64.asciidoc
Normal file
22
docs/doc_examples/a2a25aad1fea9a541b52ac613c78fb64.asciidoc
Normal file
@ -0,0 +1,22 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
body: {
|
||||
query: {
|
||||
query_string: {
|
||||
fields: [
|
||||
'content',
|
||||
'name^5'
|
||||
],
|
||||
query: 'this AND that OR thus',
|
||||
tie_breaker: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
18
docs/doc_examples/ad6ea0c1e46712aa1fd6d3bfa0ec979e.asciidoc
Normal file
18
docs/doc_examples/ad6ea0c1e46712aa1fd6d3bfa0ec979e.asciidoc
Normal file
@ -0,0 +1,18 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
body: {
|
||||
query: {
|
||||
query_string: {
|
||||
query: '(new york city) OR (big apple)',
|
||||
default_field: 'content'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
18
docs/doc_examples/b918d6b798da673a33e49b94f61dcdc0.asciidoc
Normal file
18
docs/doc_examples/b918d6b798da673a33e49b94f61dcdc0.asciidoc
Normal file
@ -0,0 +1,18 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.index({
|
||||
index: 'twitter',
|
||||
id: '1',
|
||||
timeout: '5m',
|
||||
body: {
|
||||
user: 'kimchy',
|
||||
post_date: '2009-11-15T14:12:12',
|
||||
message: 'trying out Elasticsearch'
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
17
docs/doc_examples/bb143628fd04070683eeeadc9406d9cc.asciidoc
Normal file
17
docs/doc_examples/bb143628fd04070683eeeadc9406d9cc.asciidoc
Normal file
@ -0,0 +1,17 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.index({
|
||||
index: 'twitter',
|
||||
id: '1',
|
||||
body: {
|
||||
user: 'kimchy',
|
||||
post_date: '2009-11-15T14:12:12',
|
||||
message: 'trying out Elasticsearch'
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
22
docs/doc_examples/be1bd47393646ac6bbee177d1cdb7738.asciidoc
Normal file
22
docs/doc_examples/be1bd47393646ac6bbee177d1cdb7738.asciidoc
Normal file
@ -0,0 +1,22 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
body: {
|
||||
query: {
|
||||
query_string: {
|
||||
fields: [
|
||||
'title',
|
||||
'content'
|
||||
],
|
||||
query: 'this that thus',
|
||||
minimum_should_match: 2
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
13
docs/doc_examples/bfcd65ab85d684d36a8550080032958d.asciidoc
Normal file
13
docs/doc_examples/bfcd65ab85d684d36a8550080032958d.asciidoc
Normal file
@ -0,0 +1,13 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
q: 'message:number',
|
||||
size: '0',
|
||||
terminate_after: '1'
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
12
docs/doc_examples/c5e5873783246c7b1c01d8464fed72c4.asciidoc
Normal file
12
docs/doc_examples/c5e5873783246c7b1c01d8464fed72c4.asciidoc
Normal file
@ -0,0 +1,12 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.delete({
|
||||
index: 'twitter',
|
||||
id: '1'
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
18
docs/doc_examples/cd247f267968aa0927bfdad56852f8f5.asciidoc
Normal file
18
docs/doc_examples/cd247f267968aa0927bfdad56852f8f5.asciidoc
Normal file
@ -0,0 +1,18 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
index: 'bank',
|
||||
body: {
|
||||
query: {
|
||||
match: {
|
||||
address: 'mill lane'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
28
docs/doc_examples/cfbaea6f0df045c5d940bbb6a9c69cd8.asciidoc
Normal file
28
docs/doc_examples/cfbaea6f0df045c5d940bbb6a9c69cd8.asciidoc
Normal file
@ -0,0 +1,28 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
index: 'bank',
|
||||
body: {
|
||||
size: 0,
|
||||
aggs: {
|
||||
group_by_state: {
|
||||
terms: {
|
||||
field: 'state.keyword'
|
||||
},
|
||||
aggs: {
|
||||
average_balance: {
|
||||
avg: {
|
||||
field: 'balance'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
14
docs/doc_examples/d222c6a6ec7a3beca6c97011b0874512.asciidoc
Normal file
14
docs/doc_examples/d222c6a6ec7a3beca6c97011b0874512.asciidoc
Normal file
@ -0,0 +1,14 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.getSource({
|
||||
index: 'twitter',
|
||||
id: '1',
|
||||
_source_includes: '*.id',
|
||||
_source_excludes: 'entities'
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
18
docs/doc_examples/d718b63cf1b6591a1d59a0cf4fd995eb.asciidoc
Normal file
18
docs/doc_examples/d718b63cf1b6591a1d59a0cf4fd995eb.asciidoc
Normal file
@ -0,0 +1,18 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.index({
|
||||
index: 'twitter',
|
||||
id: '1',
|
||||
op_type: 'create',
|
||||
body: {
|
||||
user: 'kimchy',
|
||||
post_date: '2009-11-15T14:12:12',
|
||||
message: 'trying out Elasticsearch'
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
26
docs/doc_examples/d8b2a88b5eca99d3691ad3cd40266736.asciidoc
Normal file
26
docs/doc_examples/d8b2a88b5eca99d3691ad3cd40266736.asciidoc
Normal file
@ -0,0 +1,26 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.create({
|
||||
index: 'my-index',
|
||||
body: {
|
||||
mappings: {
|
||||
properties: {
|
||||
age: {
|
||||
type: 'integer'
|
||||
},
|
||||
email: {
|
||||
type: 'keyword'
|
||||
},
|
||||
name: {
|
||||
type: 'text'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
13
docs/doc_examples/d90a84a24a407731dfc1929ac8327746.asciidoc
Normal file
13
docs/doc_examples/d90a84a24a407731dfc1929ac8327746.asciidoc
Normal file
@ -0,0 +1,13 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.delete({
|
||||
index: 'twitter',
|
||||
id: '1',
|
||||
timeout: '5m'
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
17
docs/doc_examples/db6cba451ba562abe953d09ad80cc15c.asciidoc
Normal file
17
docs/doc_examples/db6cba451ba562abe953d09ad80cc15c.asciidoc
Normal file
@ -0,0 +1,17 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
body: {
|
||||
query: {
|
||||
query_string: {
|
||||
query: 'city.\\*:(this AND that OR thus)'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
17
docs/doc_examples/e17e8852ec3f31781e1364f4dffeb6d0.asciidoc
Normal file
17
docs/doc_examples/e17e8852ec3f31781e1364f4dffeb6d0.asciidoc
Normal file
@ -0,0 +1,17 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
body: {
|
||||
query: {
|
||||
query_string: {
|
||||
query: '(content:this OR name:this) AND (content:that OR name:that)'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
21
docs/doc_examples/f2d68493abd3ca430bd03a7f7f8d18f9.asciidoc
Normal file
21
docs/doc_examples/f2d68493abd3ca430bd03a7f7f8d18f9.asciidoc
Normal file
@ -0,0 +1,21 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
body: {
|
||||
query: {
|
||||
query_string: {
|
||||
fields: [
|
||||
'content',
|
||||
'name'
|
||||
],
|
||||
query: 'this AND that'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
19
docs/doc_examples/f32f0c19b42de3b87dd764fe4ca17e7c.asciidoc
Normal file
19
docs/doc_examples/f32f0c19b42de3b87dd764fe4ca17e7c.asciidoc
Normal file
@ -0,0 +1,19 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
body: {
|
||||
query: {
|
||||
query_string: {
|
||||
default_field: 'title',
|
||||
query: 'ny city',
|
||||
auto_generate_synonyms_phrase_query: false
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
11
docs/doc_examples/f8cc4b331a19ff4df8e4a490f906ee69.asciidoc
Normal file
11
docs/doc_examples/f8cc4b331a19ff4df8e4a490f906ee69.asciidoc
Normal file
@ -0,0 +1,11 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.cat.health({
|
||||
v: ''
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
12
docs/doc_examples/fbcf5078a6a9e09790553804054c36b3.asciidoc
Normal file
12
docs/doc_examples/fbcf5078a6a9e09790553804054c36b3.asciidoc
Normal file
@ -0,0 +1,12 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.get({
|
||||
index: 'twitter',
|
||||
id: '0'
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
22
docs/doc_examples/fdd38f0d248385a444c777e7acd97846.asciidoc
Normal file
22
docs/doc_examples/fdd38f0d248385a444c777e7acd97846.asciidoc
Normal file
@ -0,0 +1,22 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
body: {
|
||||
query: {
|
||||
query_string: {
|
||||
fields: [
|
||||
'title',
|
||||
'content'
|
||||
],
|
||||
query: 'this OR that OR thus',
|
||||
minimum_should_match: 2
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
21
docs/doc_examples/feefeb68144002fd1fff57b77b95b85e.asciidoc
Normal file
21
docs/doc_examples/feefeb68144002fd1fff57b77b95b85e.asciidoc
Normal file
@ -0,0 +1,21 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
index: 'bank',
|
||||
body: {
|
||||
size: 0,
|
||||
aggs: {
|
||||
group_by_state: {
|
||||
terms: {
|
||||
field: 'state.keyword'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
96
scripts/generate-docs-examples.js
Normal file
96
scripts/generate-docs-examples.js
Normal file
@ -0,0 +1,96 @@
|
||||
// Licensed to Elasticsearch B.V under one or more agreements.
|
||||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* To run this generator you must have the
|
||||
* `alternatives_report.spec.json` placed in the root of this project.
|
||||
* To get the `alternatives_report.spec.json` you must run the script
|
||||
* to parse the original `alternatives_report.json`, which is not yet public
|
||||
* and lives in github.com/elastic/clients-team/tree/master/scripts/docs-json-generator
|
||||
*
|
||||
* This script will remove the content of the `docs/doc_examples` folder and generate
|
||||
* all the files present in the `enabledFiles` list below.
|
||||
* You can run it with the following command:
|
||||
*
|
||||
* ```bash
|
||||
* $ node scripts/generate-docs-examples.js
|
||||
* ```
|
||||
*/
|
||||
|
||||
const { join } = require('path')
|
||||
const { writeFileSync } = require('fs')
|
||||
const rimraf = require('rimraf')
|
||||
const standard = require('standard')
|
||||
const dedent = require('dedent')
|
||||
|
||||
const docsExamplesDir = join('docs', 'doc_examples')
|
||||
|
||||
const enabledFiles = [
|
||||
'docs/delete.asciidoc',
|
||||
'docs/get.asciidoc',
|
||||
'docs/index_.asciidoc',
|
||||
'getting-started.asciidoc',
|
||||
'query-dsl/query-string-query.asciidoc',
|
||||
'query-dsl.asciidoc',
|
||||
'search/request-body.asciidoc',
|
||||
'setup/install/check-running.asciidoc',
|
||||
'mapping.asciidoc'
|
||||
]
|
||||
|
||||
function generate () {
|
||||
rimraf.sync(join(docsExamplesDir, '*'))
|
||||
const examples = require(join(__dirname, '..', 'alternatives_report.spec.json'))
|
||||
for (const example of examples) {
|
||||
if (example.lang !== 'console') continue
|
||||
if (!enabledFiles.includes(example.source_location.file)) continue
|
||||
|
||||
const asciidoc = generateAsciidoc(example.parsed_source)
|
||||
writeFileSync(
|
||||
join(docsExamplesDir, `${example.digest}.asciidoc`),
|
||||
asciidoc,
|
||||
'utf8'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function generateAsciidoc (source) {
|
||||
var asciidoc = '// This file is autogenerated, DO NOT EDIT\n'
|
||||
asciidoc += '// Use `node scripts/generate-docs-examples.js` to generate the docs examples\n\n'
|
||||
var code = 'async function run (client) {\n// START\n'
|
||||
|
||||
for (var i = 0; i < source.length; i++) {
|
||||
const { api, query, params, body } = source[i]
|
||||
const apiArguments = Object.assign({}, params, query, body ? { body } : body)
|
||||
var serializedApiArguments = Object.keys(apiArguments).length > 0
|
||||
? JSON.stringify(apiArguments, null, 2)
|
||||
: ''
|
||||
serializedApiArguments = serializedApiArguments.replace(/"/g, "'")
|
||||
|
||||
code += `const response${getResponsePostfix(i)} = await client.${api.replace(/_([a-z])/g, g => g[1].toUpperCase())}(${serializedApiArguments})
|
||||
console.log(response${getResponsePostfix(i)})
|
||||
\n`
|
||||
}
|
||||
|
||||
code += '// END\n}'
|
||||
const { results } = standard.lintTextSync(code, { fix: true })
|
||||
code = results[0].output
|
||||
code = code.slice(code.indexOf('// START\n') + 9, code.indexOf('\n\n// END'))
|
||||
|
||||
asciidoc += `[source, js]
|
||||
----
|
||||
${dedent(code)}
|
||||
----
|
||||
|
||||
`
|
||||
return asciidoc
|
||||
|
||||
function getResponsePostfix (i) {
|
||||
if (source.length === 1) return ''
|
||||
return String(i)
|
||||
}
|
||||
}
|
||||
|
||||
generate()
|
||||
Reference in New Issue
Block a user