58 lines
942 B
Plaintext
58 lines
942 B
Plaintext
// 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: "index_1",
|
|
id: 1,
|
|
document: {
|
|
text: "Document in index 1",
|
|
},
|
|
});
|
|
console.log(response);
|
|
|
|
const response1 = await client.index({
|
|
index: "index_2",
|
|
id: 2,
|
|
refresh: "true",
|
|
document: {
|
|
text: "Document in index 2",
|
|
},
|
|
});
|
|
console.log(response1);
|
|
|
|
const response2 = await client.search({
|
|
index: "index_1,index_2",
|
|
query: {
|
|
terms: {
|
|
_index: ["index_1", "index_2"],
|
|
},
|
|
},
|
|
aggs: {
|
|
indices: {
|
|
terms: {
|
|
field: "_index",
|
|
size: 10,
|
|
},
|
|
},
|
|
},
|
|
sort: [
|
|
{
|
|
_index: {
|
|
order: "asc",
|
|
},
|
|
},
|
|
],
|
|
script_fields: {
|
|
index_name: {
|
|
script: {
|
|
lang: "painless",
|
|
source: "doc['_index']",
|
|
},
|
|
},
|
|
},
|
|
});
|
|
console.log(response2);
|
|
----
|