Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement GeoShape query #956

Open
wants to merge 3 commits into
base: release-branch.v6
Choose a base branch
from

Conversation

guilherme-santos
Copy link

No description provided.

@olivere olivere added this to the 6.2.12 milestone Nov 2, 2018
@olivere
Copy link
Owner

olivere commented Nov 2, 2018

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?

@guilherme-santos
Copy link
Author

Sure, I'll do it soon!

@olivere olivere modified the milestones: 6.2.12, 6.2.13 Nov 3, 2018
@olivere olivere modified the milestones: 6.2.13, 6.2.14 Nov 17, 2018
@olivere
Copy link
Owner

olivere commented Dec 1, 2018

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.

@olivere olivere modified the milestones: 6.2.14, 6.2.15 Dec 1, 2018
@olivere olivere modified the milestones: 6.2.15, 6.2.16 Jan 3, 2019
@olivere olivere removed this from the 6.2.16 milestone Jan 27, 2019
@timonmasberg
Copy link

What is the status of this PR? I really need GeoShape support :/

@olivere
Copy link
Owner

olivere commented Feb 1, 2022

@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.

@timonmasberg
Copy link

Okay, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants