mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-24 17:09:48 +00:00
explain geo_point mapping in geoip-processor (#29114)
simple docs change to add missing mapping explanation. Users may not be aware this is a prerequisite for doing geo-queries on this enriched data.
This commit is contained in:
parent
95a09ab2d6
commit
dc1821c707
@ -155,10 +155,12 @@ PUT _ingest/pipeline/geoip
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
PUT my_index/_doc/my_id?pipeline=geoip
|
||||
{
|
||||
"ip": "80.231.5.0"
|
||||
}
|
||||
|
||||
GET my_index/_doc/my_id
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
@ -168,18 +170,128 @@ Which returns:
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
{
|
||||
"found": true,
|
||||
"_index": "my_index",
|
||||
"_type": "_doc",
|
||||
"_id": "my_id",
|
||||
"_version": 1,
|
||||
"_source": {
|
||||
"ip": "80.231.5.0"
|
||||
"_index" : "my_index",
|
||||
"_type" : "_doc",
|
||||
"_id" : "my_id",
|
||||
"_version" : 1,
|
||||
"found" : true,
|
||||
"_source" : {
|
||||
"ip" : "80.231.5.0"
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
// TESTRESPONSE
|
||||
|
||||
[[ingest-geoip-mappings-note]]
|
||||
===== Recognizing Location as a Geopoint
|
||||
Although this plugin enriches your document with a `location` field containing
|
||||
the estimated latitude and longitude of the IP address, this field will not be
|
||||
indexed as a <<geo-point,`geo_point`>> type in Elasticsearch without explicitely defining it
|
||||
as such in the mapping.
|
||||
|
||||
You can use the following mapping for the example index above:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
PUT my_ip_locations
|
||||
{
|
||||
"mappings": {
|
||||
"_doc": {
|
||||
"properties": {
|
||||
"geoip": {
|
||||
"properties": {
|
||||
"location": { "type": "geo_point" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
|
||||
////
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
PUT _ingest/pipeline/geoip
|
||||
{
|
||||
"description" : "Add geoip info",
|
||||
"processors" : [
|
||||
{
|
||||
"geoip" : {
|
||||
"field" : "ip"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
PUT my_ip_locations/_doc/1?refresh=true&pipeline=geoip
|
||||
{
|
||||
"ip": "8.8.8.8"
|
||||
}
|
||||
|
||||
GET /my_ip_locations/_search
|
||||
{
|
||||
"query": {
|
||||
"bool" : {
|
||||
"must" : {
|
||||
"match_all" : {}
|
||||
},
|
||||
"filter" : {
|
||||
"geo_distance" : {
|
||||
"distance" : "1m",
|
||||
"geoip.location" : {
|
||||
"lon" : -97.822,
|
||||
"lat" : 37.751
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
// TEST[continued]
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
{
|
||||
"took" : 3,
|
||||
"timed_out" : false,
|
||||
"_shards" : {
|
||||
"total" : 1,
|
||||
"successful" : 1,
|
||||
"skipped" : 0,
|
||||
"failed" : 0
|
||||
},
|
||||
"hits" : {
|
||||
"total" : 1,
|
||||
"max_score" : 1.0,
|
||||
"hits" : [
|
||||
{
|
||||
"_index" : "my_ip_locations",
|
||||
"_type" : "_doc",
|
||||
"_id" : "1",
|
||||
"_score" : 1.0,
|
||||
"_source" : {
|
||||
"geoip" : {
|
||||
"continent_name" : "North America",
|
||||
"country_iso_code" : "US",
|
||||
"location" : {
|
||||
"lon" : -97.822,
|
||||
"lat" : 37.751
|
||||
}
|
||||
},
|
||||
"ip" : "8.8.8.8"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
// TESTRESPONSE[s/"took" : 3/"took" : $body.took/]
|
||||
////
|
||||
|
||||
[[ingest-geoip-settings]]
|
||||
===== Node Settings
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user