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

Equivalent functions for NewBooleanQuery, NewRangeQuery, DeleteByQuery, NewTermQuery, NewBulkIndexRequest #658

Open
harshdeodhar opened this issue Apr 14, 2023 · 2 comments

Comments

@harshdeodhar
Copy link

I am trying to upgrade Elasticsearch in a project from olivere/elastic v5 to elastic/go-elasticsearch v7.
What are the equivalent functions for NewBooleanQuery, NewRangeQuery, DeleteByQuery, NewTermQuery, NewBulkIndexRequest in elastic/go-elasticsearch v7?

To be specific how should I convert the below lines using olivere/elastic v5 to elastic/go-elasticsearch v7:

rangeQuery := elastic.NewBoolQuery()
rangeQuery.Must(elastic.NewRangeQuery("start_time").Lte(time.Now().Add(time.Duration(-20) * time.Minute)))
_, err := esClient.DeleteByQuery().
					Index("abc").
					Query(rangeQuery).
					Pretty(true).
					Do(context.Background())

Same with the below lines:

termQueryDef := elastic.NewTermQuery("DEFid", esQueryDoc.DEFId)
termQueryQwe := elastic.NewTermQuery("qwe", esQueryDoc.qwe)
termQuery := elastic.NewBoolQuery()
termQuery = termQuery.Must(termQueryDef).Must(termQueryQwe)
_, err := esClient.DeleteByQuery().
	Index("xyz").   // search in index
	Query(termQuery). // specify the query
	Pretty(true).     // pretty print request and response JSON
	Do(ctx)           // execute
@lindsayweil-sl
Copy link

I think the closest thing to that isn't in v7 but in v8: https://www.elastic.co/guide/en/elasticsearch/client/go-api/master/examples.html with the typed client. I'm trying to figure out next steps as well.

@azhu0914
Copy link

I think the closest thing to that isn't in v7 but in v8: https://www.elastic.co/guide/en/elasticsearch/client/go-api/master/examples.html with the typed client. I'm trying to figure out next steps as well.

We have been waiting for several years. Without this function, the promotion of the official library will be greatly affected. I think making users feel comfortable to use is our original intention of constantly improving the code, isn’t it?

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

No branches or pull requests

3 participants