Тип поля Point
Тип данных point позволяет индексировать и искать произвольные x, y пары, которые попадают в двумерную декартову систему координат.
Вы можете запросить документы с помощью этого типа, используя запрос Shape.
Как и в случае с geo_shape и geo_point, point можно указать в формате GeoJSON и Well-Known Text. Однако для удобства и по историческим причинам поддерживается ряд дополнительных форматов. В общей сложности существует пять способов указания декартовой точки, как показано ниже:
resp = client.indices.create(
index="my-index-000001",
mappings={
"properties": {
"location": {
"type": "point"
}
}
},
)
print(resp)
resp1 = client.index(
index="my-index-000001",
id="1",
document={
"text": "Point as an object using GeoJSON format",
"location": {
"type": "Point",
"coordinates": [
-71.34,
41.12
]
}
},
)
print(resp1)
resp2 = client.index(
index="my-index-000001",
id="2",
document={
"text": "Point as a WKT POINT primitive",
"location": "POINT (-71.34 41.12)"
},
)
print(resp2)
resp3 = client.index(
index="my-index-000001",
id="3",
document={
"text": "Point as an object with 'x' and 'y' keys",
"location": {
"x": -71.34,
"y": 41.12
}
},
)
print(resp3)
resp4 = client.index(
index="my-index-000001",
id="4",
document={
"text": "Point as an array",
"location": [
-71.34,
41.12
]
},
)
print(resp4)
resp5 = client.index(
index="my-index-000001",
id="5",
document={
"text": "Point as a string",
"location": "-71.34,41.12"
},
)
print(resp5) response = client.indices.create(
index: 'my-index-000001',
body: {
mappings: {
properties: {
location: {
type: 'point'
}
}
}
}
)
puts response
response = client.index(
index: 'my-index-000001',
id: 1,
body: {
text: 'Point as an object using GeoJSON format',
location: {
type: 'Point',
coordinates: [
-71.34,
41.12
]
}
}
)
puts response
response = client.index(
index: 'my-index-000001',
id: 2,
body: {
text: 'Point as a WKT POINT primitive',
location: 'POINT (-71.34 41.12)'
}
)
puts response
response = client.index(
index: 'my-index-000001',
id: 3,
body: {
text: "Point as an object with 'x' and 'y' keys",
location: {
x: -71.34,
y: 41.12
}
}
)
puts response
response = client.index(
index: 'my-index-000001',
id: 4,
body: {
text: 'Point as an array',
location: [
-71.34,
41.12
]
}
)
puts response
response = client.index(
index: 'my-index-000001',
id: 5,
body: {
text: 'Point as a string',
location: '-71.34,41.12'
}
)
puts response const response = await client.indices.create({
index: "my-index-000001",
mappings: {
properties: {
location: {
type: "point",
},
},
},
});
console.log(response);
const response1 = await client.index({
index: "my-index-000001",
id: 1,
document: {
text: "Point 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: "Point 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: "Point as an object with 'x' and 'y' keys",
location: {
x: -71.34,
y: 41.12,
},
},
});
console.log(response3);
const response4 = await client.index({
index: "my-index-000001",
id: 4,
document: {
text: "Point as an array",
location: [-71.34, 41.12],
},
});
console.log(response4);
const response5 = await client.index({
index: "my-index-000001",
id: 5,
document: {
text: "Point as a string",
location: "-71.34,41.12",
},
});
console.log(response5); PUT my-index-000001
{
"mappings": {
"properties": {
"location": {
"type": "point"
}
}
}
}
PUT my-index-000001/_doc/1
{
"text": "Point as an object using GeoJSON format",
"location": {
"type": "Point",
"coordinates": [-71.34, 41.12]
}
}
PUT my-index-000001/_doc/2
{
"text": "Point as a WKT POINT primitive",
"location" : "POINT (-71.34 41.12)"
}
PUT my-index-000001/_doc/3
{
"text": "Point as an object with 'x' and 'y' keys",
"location": {
"x": -71.34,
"y": 41.12
}
}
PUT my-index-000001/_doc/4
{
"text": "Point as an array",
"location": [ -71.34, 41.12 ]
}
PUT my-index-000001/_doc/5
{
"text": "Point as a string",
"location": "-71.34,41.12"
} | Точка, выраженная в виде объекта в формате GeoJSON, с ключами | |
| Точка, выраженная как Well-Known Text POINT в формате: | |
| Точка, выраженная как объект с ключами | |
| Точка, выраженная как массив в формате: [ | |
| Точка, выраженная как строка в формате: |
В отличие от типа поля geo-point, порядок координат x и y одинаков для всех указанных выше форматов.
Координаты, предоставленные индексатору, являются однобайтовыми числами с плавающей точкой, поэтому поле гарантирует ту же точность, что и виртуальная машина Java (обычно 1E-38).
Параметры для полей point
Следующие параметры принимаются полями point:
| Если | |
| | Если |
| Принимает значение точки, которое подставляется вместо явных |
Сортировка и извлечение точек
В настоящее время сортировка точек и непосредственное извлечение их полей недоступны. Значение point доступно только через поле _source.
© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/8.17/point.html