Files
elasticsearch-js/docs/doc_examples/ad57ccba0a060da4f5313692fa26a235.asciidoc
2024-07-29 17:10:05 -05:00

73 lines
1.2 KiB
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: {
date: {
type: "date_nanos",
},
},
},
});
console.log(response);
const response1 = await client.bulk({
index: "my-index-000001",
refresh: "true",
operations: [
{
index: {
_id: "1",
},
},
{
date: "2015-01-01",
},
{
index: {
_id: "2",
},
},
{
date: "2015-01-01T12:10:30.123456789Z",
},
{
index: {
_id: "3",
},
},
{
date: 1420070400000,
},
],
});
console.log(response1);
const response2 = await client.search({
index: "my-index-000001",
sort: {
date: "asc",
},
runtime_mappings: {
date_has_nanos: {
type: "boolean",
script: "emit(doc['date'].value.nano != 0)",
},
},
fields: [
{
field: "date",
format: "strict_date_optional_time_nanos",
},
{
field: "date_has_nanos",
},
],
});
console.log(response2);
----