An integrated search solution leveraging Azure Cognitive Search and QnA Maker to provide instant answers to common questions.
This solution accelerator leverages the power of Azure Cognitive Search together with QnA Maker to find answers to your questions in a similar way to how Bing and Google suggest relevant answers to queries.
Ordinarily, Azure Cognitive Search returns the most relevant documents for your search query but together with QnA Maker integration, it can not only find the most relevant documents but also pull questions and answers out of the document and suggest the most relevant answers.
Please note that not all documents support the question/answer format required by QnA Maker. By default, the logic in the Search service indexer also ingests only the following file types: .pdf,.docx,.doc,.xlsx,.xls,.html,.rtf,.txt,.tsv
. You can change this by modifying the indexedFileNameExtensions
property in the Indexer.json.
This solution accelerator contains the following artifacts:
- ARM template to set up the solution
- Custom skill in Cognitive Search, which ingests the data into QnA Maker
- User interface to view the results
You can view a live demo of this repo at the following link:
https://ambitious-tree-00baa321e.azurestaticapps.net
- A GitHub account
- Node.js and Git
- Visual Studio Code installed
- Postman for making API calls
The services and components needed for the solution are packaged in the repo's ARM template. The following resources will be deployed:
- Azure Cognitive Search
- QnA Maker Cognitive Service (this will always be deployed to the West US region, but your data is not stored here - see here)
- Azure App Service, App Service Plan
- Azure App Service, Website
- Storage Account
- Azure Function App
- Cognitive Services All-in-one resource
Click the Deploy to Azure button to get started.
The deployment may take several minutes. Once the deployment finishes, navigate over to the Outputs tab:
Copy the value of the HTTP Trigger. You'll use this value in the next step.
Open up a new browser tab and paste the URL into the browser. This will run for about a minute and then you'll see a message indicating success or failure.
Navigate to the storage account in the resource group you just created. Find the container named qna-container
and upload your documents into the container.
NOTE: if you would prefer to pull data from a different, pre-existing blob storage account, you may instead change the data source in your Search service to point to a container in a different blob storage account. Just change the connection string and container name in the data source in the Search service.
After uploading your data to qna-container
or changing your data source, you will need to reset and then re-run your indexer in the Search service to ingest your new data.
With the search index created, you're ready to spin up the UI to start searching! The UI is a React based Azure Static Web App available in the SearchUI
folder.
Navigate to SearchUI/README.md for full details on how to create, edit, and use the web app.
Within a few minutes, you'll have a UI with a search experience that looks like this:
The data we used to test with can be found here if you want to reuse it. Some of these files consistently fail upload to QnAMaker for reasons unknown to me. Make sure if we end up using this for the final demo that we reference the author and verify the licensing as appropriate.
- Have the function app use the included hosting plan instead of needing to deploy a second one.
- I am unsure based on the parameters that QnA uses for the hosting plan for their required web app if we can also tack on the function, so that will need to be investigated/tested.
- You will likely also want to use the same hosting plan for the frontend website to be included with the sample so ideally it would host all 3 resources when it is all said and done.
- If we do this, then we can in theory support an unlimited timeout for the queue trigger. That would need to be tweaked in the host.json file.
- Also make sure the function is set to AlwaysOn so that the custom skill works correctly, per the linked documentation.
- Add cognitive services enrichment skills to skillset/indexer output field mappings/index.
- Fix potential race condition in index status update code.
- Make the knowledge base id task a bit simpler.
- My idea for this is that instead of requiring it be set on the function app settings, pass it as a header to the custom skill. That way the customer just needs to paste it into the Postman collection (or otherwise the frontend once that exists) and it can be passed along to the custom skill/queue trigger execution that way.
- Better documentation