sudo-suhas / elastic-builder

A Node.js implementation of the elasticsearch Query DSL :construction_worker:
https://elastic-builder.js.org
MIT License
508 stars 75 forks source link

feat: Add support for runtime_mapping #165

Closed jmaitrehenry closed 7 months ago

jmaitrehenry commented 1 year ago

Fix #152

Add the support for runtime_mapping like:

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

This will generate a query like that:

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

will try to check this during the weekend. Thanks @jmaitrehenry for the PR.

jmaitrehenry commented 1 year ago

Thanks for the review @sudo-suhas, I will try to update it in the next few days.

sudo-suhas commented 1 year ago

ping @jmaitrehenry

pimpelsang commented 1 year ago

please finish it :)

atreids commented 7 months ago

Hi, I've raised a separate pull request based on @jmaitrehenry 's work to try and get this feature merged. @sudo-suhas If you have some time to review, that would be greatly appreciated.