expose service with elasticsearch rest api with different request body
Application Type
Service
Platform Version
11.12.0 (Build 30456)

Hi, I'm trying to create a service which consumes Elasticsearch API.

Documents can be indexed using Elasticsearch API. The content-type of the request body needs to be in JSON.

How can I define and expose the service so that multiple modules can use the service and define the different structures they want to index the documents as?

e.g.

Service exposes the action AddDocumentToIndex which is a REST endpoint to Elasticsearch.

Module A has document structure {"name": "", "description": ""}

Module B has document structure { "address": { "addressLine1": "", "addressLine2": "", "postalCode": "" } }

How can the action cater for differing structures in the request body to send to the REST endpoint?

You can set Data Type of request to  Text instead of Structure.
In Modules A / Module B, serialize you document to JSON and then call action,


Regard
Wei

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.