100 lines
1.6 KiB
Plaintext
100 lines
1.6 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: "test",
|
|
mappings: {
|
|
properties: {
|
|
my_location: {
|
|
type: "geo_point",
|
|
},
|
|
group: {
|
|
type: "keyword",
|
|
},
|
|
"@timestamp": {
|
|
type: "date",
|
|
},
|
|
},
|
|
},
|
|
});
|
|
console.log(response);
|
|
|
|
const response1 = await client.bulk({
|
|
index: "test",
|
|
refresh: "true",
|
|
operations: [
|
|
{
|
|
index: {},
|
|
},
|
|
{
|
|
my_location: {
|
|
lat: 52.373184,
|
|
lon: 4.889187,
|
|
},
|
|
"@timestamp": "2023-01-02T09:00:00Z",
|
|
},
|
|
{
|
|
index: {},
|
|
},
|
|
{
|
|
my_location: {
|
|
lat: 52.370159,
|
|
lon: 4.885057,
|
|
},
|
|
"@timestamp": "2023-01-02T10:00:00Z",
|
|
},
|
|
{
|
|
index: {},
|
|
},
|
|
{
|
|
my_location: {
|
|
lat: 52.369219,
|
|
lon: 4.901618,
|
|
},
|
|
"@timestamp": "2023-01-02T13:00:00Z",
|
|
},
|
|
{
|
|
index: {},
|
|
},
|
|
{
|
|
my_location: {
|
|
lat: 52.374081,
|
|
lon: 4.91235,
|
|
},
|
|
"@timestamp": "2023-01-02T16:00:00Z",
|
|
},
|
|
{
|
|
index: {},
|
|
},
|
|
{
|
|
my_location: {
|
|
lat: 52.371667,
|
|
lon: 4.914722,
|
|
},
|
|
"@timestamp": "2023-01-03T12:00:00Z",
|
|
},
|
|
],
|
|
});
|
|
console.log(response1);
|
|
|
|
const response2 = await client.search({
|
|
index: "test",
|
|
filter_path: "aggregations",
|
|
aggs: {
|
|
line: {
|
|
geo_line: {
|
|
point: {
|
|
field: "my_location",
|
|
},
|
|
sort: {
|
|
field: "@timestamp",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|
|
console.log(response2);
|
|
----
|