GenAI with Stock Trading Website (Module 1)

Hui Yee Leong
4 min readJul 10, 2024

--

Module 1: Create Kendra

In this module, we will set up Amazon Kendra to index and retrieve stock trading data. Amazon Kendra is a highly accurate and easy-to-use enterprise search service powered by machine learning, which allows you to index large volumes of data and retrieve relevant information quickly.

Step 1: Set Up AWS Kendra

1.1 Introduction to Amazon Kendra

Amazon Kendra is designed to provide highly accurate search results by using machine learning algorithms. It can index data from multiple sources and provide quick and relevant search results, making it an excellent tool for stock trading websites where users need to access up-to-date and detailed information.

Please setup in US-EAST-1

1.2 Create a Kendra Index

To create a Kendra index, follow these steps:

a. Open the Amazon Kendra Console: In the search bar, type “Kendra” and select Amazon Kendra from the list of services.

b. Create an Index:

  • Click on “Create index.”
  • Enter a name for your index (e.g., “asx-web-crawl-demo”).
  • Configure user access by selecting an IAM role that has the necessary permissions.
  • Leave user access control as default
  • Choose developer edition
  • Click “Create.”

1.3 Add Data Sources

After creating the index, the next step is to add data sources. Data sources can include documents, databases, and other repositories containing stock trading information. In this example I am going to use ASX website.

URL for this solution Home (asx.com.au)

a. Add a Data Source:

  • In the Amazon Kendra console, select your newly created index.
  • Click on “Data sources” in the left-hand menu.
  • Click “Add data source.”

b. Configure Data Source:

  • Select the type of data source you want to add (e.g., S3, RDS, SharePoint). For this solution I am using Web Crawler 2.0.
  • Provide data source name
  • Enter the necessary details to connect to the data source. In the source URLs section, I added ASX website URL https://asx.com.au/
  • Provide an IAM role that Kendra can use to access the data source. Please select the role that was created previously.
  • Leave any additional settings, such as synchronization schedule and data source inclusion/exclusion patterns as default.
  • Let’s keep the frequency set to “Run on Demand” for now.

1.4 Configure Index

To ensure your Kendra index provides accurate search results, you need to configure the fields and indexing options. But for this example, I will use default option.

For example, we can add custom fields that represent the metadata of your documents (e.g., “StockSymbol,” “Date,” “Price”). This step is optional and is only required for ensuring accurate data.

  • Now, once created, we can navigate to the data source we created. Select ‘Sync Now’ to initiate the web crawling process for the webpage.
  • The synchronization process will take approximately 1 hour.

1.5 Testing Kendra

Before moving on, it’s essential to test your Kendra index to ensure its indexing and retrieving data correctly.

a. Test Search Queries:

  • In the Kendra console, select your index and click on “Search index content.”
  • Enter sample queries relevant to stock trading (e.g., “ANZ Stock Price”).
  • Verify that the search results are accurate and relevant.

b. Debugging

  • If the search results are not as expected, review your index configuration, data sources, and synonym settings. Alternatively, you can check the sync history by selecting the button in the details section, which will navigate to CloudWatch.
  • We can run the query button to view the logs.

Summary

This module walks you through setting up Amazon Kendra, from creating an index to adding data sources, configuring fields, and testing the setup. In the next module, we will enable Bedrock to further enhance our search capabilities.

Next Module: GenAI with Stock Trading Website (Module 2)

--

--