-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Add "remove a tag" script logic as an example #32556
Conversation
It took me quite a while of online searching and experimenting to realize the function-call asymmetry in the Add versus Remove from a list, like the "tags" list! I realize we cannot give examples for every single thing the user wants to do in Painless, but this is such a common use case (removing a tag from a single doc, or from a set of docs with Update-By-Query) that I believe it ought to be demonstrated immediately after the "add a tag" example. We have an example of removing an entire document field, but not removing one element of a list (a multi-valued field). Also, a minor grammar fix: I have added an apostrophe to the word "its" in the accompanying text of the example just above.
Pinging @elastic/es-core-infra |
Hi! This was my first pull request, so I don't know if I did it properly, but I believe I did. It's not code, merely documentation, so it might not be as important as real code, but I do think its inclusion would help other users who were in the same boat as I was. I respectfully submit it for your consideration to add to the docs. Thanks! |
@JeffSaxeVA Thank you for the contribution. This looks good to me. |
@elasticmachine test this please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will commit once it passes CI.
@elasticmachine test this please |
@JeffSaxeVA Unfortunately the docs tests produced an error with this commit. You should be able to run I'm seeing the following error:
|
Wow. I didn't realize there was such a sophisticated CI / test suite behind even the documentation! I didn't pull down an entire copy of the master to my local workstation using git; I merely edited the one file in question here, right inside the github portal, directly creating a check-in patch and a pull request right on the site. So I'm not sure I can easily "sync with master and push". But I'm looking at the gradle output that you quoted, and it looks like a spurious failure. Each of the examples is being executed against a sample index called "test", trying to modify a document type "_doc" with unique ID "1". Most of the examples will actually have some effect (incrementing a counter, or adding a tag), so in each case, it would store back a new document with that ID, with new content and with an incremented _version. In fact if my new example code is executed serially right after the previous example of adding a tag "blue", then it would correctly remove that tag "blue", so the new doc would be different. But if each example is tested individually in a vacuum, with a fresh environment and no preexisting "test" index, then my example will test for the existence of a "blue" tag, discover that there isn't one, and then come up with no modifications to the source, so I guess it would turn into a "noop" update. But then I don't know why the _version would be incremented from 6 to 7, but even if it is, that would be harmless. Maybe that's it... is the gradle test written so that a "noop" result should always imply that the _version number stays the same? I am not sure how I can fix this problem. I'm pretty sure my code snippet works (used it myself to bulk-repair some faulty documents at my job), so I'm not sure how I can convince gradle that it doesn't have an error. Hmm. |
retest this please |
I have merged master in and ran tests again, fingers crossed ;) |
retest this please |
retest this please |
hi @JeffSaxeVA I could verify that the error was caused by your change. A snippet down below was checking that the version of the document was set to |
Ah, thank you, @javanna! I now see how it works... TEST, TEST, then a TESTRESPONSE that is checked for correctness. That's a good way to make documentation with code snippets and ensure the code works. Thanks for your generosity in repairing and reformatting my contribution, and my apologies for not discovering the 6 and 7 a bit further down within the same document. |
the current failure is unrelated, I will trigger a new build once we fixed that upstream. |
retest this please |
thanks @JeffSaxeVA ! |
It took me quite a while of online searching and experimenting to realize the function-call asymmetry in the Add versus Remove from a list, like the "tags" list! I realize we cannot give examples for every single thing the user wants to do in Painless, but this is such a common use case (removing a tag from a single doc, or from a set of docs with Update-By-Query) that I believe it ought to be demonstrated immediately after the "add a tag" example. We have an example of removing an entire document field, but not removing one element of a list (a multi-valued field). Also, a minor grammar fix: I have added an apostrophe to the word "its" in the accompanying text of the example just above.
* 6.x: (42 commits) [DOCS] Splits the users API documentation into multiple pages (#32825) [DOCS] Splits the token APIs into separate pages (#32865) [DOCS] Creates redirects for role management APIs page Bypassing failing test PainlessDomainSplitIT#testHRDSplit (#32966) TEST: Mute testRetentionPolicyChangeDuringRecovery [DOCS] Fixes more broken links to role management APIs [Docs] Tweaks and fixes to rollup docs [DOCS] Fixes links to role management APIs [ML][TEST] Fix BasicRenormalizationIT after adding multibucket feature [DOCS] Splits the roles API documentation into multiple pages (#32794) [TEST] Run pre 6.4 nodes in non-FIPS JVMs (#32901) Remove assertion in testDocStats on deletedDocs counter (#32914) [ML] fix updating opened jobs scheduled events (#31651) (#32881) Enable FIPS140LicenseBootstrapCheck (#32903) HLRC: Move ML request converters into their own class (#32906) [DOCS] Update getting-started.asciidoc (#29518) Fix allowed value for HighlighterBuilder encoder in javadocs (#32780) [DOCS] Add "remove a tag" script logic as an example (#32556) RFC: Test that example plugins build stand-alone (#32235) Security: remove put privilege API (#32879) ...
It took me quite a while of online searching and experimenting to realize the function-call asymmetry in the Add versus Remove from a list, like the "tags" list! I realize we cannot give examples for every single thing the user wants to do in Painless, but this is such a common use case (removing a tag from a single doc, or from a set of docs with Update-By-Query) that I believe it ought to be demonstrated immediately after the "add a tag" example. We have an example of removing an entire document field, but not removing one element of a list (a multi-valued field).
Also, a minor grammar fix: I have added an apostrophe to the word "its" in the accompanying text of the example just above.