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

Feat/Add support for runtime_mappings [Issue: #152] #196

Merged
merged 4 commits into from
Mar 10, 2024

Conversation

atreids
Copy link
Contributor

@atreids atreids commented Feb 28, 2024

Issue:

resolves #152

Additional Author

Original PR was raised by @jmaitrehenry but appears to be abandoned. This PR attempts to complete implementation of this feature, based upon his original work.

Aim:

Add support for Elasticsearch runtime_mappings field, added in v7.11.0.

Usage:

const field = esb.runtimeField(
      'keyword',
      `emit(doc['sessionId'].value + '::' + doc['name'].value)`,
);
const reqBody = esb.requestBodySearch();
reqBody.runtimeMapping('sessionId-eventName', field);

Will generate query:

{
  "runtime_mappings": {
    "sessionId-eventName": {
      "type": "keyword",
      "script": {
        "source": "emit(doc['sessionId'].value + '::' + doc['name'].value)"
      }
    }
  }
}

Changes from original PR

  • Removed name property from RuntimeField class. It, as far as I could tell, didn't do anything. The name for the runtime field is set as the first param of runtimeMapping.
  • Updated and expanded JSDocs.
  • Expanded typing.
  • Renamed some variables.

@sudo-suhas sudo-suhas merged commit 2572468 into sudo-suhas:master Mar 10, 2024
9 checks passed
@sudo-suhas
Copy link
Owner

Thanks again @atreids for the PR!

Copy link

🎉 This PR is included in version 2.28.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

Support to runtime_mappings
3 participants