I am working with data ingested via Logstash, which has these fields among others:
"location_center": [
20.4222935,
44.815367
],
"location": {
"type": "envelope",
"coordinates": [
[
20.221376,
44.942688
],
[
20.623211,
44.688046
]
]
}
I can't seem to find a way to search by their values, like matching all that are contained inside given coordinates. I tried both in Kibana data view and via NEST.
Here is my C# code:
var local = new Uri("http://localhost:9200");
var settings = new ConnectionSettings(local).DefaultIndex("lyrics_data");
var client = new ElasticClient(settings);
var searchResponse = client.Search<Song>(s => s.PostFilter
(f => f.Bool(b => b
.Must(mu =>
{
return mu;
}
)))
.Query(q => q.Bool(b => b
.Must(mu =>
{
if (Location != "All")
{
mu.GeoShape(c => c
.Field(p => p.Location)
.Shape(s => s
.Envelope(getSelectedNW(), getSelectedSE())
)
.Relation(GeoShapeRelation.Contains));
}
return mu;
})
)
)
);
var songs = new List<Song>();
foreach (var hit in searchResponse.Hits)
{
songs.Add(hit.Source);
}
return songs;
getSelectedNW and getSelectedSE return GeoCoordinate points.
I don't know how to define location and location_center in POCO. Object doesn't work. Excerpt from Song POCO:
[Object(Name = "location")]
public Object Location { get; set; }