103 lines
1.9 KiB
Plaintext
103 lines
1.9 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: {
|
|
location: {
|
|
type: "geo_point",
|
|
},
|
|
},
|
|
},
|
|
});
|
|
console.log(response);
|
|
|
|
const response1 = await client.index({
|
|
index: "my-index-000001",
|
|
id: 1,
|
|
document: {
|
|
text: "Geopoint as an object using GeoJSON format",
|
|
location: {
|
|
type: "Point",
|
|
coordinates: [-71.34, 41.12],
|
|
},
|
|
},
|
|
});
|
|
console.log(response1);
|
|
|
|
const response2 = await client.index({
|
|
index: "my-index-000001",
|
|
id: 2,
|
|
document: {
|
|
text: "Geopoint as a WKT POINT primitive",
|
|
location: "POINT (-71.34 41.12)",
|
|
},
|
|
});
|
|
console.log(response2);
|
|
|
|
const response3 = await client.index({
|
|
index: "my-index-000001",
|
|
id: 3,
|
|
document: {
|
|
text: "Geopoint as an object with 'lat' and 'lon' keys",
|
|
location: {
|
|
lat: 41.12,
|
|
lon: -71.34,
|
|
},
|
|
},
|
|
});
|
|
console.log(response3);
|
|
|
|
const response4 = await client.index({
|
|
index: "my-index-000001",
|
|
id: 4,
|
|
document: {
|
|
text: "Geopoint as an array",
|
|
location: [-71.34, 41.12],
|
|
},
|
|
});
|
|
console.log(response4);
|
|
|
|
const response5 = await client.index({
|
|
index: "my-index-000001",
|
|
id: 5,
|
|
document: {
|
|
text: "Geopoint as a string",
|
|
location: "41.12,-71.34",
|
|
},
|
|
});
|
|
console.log(response5);
|
|
|
|
const response6 = await client.index({
|
|
index: "my-index-000001",
|
|
id: 6,
|
|
document: {
|
|
text: "Geopoint as a geohash",
|
|
location: "drm3btev3e86",
|
|
},
|
|
});
|
|
console.log(response6);
|
|
|
|
const response7 = await client.search({
|
|
index: "my-index-000001",
|
|
query: {
|
|
geo_bounding_box: {
|
|
location: {
|
|
top_left: {
|
|
lat: 42,
|
|
lon: -72,
|
|
},
|
|
bottom_right: {
|
|
lat: 40,
|
|
lon: -74,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|
|
console.log(response7);
|
|
----
|