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

Enhance contains condition to work on fields that are arrays of string #2248

Merged
merged 1 commit into from
Aug 12, 2016

Conversation

andrewkroh
Copy link
Member

Addresses #2237

@@ -269,26 +269,36 @@ func (c *Condition) checkEquals(event common.MapStr) bool {
}

func (c *Condition) checkContains(event common.MapStr) bool {

outer:
Copy link
Collaborator

Choose a reason for hiding this comment

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

argh :-(

Copy link
Member Author

@andrewkroh andrewkroh Aug 12, 2016

Choose a reason for hiding this comment

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

Why no love for the label? Naming?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not supported in my brain :-D

@ruflin
Copy link
Collaborator

ruflin commented Aug 12, 2016

LGTM

@ruflin ruflin merged commit c010bae into elastic:master Aug 12, 2016
if !strings.Contains(*value.(*string), equalValue) {
return false
}
case []string:
Copy link
Contributor

Choose a reason for hiding this comment

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

@andrewkroh why not ?

found := false
for _, s := range value.([]string) {
  if strings.Contains(s, equalValue) {
   found = true
  }
}
if !found {
  return false
}

Copy link
Member Author

@andrewkroh andrewkroh Aug 16, 2016

Choose a reason for hiding this comment

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

They are equivalent if you add the required break statement to the snippet above. But the code in the PR is a bit more concise.

@monicasarbu
Copy link
Contributor

@andrewkroh does it work without updating setContains() function?

@monicasarbu
Copy link
Contributor

@andrewkroh can you please add documentation for it?

@andrewkroh
Copy link
Member Author

does it work without updating setContains() function?

Yes, setContains is for reading the configuration as I understand it. This PR does not make any changes to what is accepted as part of the configuration (it accepts a single string). The PR only enhances it to work properly when the field in the event is an array.

@andrewkroh
Copy link
Member Author

andrewkroh commented Aug 16, 2016

can you please add documentation for it?

I have updated to docs. See #2285

@monicasarbu monicasarbu deleted the feature/contains-array branch August 22, 2016 10:06
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.

3 participants