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 Risposta
0
Risposta accettata

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
ESPERTO
con risposta un anno fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande