Get response after recorded

Hi team.
i need to get response from elastic that data is written and then return success, but now endpoint returns success when data is sent for recording. how to do that?

  method: 'POST',
  path: '/api/newinv',
  async handler(req, h) {
	const payload = req.payload;

	await callWithRequest(req, 'bulk', {
		index: 'myindex',
		body: [
			{ "index" : { "_index" : "myindex", "_type" : "doc" }},
	  .then(response => {
		console.log({ error: null, id: response._id, result: response.result });
	  .catch(error => {
		console.log({ error: error });
	return "SUCCESS";

I think you'd want to use the refresh parameter:

So, probably you want either refresh=true or refresh=wait_for. Both have their drawbacks, and I'd say it really depends on how much writing you're doing as to whether or not you want to do this.

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