@Fatih_Kurnaz
Try This... but it feels a bit backwards you are going to get the shape back every search.
Note: I think you can use intersects
or contains
... I think intersects
might be faster / more efficient but am not completely sure. you can test
PUT _ingest/pipeline/polygonize_circles
{
"description": "translate circle to polygon",
"processors": [
{
"circle": {
"field": "location",
"error_distance": 100, <-- That means 100m error possibility
"shape_type": "geo_shape"
}
}
]
}
GET my-circle
DELETE my-circle
PUT my-circle
{
"mappings": {
"properties": {
"location": {
"type": "geo_shape"
}
}
}
}
POST my-circle/_doc/?pipeline=polygonize_circles
{
"locationName": "nowhere",
"location": {
"type": "circle",
"coordinates": [
1,
70
],
"radius": "25mi"
}
}
POST my-circle/_doc/?pipeline=polygonize_circles
{
"locationName": "london",
"location": {
"type": "circle",
"coordinates": [
1,
51
],
"radius": "25mi"
}
}
GET my-circle/_search
{
"query": {
"bool": {
"must": {
"match_all": {}
},
"filter": {
"geo_shape": {
"location": {
"shape": {
"type": "point",
"coordinates": [
0, 70.0
],
"relation": "contains"
}
}
}
}
}
}
}
If you don't actually want the shape to come back
GET my-circle/_search
{
"size" : 0, <---
"query": {
"bool": {
"must": {
"match_all": {}
},
"filter": {
"geo_shape": {
"location": {
"shape": {
"type": "point",
"coordinates": [
0, 70.0
],
"relation": "contains"
}
}
}
}
}
}
}
The results will look like this.
{
"took" : 12,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 1, <--- Means it will be found but you wont know which one
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
}
}
if want just the name of the matching circle
GET my-circle/_search
{
"_source": "locationName", <---- This will return the location name
"query": {
"bool": {
"must": {
"match_all": {}
},
"filter": {
"geo_shape": {
"location": {
"shape": {
"type": "point",
"coordinates": [
0, 70.0
],
"relation": "contains"
}
}
}
}
}
}
}
result
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "my-circle",
"_type" : "_doc",
"_id" : "Ys7N2XcB-yLzgGFD36Ru",
"_score" : 1.0,
"_source" : {
"locationName" : "nowhere"
}
}
]
}
}