48 lines
928 B
Plaintext
48 lines
928 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.indices.create({
|
|
index: "my-index-000001",
|
|
mappings: {
|
|
properties: {
|
|
full_name: {
|
|
type: "text",
|
|
store: true,
|
|
},
|
|
title: {
|
|
type: "text",
|
|
store: true,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
console.log(response);
|
|
|
|
const response1 = await client.index({
|
|
index: "my-index-000001",
|
|
id: 1,
|
|
refresh: "true",
|
|
document: {
|
|
full_name: "Alice Ball",
|
|
title: "Professor",
|
|
},
|
|
});
|
|
console.log(response1);
|
|
|
|
const response2 = await client.search({
|
|
index: "my-index-000001",
|
|
script_fields: {
|
|
name_with_title: {
|
|
script: {
|
|
lang: "painless",
|
|
source:
|
|
"params._fields['title'].value + ' ' + params._fields['full_name'].value",
|
|
},
|
|
},
|
|
},
|
|
});
|
|
console.log(response2);
|
|
----
|