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

Add template snippets support for field and target_field in KV ingest processor #10040

Merged
merged 10 commits into from
Nov 21, 2023

Conversation

gaobinlong
Copy link
Collaborator

@gaobinlong gaobinlong commented Sep 14, 2023

Description

Add template snippets support for field and target_field parameters in KV ingest processor so that users can use mustache script like {{some filed}} to set those parameters.

Here is an example:

POST /_ingest/pipeline/_simulate
{
  "pipeline": {
    "description": "_description",
    "processors": [
      {
        "kv": {
          "field": "{{key}}",
          "field_split": " ",
          "value_split": "=",
          "target_field": "{{target_field}}"
        }
      }
    ]
  },
  "docs": [
    {
      "_index": "index",
      "_id": "id",
      "_source": {
        "key":"foo",
        "foo": "bar=x",
        "target_field":"zoo"
      }
    },
    {
      "_index": "index",
      "_id": "id",
      "_source": {
        "key":"foo",
        "foo": "rab=x",
        "target_field":"zoo"
      }
    }
  ]
}

The response is:

{
  "docs": [
    {
      "doc": {
        "_index": "index",
        "_id": "id",
        "_source": {
          "zoo": {
            "bar": "x"
          },
          "target_field": "zoo",
          "key": "foo",
          "foo": "bar=x"
        },
        "_ingest": {
          "timestamp": "2023-09-14T03:37:21.612363Z"
        }
      }
    },
    {
      "doc": {
        "_index": "index",
        "_id": "id",
        "_source": {
          "zoo": {
            "rab": "x"
          },
          "target_field": "zoo",
          "key": "foo",
          "foo": "rab=x"
        },
        "_ingest": {
          "timestamp": "2023-09-14T03:37:21.612463Z"
        }
      }
    }
  ]
}

The main changes of this PR are:

  1. Add template snippets support for field and target_field parameters in KV ingest processor.
  2. Same to Fix ignore_missing parameter has no effect in rename ingest processor #9725, we also need to avoid ignore_missing parameter taking no effect when the filed in template snippet doesn't exist.
  3. Add some yml tests for the change.

Related Issues

#9964

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)

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.

Signed-off-by: Gao Binlong <[email protected]>
@github-actions
Copy link
Contributor

github-actions bot commented Sep 14, 2023

Compatibility status:

Checks if related components are compatible with change cd50504

Incompatible components

Incompatible components: [https://github.com/opensearch-project/k-nn.git, https://github.com/opensearch-project/performance-analyzer.git]

Skipped components

Compatible components

Compatible components: [https://github.com/opensearch-project/security-analytics.git, https://github.com/opensearch-project/opensearch-oci-object-storage.git, https://github.com/opensearch-project/observability.git, https://github.com/opensearch-project/notifications.git, https://github.com/opensearch-project/custom-codecs.git, https://github.com/opensearch-project/job-scheduler.git, https://github.com/opensearch-project/security.git, https://github.com/opensearch-project/neural-search.git, https://github.com/opensearch-project/asynchronous-search.git, https://github.com/opensearch-project/reporting.git, https://github.com/opensearch-project/ml-commons.git, https://github.com/opensearch-project/sql.git, https://github.com/opensearch-project/geospatial.git, https://github.com/opensearch-project/index-management.git, https://github.com/opensearch-project/common-utils.git, https://github.com/opensearch-project/anomaly-detection.git, https://github.com/opensearch-project/cross-cluster-replication.git, https://github.com/opensearch-project/performance-analyzer-rca.git, https://github.com/opensearch-project/alerting.git]

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Copy link
Contributor

❌ Gradle check result for e4a31b7: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@reta
Copy link
Collaborator

reta commented Nov 15, 2023

@msfroh another one for you :)

Copy link
Contributor

❕ Gradle check result for cd50504: UNSTABLE

  • TEST FAILURES:
      1 org.opensearch.index.IndexServiceTests.testAsyncTranslogTrimTaskOnClosedIndex

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

@reta you good with this?

@reta
Copy link
Collaborator

reta commented Nov 21, 2023

@gaobinlong could you please create a documentation issue update for this processor? (https://github.com/opensearch-project/documentation-website/) Thank you.

@reta reta added v3.0.0 Issues and PRs related to version 3.0.0 Indexing Indexing, Bulk Indexing and anything related to indexing API Issues with external APIs and removed stalled Issues that have stalled labels Nov 21, 2023
@reta reta merged commit 7f4537c into opensearch-project:main Nov 21, 2023
47 of 51 checks passed
@reta reta added the backport 2.x Backport to 2.x branch label Nov 21, 2023
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

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

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch/backport-2.x
# Create a new branch
git switch --create backport/backport-10040-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 7f4537c3d4068a117576e6e2214eaf924db6748f
# Push it to GitHub
git push --set-upstream origin backport/backport-10040-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-10040-to-2.x.

@reta
Copy link
Collaborator

reta commented Nov 21, 2023

@gaobinlong could you please send a manual backport to 2.x? thank you

@gaobinlong
Copy link
Collaborator Author

@reta, sure, I'll create a backport PR and documentation PR for this change later.

gaobinlong added a commit to gaobinlong/OpenSearch that referenced this pull request Nov 22, 2023
… processor (opensearch-project#10040)

* Add template snippets support for field and target_field in KV ingest processor

Signed-off-by: Gao Binlong <[email protected]>

* modify change log

Signed-off-by: Gao Binlong <[email protected]>

* revert replace assertThat by assertEquals

Signed-off-by: Gao Binlong <[email protected]>

* Revert some code

Signed-off-by: Gao Binlong <[email protected]>

* Revert some code

Signed-off-by: Gao Binlong <[email protected]>

* Fix typo and skip some yml test by version

Signed-off-by: Gao Binlong <[email protected]>

---------

Signed-off-by: Gao Binlong <[email protected]>
(cherry picked from commit 7f4537c)
reta pushed a commit that referenced this pull request Nov 22, 2023
… processor (#10040) (#11300)

* Add template snippets support for field and target_field in KV ingest processor

Signed-off-by: Gao Binlong <[email protected]>

* modify change log

Signed-off-by: Gao Binlong <[email protected]>

* revert replace assertThat by assertEquals

Signed-off-by: Gao Binlong <[email protected]>

* Revert some code

Signed-off-by: Gao Binlong <[email protected]>

* Revert some code

Signed-off-by: Gao Binlong <[email protected]>

* Fix typo and skip some yml test by version

Signed-off-by: Gao Binlong <[email protected]>

---------

Signed-off-by: Gao Binlong <[email protected]>
(cherry picked from commit 7f4537c)
fahadshamiinsta pushed a commit to fahadshamiinsta/OpenSearch270 that referenced this pull request Dec 4, 2023
… processor (opensearch-project#10040)

* Add template snippets support for field and target_field in KV ingest processor

Signed-off-by: Gao Binlong <[email protected]>

* modify change log

Signed-off-by: Gao Binlong <[email protected]>

* revert replace assertThat by assertEquals

Signed-off-by: Gao Binlong <[email protected]>

* Revert some code

Signed-off-by: Gao Binlong <[email protected]>

* Revert some code

Signed-off-by: Gao Binlong <[email protected]>

* Fix typo and skip some yml test by version

Signed-off-by: Gao Binlong <[email protected]>

---------

Signed-off-by: Gao Binlong <[email protected]>
deshsidd pushed a commit to deshsidd/OpenSearch that referenced this pull request Dec 11, 2023
… processor (opensearch-project#10040)

* Add template snippets support for field and target_field in KV ingest processor

Signed-off-by: Gao Binlong <[email protected]>

* modify change log

Signed-off-by: Gao Binlong <[email protected]>

* revert replace assertThat by assertEquals

Signed-off-by: Gao Binlong <[email protected]>

* Revert some code

Signed-off-by: Gao Binlong <[email protected]>

* Revert some code

Signed-off-by: Gao Binlong <[email protected]>

* Fix typo and skip some yml test by version

Signed-off-by: Gao Binlong <[email protected]>

---------

Signed-off-by: Gao Binlong <[email protected]>
rayshrey pushed a commit to rayshrey/OpenSearch that referenced this pull request Mar 18, 2024
… processor (opensearch-project#10040)

* Add template snippets support for field and target_field in KV ingest processor

Signed-off-by: Gao Binlong <[email protected]>

* modify change log

Signed-off-by: Gao Binlong <[email protected]>

* revert replace assertThat by assertEquals

Signed-off-by: Gao Binlong <[email protected]>

* Revert some code

Signed-off-by: Gao Binlong <[email protected]>

* Revert some code

Signed-off-by: Gao Binlong <[email protected]>

* Fix typo and skip some yml test by version

Signed-off-by: Gao Binlong <[email protected]>

---------

Signed-off-by: Gao Binlong <[email protected]>
shiv0408 pushed a commit to Gaurav614/OpenSearch that referenced this pull request Apr 25, 2024
… processor (opensearch-project#10040)

* Add template snippets support for field and target_field in KV ingest processor

Signed-off-by: Gao Binlong <[email protected]>

* modify change log

Signed-off-by: Gao Binlong <[email protected]>

* revert replace assertThat by assertEquals

Signed-off-by: Gao Binlong <[email protected]>

* Revert some code

Signed-off-by: Gao Binlong <[email protected]>

* Revert some code

Signed-off-by: Gao Binlong <[email protected]>

* Fix typo and skip some yml test by version

Signed-off-by: Gao Binlong <[email protected]>

---------

Signed-off-by: Gao Binlong <[email protected]>
Signed-off-by: Shivansh Arora <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Issues with external APIs backport 2.x Backport to 2.x branch backport-failed Indexing Indexing, Bulk Indexing and anything related to indexing v3.0.0 Issues and PRs related to version 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants