elastic
elastic copied to clipboard
Implement GeoShape query
Thank you very much for working on this!
When I add new queries, I typically use the Java source as a basis. It often has more fields than documented at the official manual. E.g. GeoShapeQueryBuilder.java
has these fields, serializes in this way. Can you look into that and complete the query?
Sure, I'll do it soon!
I was toying around a bit with this, but I'm still not happy with the outcome. I'm experimenting a bit with different ShapeBuilders
(as they call it in the Java source) that are used to create the inner shape
object and its coordinates. Also, I'm trying to use the naming from the Java source, so indexedShapeIndex
and indexedShapeType
instead of index
and typ
etc. So I'll delay this a bit and hope to include it in the 6.2.15 release.
What is the status of this PR? I really need GeoShape support :/
@timonmasberg Creating all the different builders is a lot of work. It has been mentioned in several issues how one can do that. I'm struggling with time to do it for a while now.
The workaround is to build the query yourself. You can e.g. always use RawStringQuery
like so:
q := elastic.NewRawStringQuery(`{
"geo_shape": {
"location": {
"shape": {
"type": "envelope",
"coordinates": [ [ 13.0, 53.0 ], [ 14.0, 52.0 ] ]
},
"relation": "within"
}
}`)
res, err := client.Search().
Index("YOUR_INDEX_NAME").
Query(q).
Do(ctx)
...
... or build your own Query
implementation.
Okay, thank you!