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

Improve consistency of JSONPath parsing & execution across frontend/backend #481

Merged
merged 4 commits into from
Nov 15, 2024

Conversation

ohltyler
Copy link
Member

@ohltyler ohltyler commented Nov 15, 2024

Description

This PR improves the path parsing and JSONPath handling when configuring advanced transforms in the ML processors. Added detailed comments in the source code for readability.

  • improves generateTransform to handle more edge cases and be consistent without the backend handles path parsing for the different scenarios (input vs. output, ingest vs. search request vs. search response).
  • adds newsanitizeJSONPath() fn used in 2 places: 1/ when auto-populating keys for the query or document JSONs (ensures they will run consistently on frontend & backend), and 2/ when converting to a template (to ensure it runs properly on the backend).
  • adds new fn isIndefiniteJsonPath() to help make the return values of a JSONPath execution consistent. Note: this is not a full-featured fn. The frontend libraries do not have any configuration similar to ALWAYS_RETURN_LIST, nor a mechanism to determine whether a path is definite or indefinite. The purpose of this function is to broadly cover the majority of use cases to mimic the implementation as close as possible.

More details on the fixes this covers in the related issue #478 .

Issues Resolved

Resolves #478

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

jsonpath.query(input, path)
: // Standard dot notation
get(input, path);
// Rregular dot notation can only be executed if 1/ the JSONPath selector is not explicitly defined,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit : Regular

@ohltyler ohltyler marked this pull request as draft November 15, 2024 21:04
@ohltyler ohltyler marked this pull request as ready for review November 15, 2024 22:36
@ohltyler ohltyler merged commit 75ae094 into opensearch-project:main Nov 15, 2024
7 checks passed
@ohltyler ohltyler deleted the jsonpath-fixes branch November 15, 2024 22:45
opensearch-trigger-bot bot pushed a commit that referenced this pull request Nov 15, 2024
…ackend (#481)

Signed-off-by: Tyler Ohlsen <[email protected]>
(cherry picked from commit 75ae094)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
ohltyler pushed a commit that referenced this pull request Nov 15, 2024
…ackend (#481) (#482)

(cherry picked from commit 75ae094)

Signed-off-by: Tyler Ohlsen <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve handling edge cases regarding JSONPath / dot notation discrepancies
2 participants