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

[DOC] Missing documentation executing stored scripts in update/bulk operations #7248

Closed
1 of 4 tasks
camerondurham opened this issue May 25, 2024 · 5 comments · Fixed by #7397
Closed
1 of 4 tasks
Assignees
Labels
3 - Done Issue is done/complete security

Comments

@camerondurham
Copy link

What do you want to do?

  • Request a change to existing documentation
  • Add new documentation
  • Report a technical problem with the documentation
  • Other

Tell us about your request. Provide a summary of the request and all versions that are affected.

As an OpenSearch user, I would like to have documentation around how to perform operations using a stored script. The docs cover how to use inline scripts but not how to reference a stored script.

Please let me know if I maybe missed it in documentation, or if this is too much of an "edge-case" to be useful.

Here's a specific, potentially useful example it would nice to have documentation around:

Example below executes the conditional script in a cluster with incoming doc in params to conditionally update the doc with _id=test-1. I came across this while answering this amazon-opensearch question and didn't find docs to link to.

curl -XPOST "http://localhost:9200/_bulk?_source=true" -H 'Content-Type: application/json' -d'
    {"update":{"_index":"overflow-index","_type":"_doc","_id":"test-1","retry_on_conflict":1}}
    {"script":{"id":"conditional","params":{ "uuid": "test", "status": false, "timestamp": "3994-01-31T23:05:09.909525Z"}}}
'

Also, I'm happy PR as long I know where and how documentation owners think this should be updated.

Thanks!

What other resources are available? Provide links to related issues, POCs, steps for testing, etc.

@hdhalter
Copy link
Contributor

@camerondurham
Copy link
Author

Hi @hdhalter ,
Thanks for pointing out that documentation, (https://opensearch.org/docs/latest/api-reference/script-apis/exec-stored-script/#running-a-painless-stored-script-with-parameters). I had missed it earlier.

Would it be helpful to clarify if/when stored scripts can be used in other contexts (bulk, update by query, index, etc.)? Or should developers infer that stored scripts can be referenced wherever scripts are allowed?

Ref:

I'm okay to close the issue if the current documentation is sufficient.

@hdhalter
Copy link
Contributor

hdhalter commented Jun 6, 2024

@dhwanilpatel - Do you have any thoughts on this?

@hdhalter hdhalter added 1 - Backlog - DEV Developer assigned to issue is responsible for creating PR. and removed untriaged labels Jun 6, 2024
@dhwanilpatel
Copy link

dhwanilpatel commented Jun 11, 2024

While passing script in APIs, we need to pass either "source" or "id", so it seems we can pass the id for the stored script instead of source.

https://github.com/opensearch-project/OpenSearch/blob/f2ed7d6071145d1e4e98f6e988be9392fdf9939a/server/src/main/java/org/opensearch/script/Script.java#L363-L366

We can include this one liner in our documentation so users wont have to go through the code to understand this.

@leanneeliatra
Copy link
Contributor

I'll update this @hdhalter, please assign me.

@hdhalter hdhalter added 2 - In progress Issue/PR: The issue or PR is in progress. security and removed 1 - Backlog - DEV Developer assigned to issue is responsible for creating PR. labels Jun 14, 2024
@hdhalter hdhalter added 3 - Done Issue is done/complete and removed 2 - In progress Issue/PR: The issue or PR is in progress. labels Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Done Issue is done/complete security
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants