68 lines
1.2 KiB
Plaintext
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: "geo_shape",
|
|
},
|
|
},
|
|
},
|
|
});
|
|
console.log(response);
|
|
|
|
const response1 = await client.bulk({
|
|
index: "places",
|
|
refresh: "true",
|
|
operations: [
|
|
{
|
|
index: {
|
|
_id: 1,
|
|
},
|
|
},
|
|
{
|
|
name: "NEMO Science Museum",
|
|
geometry: "POINT(4.912350 52.374081)",
|
|
},
|
|
{
|
|
index: {
|
|
_id: 2,
|
|
},
|
|
},
|
|
{
|
|
name: "Sportpark De Weeren",
|
|
geometry: {
|
|
type: "Polygon",
|
|
coordinates: [
|
|
[
|
|
[4.965305328369141, 52.39347642069457],
|
|
[4.966979026794433, 52.391721758934835],
|
|
[4.969425201416015, 52.39238958618537],
|
|
[4.967944622039794, 52.39420969150824],
|
|
[4.965305328369141, 52.39347642069457],
|
|
],
|
|
],
|
|
},
|
|
},
|
|
],
|
|
});
|
|
console.log(response1);
|
|
|
|
const response2 = await client.search({
|
|
index: "places",
|
|
size: 0,
|
|
aggs: {
|
|
viewport: {
|
|
geo_bounds: {
|
|
field: "geometry",
|
|
},
|
|
},
|
|
},
|
|
});
|
|
console.log(response2);
|
|
----
|