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

Feature request: strong type dsl builder #526

Open
ah-its-andy opened this issue Aug 25, 2022 · 6 comments
Open

Feature request: strong type dsl builder #526

ah-its-andy opened this issue Aug 25, 2022 · 6 comments

Comments

@ah-its-andy
Copy link

the olivere/elastic supports follow codes:
q := elastic.NewBoolQuery() q.Must(elastic.NewTermQuery("id", "1544175232779030532"))
It's definitely more readable.

@Anaethelion
Copy link
Contributor

Thank you for the suggestion!

This is definitely in the long term goals and would qualify as a helper to build specific queries.

It would need to be built by hand upon the generated types to carefully chose what to expose which cannot be done as part of the code generation of the whole typed api.

I'm flagging this issue as an enhancement and will keep it open for future reference!

@JOJO0527
Copy link

This feature is the biggest gap between olivere and the official lib

@lindsayweil-sl
Copy link

I know from previous pull request notes and issue posts as well as the release notes that the typedapi is in alpha. Is there somewhere to subscribe to news on when it will move past the alpha phase? Thanks!

@notque
Copy link

notque commented Mar 22, 2023

Does this include the Filter.query? I rely on this heavily, and am stuck with olivere until I can do this

query := elastic.NewBoolQuery()

if filter.ObserverType != "" {
query = FilterQuery(filter.ObserverType, esFieldMapping["observer_type"], query)
}

@Anaethelion
Copy link
Contributor

@notque I'm not sure what your FilterQuery method does, however you can already do something like this:

s := &search.Request{Query: types.Query{Bool: types.BoolQuery{
	Filter: []types.Query{
		{
			Term: map[string]types.TermQuery{
				"field": {Value: "value"},
			},
		},
	},
}}}

And run that request through the Search endpoint.
If you want to dig further I would advise you to create a specific issue so we can keep this one dedicated to the dsl topic.

@notque
Copy link

notque commented Mar 22, 2023

@Anaethelion understood, I wasn't thinking clearly and didn't show the full piece. I will create a new issue to show. Thanks.

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

No branches or pull requests

5 participants