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

[GUIDE] Add bulk guide #292

Merged
merged 5 commits into from
Apr 14, 2023
Merged

Conversation

zethuman
Copy link
Contributor

@zethuman zethuman commented Apr 10, 2023

Description

Add bulk guide.

Issues Resolved

Closes [#278, #279].

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@dblock
Copy link
Member

dblock commented Apr 12, 2023

You're missing DCO, same as other PRs.

zethuman and others added 3 commits April 12, 2023 23:29
Signed-off-by: Rakhat Zhuman <zhumanrakhat01@gmail.com>
Signed-off-by: Rakhat Zhuman <zhumanrakhat01@gmail.com>
…ensearch-project#286)

Signed-off-by: Jakob Hahn <jakob.hahn@hetzner.com>
Signed-off-by: Rakhat Zhuman <zhumanrakhat01@gmail.com>
@zethuman
Copy link
Contributor Author

fixed

func main() {
client, err := opensearch.NewDefaultClient()
if err != nil {
log.Printf("error occurred: [%s]", err.Error())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we bailing here in samples, e.g. log.Fatalf?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was guided by the rules from issue, there was written not to throw errors, or did I misunderstand?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, I don't know what's best.

What's the user experience when NewDefaultClient() returns an error with the code as written?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the console there will be a reason why the client was not created and the program will complete successfully, I mean there will be no fatal termination. The user, having read the reason, understands that he did something wrong, and decides the origin reason and tries again.

Copy link
Member

@dblock dblock Apr 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this example the code doesn't do anything else, however in the example below:

movies := "movies"
books := "books"
createMovieIndex, err := client.Indices.Create(movies)
if err != nil {
    log.Printf("error occurred: [%s]", err.Error())
}
log.Printf("response: [%+v]", createMovieIndex)
createBooksIndex, err := client.Indices.Create(books)
if err != nil {
    log.Printf("error occurred: [%s]", err.Error())
}
log.Printf("response: [%+v]", createBooksIndex)

You get an error the first time on client.Indices.Create(movies), then you get an error again the second time on client.Indices.Create(books). I believe we shouldn't be bailing after the first error, no? Furthermore, there should be a way to auto-cleanup whatever was successfully created even if it was only the first and not the second index.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree about the first one, but again I will refer to the guide ... It's not difficult for me to change it for a fatal mistake. At the expense of the second, at the end of each guide there are cleaning topics, and the previously created modules were cleaned there

@dblock dblock merged commit b1508ba into opensearch-project:main Apr 14, 2023
@dblock dblock mentioned this pull request Apr 14, 2023
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.

3 participants