Skip to content

Allow script to have string or object value #2960

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Mar 27, 2025
Merged

Conversation

l-trotta
Copy link
Contributor

Originally reported as a Java Client issue.

PutScript API support either the source of the script as a string, or as a Search Template object, which is equivalent to the whole SearchRequest body.

Since the Search Request body is also needed by Multisearch, it was extracted as a separate class in the search package to that both Multisearch and StoredScript can use it (it was also ordered alphabetically).

source in StoredScript is now an externally tagged union. (potentially breaking for generators)

Ideally nothing else should be changed in the client codes as a result of this PR except for StoredScript, I'm setting this up as a draft for now, let me know when the generators are ready.

Copy link
Contributor

Following you can find the validation results for the APIs you have changed.

API Status Request Response
msearch 🟢 17/17 16/16
search 🔴 2204/2262 2243/2244

You can validate these APIs yourself by using the make validate target.

@l-trotta l-trotta marked this pull request as draft September 27, 2024 15:14
@technige technige added the tracking Tracking in DevTools roadmap label Oct 4, 2024
Copy link
Member

@pquentin pquentin left a comment

Choose a reason for hiding this comment

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

Since this does not affect elasticsearch-py, I'm approving.

However since it could affect elasticsearch-dsl-py, I added @miguelgrinberg to the list of reviewers.

Copy link
Contributor

@miguelgrinberg miguelgrinberg left a comment

Choose a reason for hiding this comment

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

LGTM. And the Python DSL client is not affected by this change.

@l-trotta
Copy link
Contributor Author

thank you both! I'll remember the python dsl for future issues

@JoshMock
Copy link
Member

Shouldn't cause any issues for the JS generator either. 👍

@flobernd
Copy link
Member

flobernd commented Feb 5, 2025

The same change should be applied to Script.source, RenderSearchTemplate.source, PhraseSuggestCollateQuery.source (and probably more places).

@l-trotta l-trotta force-pushed the support-object-as-script branch from 762d4cc to 8e5bcad Compare March 27, 2025 15:32
Copy link
Contributor

Following you can find the validation results for the APIs you have changed.

API Status Request Response
msearch 🟢 17/17 16/16
search 🔴 2320/2404 2387/2388

You can validate these APIs yourself by using the make validate target.

@l-trotta l-trotta marked this pull request as ready for review March 27, 2025 15:34
Copy link
Contributor

Following you can find the validation results for the APIs you have changed.

API Status Request Response
ingest.delete_geoip_database 🟢 1/1 1/1
ingest.delete_ip_location_database 🟢 1/1 1/1
ingest.delete_pipeline 🟢 15/15 15/15
ingest.geo_ip_stats 🟢 1/1 1/1
ingest.get_geoip_database 🟢 6/6 6/6
ingest.get_ip_location_database 🟢 7/7 7/7
ingest.get_pipeline 🟢 22/22 22/22
ingest.processor_grok 🟢 1/1 1/1
ingest.put_geoip_database 🟢 3/3 3/3
ingest.put_ip_location_database 🟢 4/4 4/4
ingest.put_pipeline 🟢 60/60 60/60
ingest.simulate 🟢 10/10 10/10
msearch_template 🟢 1/1 1/1
msearch 🟢 17/17 16/16
render_search_template 🟢 1/1 1/1
search_template 🟢 2/2 1/1
search 🔴 2320/2404 2387/2388
watcher.ack_watch 🟢 1/1 1/1
watcher.activate_watch 🟢 1/1 1/1
watcher.deactivate_watch 🟢 1/1 1/1
watcher.delete_watch 🟢 2/2 2/2
watcher.execute_watch 🟢 7/7 7/7
watcher.get_settings Missing test Missing test
watcher.get_watch 🟢 9/9 9/9
watcher.put_watch 🔴 29/38 38/38
watcher.query_watches Missing test Missing test
watcher.start 🟢 1/1 1/1
watcher.stats 🟢 1/1 1/1
watcher.stop 🟢 1/1 1/1
watcher.update_settings Missing test Missing test

You can validate these APIs yourself by using the make validate target.

@Anaethelion Anaethelion merged commit 1706b81 into main Mar 27, 2025
8 checks passed
@Anaethelion Anaethelion deleted the support-object-as-script branch March 27, 2025 17:04
Copy link
Contributor

The backport to 9.0 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-9.0 9.0
# Navigate to the new working tree
cd .worktrees/backport-9.0
# Create a new branch
git switch --create backport-2960-to-9.0
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 1706b81e4754756bda1936bd4d4c34eac80dbe5e
# Push it to GitHub
git push --set-upstream origin backport-2960-to-9.0
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-9.0

Then, create a pull request where the base branch is 9.0 and the compare/head branch is backport-2960-to-9.0.

l-trotta added a commit that referenced this pull request Mar 27, 2025
* search body refactor + object script

* many more scripts
JoshMock added a commit to elastic/elasticsearch-js that referenced this pull request Apr 4, 2025
The spec combined definitions for search and multisearch bodies in
elastic/elasticsearch-specification#2960.
JoshMock added a commit to elastic/elasticsearch-js that referenced this pull request Apr 4, 2025
* Update helpers to use correct multisearch types

The spec combined definitions for search and multisearch bodies in
elastic/elasticsearch-specification#2960.

* Stop copying project files to Dockerfile

Slightly faster run times for codegen, hopefully.
github-actions bot pushed a commit to elastic/elasticsearch-js that referenced this pull request Apr 4, 2025
* Update helpers to use correct multisearch types

The spec combined definitions for search and multisearch bodies in
elastic/elasticsearch-specification#2960.

* Stop copying project files to Dockerfile

Slightly faster run times for codegen, hopefully.

(cherry picked from commit b2a4907)
JoshMock added a commit to elastic/elasticsearch-js that referenced this pull request Apr 4, 2025
* Update helpers to use correct multisearch types

The spec combined definitions for search and multisearch bodies in
elastic/elasticsearch-specification#2960.

* Stop copying project files to Dockerfile

Slightly faster run times for codegen, hopefully.

(cherry picked from commit b2a4907)

Co-authored-by: Josh Mock <joshua.mock@elastic.co>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
backport 9.0 specification tracking Tracking in DevTools roadmap
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants