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年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン