Skip to content

Latest commit

 

History

History
104 lines (65 loc) · 6.59 KB

README.md

File metadata and controls

104 lines (65 loc) · 6.59 KB

Cognitive Search Question Answering Solution Accelerator

An integrated search solution leveraging Azure Cognitive Search and QnA Maker to provide instant answers to common questions.

Screenshot of sample web app

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

Cognitive Search QnA Maker Solution Architecture

Live demo

You can view a live demo of this repo at the following link:

https://ambitious-tree-00baa321e.azurestaticapps.net

Prerequisites

Getting started

1. Deploy Resources

The services and components needed for the solution are packaged in the repo's ARM template. The following resources will be deployed:

  1. Azure Cognitive Search
  2. QnA Maker Cognitive Service (this will always be deployed to the West US region, but your data is not stored here - see here)
  3. Azure App Service, App Service Plan
  4. Azure App Service, Website
  5. Storage Account
  6. Azure Function App
  7. Cognitive Services All-in-one resource

Click the Deploy to Azure button to get started.

Deploy to Azure

The deployment may take several minutes. Once the deployment finishes, navigate over to the Outputs tab:

Deployment screenshot

Copy the value of the HTTP Trigger. You'll use this value in the next step.

URL to copy

2. Initialize the solution

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.

Initalize solution accelerator

3. Upload documents

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.

4. Set up the UI

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:

Screenshot of sample web app

Data

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.

To-do

  1. Have the function app use the included hosting plan instead of needing to deploy a second one.
    1. 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.
    2. 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.
    3. 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.
    4. Also make sure the function is set to AlwaysOn so that the custom skill works correctly, per the linked documentation.
  2. Add cognitive services enrichment skills to skillset/indexer output field mappings/index.
  3. Fix potential race condition in index status update code.
  4. Make the knowledge base id task a bit simpler.
    1. 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.
  5. Better documentation

Resources