Skip to content

add create/create_unless_exists actions support to node client (from pickypg) #39

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

Closed
wants to merge 1 commit into from

Conversation

talevy
Copy link
Contributor

@talevy talevy commented Jan 21, 2015

original PR: #29

@pickypg

subject.register
subject.receive(LogStash::Event.new("message" => "sample message here"))
subject.buffer_flush(:final => true)
es.indices.refresh
Copy link
Contributor

Choose a reason for hiding this comment

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

we can do a get here immediately to assert the existence of the doc (without a refresh)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is needed, otherwise does not get indexed in time

Copy link
Contributor

Choose a reason for hiding this comment

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

aye, for search we need a refresh..get is real time :) anyhow, can leave this as is

@suyograo
Copy link
Contributor

+1, one new test needed to verify behavior

@@ -178,6 +178,8 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
#
# - index: indexes a document (an event from Logstash).
# - delete: deletes a document by id
# - create_unless_exists: creates a document, raises exception if no id is provided
Copy link
Contributor

Choose a reason for hiding this comment

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

Also fails if a document by that id already exists in the index.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should explicitly document that this is not supported by the HTTP client unless it does. I'm torn on that difference too, but it makes sense for the HTTP client to be a bit truer to the REST spec.

Copy link
Contributor

Choose a reason for hiding this comment

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

this isn't supported by the http client?

Copy link
Contributor

Choose a reason for hiding this comment

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

wording - "raises exception" <-- exceptions are something developers care about. Maybe instead say "will fail if no ID is provided or if the document already exists?"

The important phrase to change, for me, is "raises exception" (dev focused) to be "fails" (user focused)

Copy link
Contributor

Choose a reason for hiding this comment

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

@jordansissel No, that's why we changed it from create originally to create_unless_exists to drive home that it's different.

The functionality implied by create_unless_exists is still true in the HTTP client as long as you supply an ID with create. The only difference is that create_unless_exists requires you to specify the ID (as opposed to create, which will generate one if not supplied).

@suyograo
Copy link
Contributor

LGTM

@elasticsearch-bot
Copy link

Merged sucessfully into master!

@talevy talevy closed this in 352f48b Jan 22, 2015
@talevy talevy deleted the feature/create branch January 22, 2015 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants