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
전문가
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인