Kibaba Plugin - how to insert data into elasticsearch

let say I have a plugin with route:

router.post(
    {
      path: '/api/dashboard_real_time/create',
      validate: {
        body: schema.object({
          fullName: schema.string(),
          age: schema.number(),
          status: schema.number()
        })
      },
    },
    async (context, request, response) => {
      // then i wanna insert some data into elasticsearch here
      return response.ok({
        body: {
          time: new Date().toISOString(),
        },
      });
    }
  );

I am confused to use the kibana elastic search service or data plugin or elasticsearchjs (which i have to config authentication manually).
Please give me some sample code. Thank alot!

Hello,

Here is our official elasticsearch node JS client - GitHub - elastic/elasticsearch-js: Official Elasticsearch client library for Node.js

I suspect that is what you need to use. Let me know if the docs are not enough.

Thanks,
Bhavya

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.