Skip to content

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

Merged
reta merged 10 commits intoopensearch-project:mainfrom
gaobinlong:enhance_kv
Nov 21, 2023
Merged

Add template snippets support for field and target_field in KV ingest processor#10040
reta merged 10 commits intoopensearch-project:mainfrom
gaobinlong:enhance_kv

Conversation

@gaobinlong
Copy link
Copy Markdown
Contributor

@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.

… processor

Signed-off-by: Gao Binlong <gbinlong@amazon.com>
Signed-off-by: Gao Binlong <gbinlong@amazon.com>
@github-actions
Copy link
Copy Markdown
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
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Copy Markdown
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
Copy Markdown
Contributor

reta commented Nov 15, 2023

@msfroh another one for you :)

Signed-off-by: Gao Binlong <gbinlong@amazon.com>
Signed-off-by: Gao Binlong <gbinlong@amazon.com>
@github-actions
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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
@reta reta added the backport 2.x Backport to 2.x branch label Nov 21, 2023
@opensearch-trigger-bot
Copy link
Copy Markdown
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
Copy Markdown
Contributor

reta commented Nov 21, 2023

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

@gaobinlong
Copy link
Copy Markdown
Contributor 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 <gbinlong@amazon.com>

* modify change log

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* revert replace assertThat by assertEquals

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Revert some code

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Revert some code

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Fix typo and skip some yml test by version

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

---------

Signed-off-by: Gao Binlong <gbinlong@amazon.com>
(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 <gbinlong@amazon.com>

* modify change log

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* revert replace assertThat by assertEquals

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Revert some code

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Revert some code

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Fix typo and skip some yml test by version

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

---------

Signed-off-by: Gao Binlong <gbinlong@amazon.com>
(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 <gbinlong@amazon.com>

* modify change log

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* revert replace assertThat by assertEquals

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Revert some code

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Revert some code

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Fix typo and skip some yml test by version

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

---------

Signed-off-by: Gao Binlong <gbinlong@amazon.com>
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 <gbinlong@amazon.com>

* modify change log

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* revert replace assertThat by assertEquals

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Revert some code

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Revert some code

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Fix typo and skip some yml test by version

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

---------

Signed-off-by: Gao Binlong <gbinlong@amazon.com>
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 <gbinlong@amazon.com>

* modify change log

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* revert replace assertThat by assertEquals

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Revert some code

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Revert some code

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Fix typo and skip some yml test by version

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

---------

Signed-off-by: Gao Binlong <gbinlong@amazon.com>
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 <gbinlong@amazon.com>

* modify change log

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* revert replace assertThat by assertEquals

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Revert some code

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Revert some code

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Fix typo and skip some yml test by version

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

---------

Signed-off-by: Gao Binlong <gbinlong@amazon.com>
Signed-off-by: Shivansh Arora <hishiv@amazon.com>
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