I want to log my data in my react app from my Amazon OpenSearch Service

0

In Amazon OpenSearch Service i have a service running, if i go to the dashboard and click on discover, i have an index with data that i can search trough. Now i want the data displayed in my react app and also searchable. I tried many things but it does not work to connect to my opensearch service and get the data. How do i fix this?

1 Respuesta
0
Respuesta aceptada

In order show data from a Amazon OpenSearch Service, your React web application needs consume APIs that allow you to search for content. This API should retrieve data from the OpenSearch Service via SDK and return the data to the client React app. Not knowing your specific details from above questions, in general you should:

  1. Create an API. You can either leverage API Gateway or Appsync to build integrations with OpenSearch. See these two links as reference (API Gateway: https://docs.aws.amazon.com/opensearch-service/latest/developerguide/search-example.html AppSync: https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-elasticsearch-resolvers.html. Authentication/Authorization will depend on your requirements.
  2. Depending on your choice, you may need to create a Lambda function to retrieve data from either OpenSearch API AWS SDK for your preferred language, or connect GraphQL Resolver with an OpenSearch Data resolver. Make sure that AWS consuming services have enough permissions via IAM roles to access OpenSearch domain.
  3. Consume this API from React. This is language specific. For NodeJs you can for instance use fetch (https://reactjs.org/docs/faq-ajax.html), core https (https://nodejs.org/api/https.html) or external libraries (axios: https://axios-http.com/docs/intro)

Hope this gives you a few hints to be able to leverage OpenSearch search capabilities into your React client.

profile picture
EXPERTO
respondido hace un año

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas