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 個回答
0
已接受的答案

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
專家
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南