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

NIFI-5052 Added DeleteByQuery ElasticSearch processor. #2616

Closed
wants to merge 5 commits into from

Conversation

MikeThomsen
Copy link
Contributor

@MikeThomsen MikeThomsen commented Apr 7, 2018

Thank you for submitting a contribution to Apache NiFi.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced
    in the commit message?

  • Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.

  • Has your PR been rebased against the latest commit within the target branch (typically master)?

  • Is your initial contribution a single, squashed commit?

For code changes:

  • Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
  • Have you written or updated unit tests to verify your changes?
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
  • If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
  • If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?

Note:

Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.

Copy link
Contributor

@zenfenan zenfenan left a comment

Choose a reason for hiding this comment

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

There is one checkstyle violation. Hard to find it from travis log though. Doubt if it has something to do with the comments in POM

@zenfenan
Copy link
Contributor

zenfenan commented Apr 7, 2018

Reviewing..

@MikeThomsen
Copy link
Contributor Author

Anything @zenfenan?

@zenfenan
Copy link
Contributor

zenfenan commented Apr 10, 2018

I'm extremely sorry for the delay. Got held up by some unexpected works. Will try to complete by this week. Is that okay? Meanwhile, the code looks good. I just wanted to try it before approving. :)

@MikeThomsen
Copy link
Contributor Author

@zenfenan sounds like a plan. After the change to expressionLanguageSupport I might have to rebase this today FYI.

PropertyDescriptor QUERY = new PropertyDescriptor.Builder()
.name("el-rest-query")
.displayName("Query")
.description("A query in JSON syntax, not Lucene syntax. Ex: " +
Copy link
Contributor

Choose a reason for hiding this comment

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

description can be more descriptive. If we don't give the query in QUERY then it reads from the flowfile content. I think that can be added to the description.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

<!--<groupId>org.elasticsearch.client</groupId>-->
<!--<artifactId>rest</artifactId>-->
<!--<version>5.6.6</version>-->
<!--</dependency>-->
Copy link
Contributor

Choose a reason for hiding this comment

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

Comments to be deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -137,7 +149,7 @@
<httpPort>9400</httpPort>
<version>5.6.2</version>
<timeout>90</timeout>
<pathInitScript>${project.basedir}/src/test/resources/setup.script</pathInitScript>
<!--<pathInitScript>${project.basedir}/src/test/resources/setup.script</pathInitScript>-->
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. Can they be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

PropertyDescriptor INDEX = new PropertyDescriptor.Builder()
.name("el-rest-fetch-index")
.displayName("Index")
.description("The name of the index to read from")
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this is not introduced by you, rather moved over from JsonQueryElasticSearch but for JsonQueryElasticSearch, the description matched the intention, because it was just reading but since now the delete processor is using this property, changing it to something like "The name of the ElasticSearch Index to use" makes sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

.name("el-rest-query")
.displayName("Query")
.description("A query in JSON syntax, not Lucene syntax. Ex: " +
"{\n" +
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here - not something you introduced but moved and mostly a cosmetic change. Feel free to ignore this. The \t and \n won't be rendered in the UI so simply writing { \"query\": { \"match\": { \"name\": \"John Smith\" } } }" is enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

@zenfenan zenfenan left a comment

Choose a reason for hiding this comment

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

@MikeThomsen I think we are close.. Only one more typo to be fixed.

"\t}\n" +
"}")
.description("A query in JSON syntax, not Lucene syntax. Ex: {\"query\":{\"match\":{\"somefield\":\"somevalue\"}}}. " +
"If this parameter is not set, the query will be ready from the flowfile content.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo : 'read'

@MikeThomsen
Copy link
Contributor Author

@zenfenan Done. Do you have commit privileges? Had to ask because I'm not sure how up to date the team page is on apache.org.

@zenfenan
Copy link
Contributor

zenfenan commented Apr 12, 2018

@MikeThomsen Nope. I don't have commit privileges.

BTW, I have ran the build and tested locally.

  • Tested the new DeleteByQueryElasticsearch processor with both flowfile content as well as Query property
  • Tested the JsonQueryElasticsearch to make sure that the new changes doesn't cause any new issues to it.

Everything works fine and looks good to me. Thanks, @MikeThomsen

@MikeThomsen
Copy link
Contributor Author

Thanks @zenfenan
@mattyb149 @pvillard31 What do you think? Ready to merge?

@MikeThomsen
Copy link
Contributor Author

@JPercivall if you have any time, do you think you could take a look at this?

@JPercivall
Copy link
Contributor

Hey @MikeThomsen sorry to leave you hanging but I just got super busy with my day job. I may be able to help in a couple weeks can't at the moment.

@MikeThomsen
Copy link
Contributor Author

@mattyb149 @pvillard31 Got any time for a review?

@mattyb149
Copy link
Contributor

Reviewing...

"or from the Query parameter.")
@Tags({ "elastic", "elasticsearch", "delete", "query"})
@WritesAttributes({
@WritesAttribute(attribute = "elasticsearch.delete.took"),
Copy link
Contributor

Choose a reason for hiding this comment

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

These should have descriptions as they will be displayed in the processor documentation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>5.6.8</version>
<scope>compile</scope>
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure these need to be explicitly scoped? But if it works, no harm no foul...


@Test
public void testDeleteByQuery() throws Exception {
String query = "{\n" +
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick, but if ES doesn't require the query be pretty-printed, it might be easier to read if it were just a one-line string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@MikeThomsen
Copy link
Contributor Author

@mattyb149 made those changes.

@MikeThomsen
Copy link
Contributor Author

@mattyb149 ready to merge?

@MikeThomsen
Copy link
Contributor Author

@mattyb149 can we close this out? It's blocking me from fleshing out the rest of the CRUD capabilities around the new client service.

@mattyb149
Copy link
Contributor

Sorry I lost track of this, was reviewing your other ones. I'll try to take a look ASAP

@MikeThomsen
Copy link
Contributor Author

Thanks and np. We need more committers :)

@mattyb149
Copy link
Contributor

+1 LGTM, ran the build with tests and contrib-check, also tested various situations (with/out incoming connections, valid/invalid queries, etc.) and all looks good. Thanks for this feature! Merging to master

@asfgit asfgit closed this in 3a29c1e May 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants