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

68 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: "places",
mappings: {
properties: {
geometry: {
type: "shape",
},
},
},
});
console.log(response);
const response1 = await client.bulk({
index: "places",
refresh: "true",
operations: [
{
index: {
_id: 1,
},
},
{
name: "NEMO Science Museum",
geometry: "POINT(491.2350 5237.4081)",
},
{
index: {
_id: 2,
},
},
{
name: "Sportpark De Weeren",
geometry: {
type: "Polygon",
coordinates: [
[
[496.5305328369141, 5239.347642069457],
[496.6979026794433, 5239.172175893484],
[496.9425201416015, 5239.238958618537],
[496.7944622039794, 5239.420969150824],
[496.5305328369141, 5239.347642069457],
],
],
},
},
],
});
console.log(response1);
const response2 = await client.search({
index: "places",
size: 0,
aggs: {
centroid: {
cartesian_centroid: {
field: "geometry",
},
},
},
});
console.log(response2);
----