Microsoft Cognitive Language Service - Question Answering (stable:2023-04-01)

2025/04/28 • 2 updated methods

QuestionAnswering_GetAnswers (updated)
Description Answers the specified question using your knowledge base.
Reference Link ¶

⚶ Changes

{
  "#id": "QuestionAnswering_GetAnswers",
  "$parameters": [
    {
      "#name": "api-version",
      "Description": {
        "new": "The API version to use for this operation.",
        "old": "Client API version."
      }
    },
    {
      "knowledgeBaseQueryOptions": {
        "$properties": [
          {
            "#name": "qnaId",
            "Description": {
              "new": "Exact QnA ID to fetch from the knowledge base, this field takes priority over\nquestion.",
              "old": "Exact QnA ID to fetch from the knowledge base, this field takes priority over question."
            }
          },
          {
            "#name": "rankerType",
            "Enum": {
              "new": [
                [
                  "QuestionOnly",
                  "Question only ranker."
                ],
                [
                  "Default",
                  "Default ranker."
                ]
              ],
              "old": [
                [
                  "Default",
                  "Default ranker."
                ],
                [
                  "QuestionOnly",
                  "Question only ranker."
                ]
              ]
            }
          },
          {
            "filters": [
              {
                "metadataFilter": [
                  {
                    "#name": "logicalOperation",
                    "Enum": {
                      "new": [
                        [
                          "AND",
                          "'AND' for using corresponding logical operation."
                        ],
                        [
                          "OR",
                          "Set 'OR' for using corresponding logical operation."
                        ]
                      ],
                      "old": [
                        [
                          "AND",
                          ""
                        ],
                        [
                          "OR",
                          ""
                        ]
                      ]
                    }
                  }
                ]
              },
              {
                "#name": "sourceFilter",
                "Description": {
                  "new": "Find QnAs that are associated with any of the given list of sources in\nknowledge base.",
                  "old": "Find QnAs that are associated with any of the given list of sources in knowledge base."
                },
                "Type": {
                  "new": "array",
                  "old": "object"
                }
              },
              {
                "#name": "logicalOperation",
                "Enum": {
                  "new": [
                    [
                      "AND",
                      "'AND' for using corresponding logical operation."
                    ],
                    [
                      "OR",
                      "Set 'OR' for using corresponding logical operation."
                    ]
                  ],
                  "old": [
                    [
                      "AND",
                      ""
                    ],
                    [
                      "OR",
                      ""
                    ]
                  ]
                }
              }
            ]
          },
          {
            "answerSpanRequest": [
              {
                "#name": "confidenceScoreThreshold",
                "Description": {
                  "new": "Minimum threshold score required to include an answer span, value ranges from 0\nto 1.",
                  "old": "Minimum threshold score required to include an answer span, value ranges from 0 to 1."
                }
              }
            ]
          }
        ]
      }
    }
  ],
  "$responses": {
    "200": {
      "$properties": {
        "answers": {
          "$properties": [
            {
              "#name": "metadata",
              "Description": {
                "new": "Metadata associated with the answer, useful to categorize or filter question\nanswers.",
                "old": "Metadata associated with the answer, useful to categorize or filter question answers."
              }
            },
            {
              "dialog": [
                {
                  "#name": "isContextOnly",
                  "Description": {
                    "new": "To mark if a prompt is relevant only with a previous question or not. If true,\ndo not include this QnA as search result for queries without context;\notherwise, if false, ignores context and includes this QnA in search result.",
                    "old": "To mark if a prompt is relevant only with a previous question or not. If true, do not include this QnA as search result for queries without context; otherwise, if false, ignores context and includes this QnA in search result."
                  }
                }
              ]
            }
          ]
        }
      }
    },
    "default": {
      "$properties": {
        "error": [
          {
            "#name": "code",
            "Enum": {
              "new": [
                [
                  "InvalidRequest",
                  "Invalid request error"
                ],
                [
                  "InvalidArgument",
                  "Invalid argument error"
                ],
                [
                  "Unauthorized",
                  "Unauthorized access error"
                ],
                [
                  "Forbidden",
                  "Forbidden access error"
                ],
                [
                  "NotFound",
                  "Not found error"
                ],
                [
                  "ProjectNotFound",
                  "Project not found error"
                ],
                [
                  "OperationNotFound",
                  "Operation not found error"
                ],
                [
                  "AzureCognitiveSearchNotFound",
                  "Azure Cognitive Search not found error"
                ],
                [
                  "AzureCognitiveSearchIndexNotFound",
                  "Azure Cognitive Search index not found error"
                ],
                [
                  "TooManyRequests",
                  "Too many requests error"
                ],
                [
                  "AzureCognitiveSearchThrottling",
                  "Azure Cognitive Search throttling error"
                ],
                [
                  "AzureCognitiveSearchIndexLimitReached",
                  "Azure Cognitive Search index limit reached error"
                ],
                [
                  "InternalServerError",
                  "Internal server error"
                ],
                [
                  "ServiceUnavailable",
                  "Service unavailable error"
                ],
                [
                  "Timeout",
                  "Timeout error"
                ],
                [
                  "QuotaExceeded",
                  "Quota exceeded error"
                ],
                [
                  "Conflict",
                  "Conflict error"
                ],
                [
                  "Warning",
                  "Warning error"
                ]
              ],
              "old": [
                [
                  "InvalidRequest",
                  ""
                ],
                [
                  "InvalidArgument",
                  ""
                ],
                [
                  "Unauthorized",
                  ""
                ],
                [
                  "Forbidden",
                  ""
                ],
                [
                  "NotFound",
                  ""
                ],
                [
                  "ProjectNotFound",
                  ""
                ],
                [
                  "OperationNotFound",
                  ""
                ],
                [
                  "AzureCognitiveSearchNotFound",
                  ""
                ],
                [
                  "AzureCognitiveSearchIndexNotFound",
                  ""
                ],
                [
                  "TooManyRequests",
                  ""
                ],
                [
                  "AzureCognitiveSearchThrottling",
                  ""
                ],
                [
                  "AzureCognitiveSearchIndexLimitReached",
                  ""
                ],
                [
                  "InternalServerError",
                  ""
                ],
                [
                  "ServiceUnavailable",
                  ""
                ],
                [
                  "Timeout",
                  ""
                ],
                [
                  "QuotaExceeded",
                  ""
                ],
                [
                  "Conflict",
                  ""
                ],
                [
                  "Warning",
                  ""
                ]
              ]
            }
          },
          {
            "innererror": [
              {
                "#name": "code",
                "Enum": {
                  "new": [
                    [
                      "InvalidRequest",
                      "Invalid request error"
                    ],
                    [
                      "InvalidParameterValue",
                      "Invalid parameter value error"
                    ],
                    [
                      "KnowledgeBaseNotFound",
                      "Knowledge base not found error"
                    ],
                    [
                      "AzureCognitiveSearchNotFound",
                      "Azure Cognitive Search not found error"
                    ],
                    [
                      "AzureCognitiveSearchThrottling",
                      "Azure Cognitive Search throttling error"
                    ],
                    [
                      "ExtractionFailure",
                      "Extraction failure error"
                    ],
                    [
                      "InvalidRequestBodyFormat",
                      "Invalid request body format error"
                    ],
                    [
                      "EmptyRequest",
                      "Empty request error"
                    ],
                    [
                      "MissingInputDocuments",
                      "Missing input documents error"
                    ],
                    [
                      "InvalidDocument",
                      "Invalid document error"
                    ],
                    [
                      "ModelVersionIncorrect",
                      "Model version incorrect error"
                    ],
                    [
                      "InvalidDocumentBatch",
                      "Invalid document batch error"
                    ],
                    [
                      "UnsupportedLanguageCode",
                      "Unsupported language code error"
                    ],
                    [
                      "InvalidCountryHint",
                      "Invalid country hint error"
                    ]
                  ],
                  "old": [
                    [
                      "InvalidRequest",
                      ""
                    ],
                    [
                      "InvalidParameterValue",
                      ""
                    ],
                    [
                      "KnowledgeBaseNotFound",
                      ""
                    ],
                    [
                      "AzureCognitiveSearchNotFound",
                      ""
                    ],
                    [
                      "AzureCognitiveSearchThrottling",
                      ""
                    ],
                    [
                      "ExtractionFailure",
                      ""
                    ],
                    [
                      "InvalidRequestBodyFormat",
                      ""
                    ],
                    [
                      "EmptyRequest",
                      ""
                    ],
                    [
                      "MissingInputDocuments",
                      ""
                    ],
                    [
                      "InvalidDocument",
                      ""
                    ],
                    [
                      "ModelVersionIncorrect",
                      ""
                    ],
                    [
                      "InvalidDocumentBatch",
                      ""
                    ],
                    [
                      "UnsupportedLanguageCode",
                      ""
                    ],
                    [
                      "InvalidCountryHint",
                      ""
                    ]
                  ]
                }
              }
            ]
          }
        ]
      }
    }
  }
}

⚼ Request

POST:  /:query-knowledgebases
{
api-version: string ,
projectName: string ,
deploymentName: string ,
knowledgeBaseQueryOptions:
{
qnaId: integer ,
question: string ,
top: integer ,
userId: string ,
confidenceScoreThreshold: number ,
context:
{
previousQnaId: integer ,
previousUserQuery: string ,
}
,
rankerType: enum ,
filters:
{
metadataFilter:
{
metadata:
[
{
key: string ,
value: string ,
}
,
]
,
logicalOperation: enum ,
}
,
sourceFilter:
[
string ,
]
,
logicalOperation: enum ,
}
,
answerSpanRequest:
{
enable: boolean ,
confidenceScoreThreshold: number ,
topAnswersWithSpan: integer ,
}
,
includeUnstructuredSources: boolean ,
}
,
}

⚐ Response (200)

{
answers:
[
{
questions:
[
string ,
]
,
answer: string ,
confidenceScore: number ,
id: integer ,
source: string ,
metadata: object ,
dialog:
{
isContextOnly: boolean ,
prompts:
[
{
displayOrder: integer ,
qnaId: integer ,
displayText: string ,
}
,
]
,
}
,
answerSpan:
{
text: string ,
confidenceScore: number ,
offset: integer ,
length: integer ,
}
,
}
,
]
,
}

⚐ Response (default)

{
$headers:
{
x-ms-error-code: string ,
}
,
$schema:
{
error:
{
code: enum ,
message: string ,
target: string ,
details:
[
string ,
]
,
innererror:
{
code: enum ,
message: string ,
details: object ,
target: string ,
innererror: string ,
}
,
}
,
}
,
}
QuestionAnswering_GetAnswersFromText (updated)
Description Answers the specified question using the provided text in the body.
Reference Link ¶

⚶ Changes

{
  "#id": "QuestionAnswering_GetAnswersFromText",
  "$parameters": [
    {
      "#name": "api-version",
      "Description": {
        "new": "The API version to use for this operation.",
        "old": "Client API version."
      }
    },
    {
      "textQueryOptions": {
        "$properties": [
          {
            "#name": "language",
            "Description": {
              "new": "Language of the text records. This is BCP-47 representation of a language. For\nexample, use \"en\" for English; \"es\" for Spanish etc. If not set, use \"en\" for\nEnglish as default.",
              "old": "Language of the text records. This is BCP-47 representation of a language. For example, use \"en\" for English; \"es\" for Spanish etc. If not set, use \"en\" for English as default."
            }
          },
          {
            "#name": "stringIndexType",
            "Description": {
              "new": "Specifies the method used to interpret string offsets.  Defaults to Text\nElements (Graphemes) according to Unicode v8.0.0. For additional information\nsee https://aka.ms/text-analytics-offsets.",
              "old": "Specifies the method used to interpret string offsets.  Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets."
            },
            "Enum": {
              "new": [
                [
                  "TextElements_v8",
                  "Returned offset and length values will correspond to TextElements (Graphemes\nand Grapheme clusters) confirming to the Unicode 8.0.0 standard. Use this\noption if your application is written in .Net Framework or .Net Core and you\nwill be using StringInfo."
                ],
                [
                  "UnicodeCodePoint",
                  "Returned offset and length values will correspond to Unicode code points. Use\nthis option if your application is written in a language that support Unicode,\nfor example Python."
                ],
                [
                  "Utf16CodeUnit",
                  "Returned offset and length values will correspond to UTF-16 code units. Use\nthis option if your application is written in a language that support Unicode,\nfor example Java, JavaScript."
                ]
              ],
              "old": [
                [
                  "TextElements_v8",
                  "Returned offset and length values will correspond to TextElements (Graphemes and Grapheme clusters) confirming to the Unicode 8.0.0 standard. Use this option if your application is written in .Net Framework or .Net Core and you will be using StringInfo."
                ],
                [
                  "UnicodeCodePoint",
                  "Returned offset and length values will correspond to Unicode code points. Use this option if your application is written in a language that support Unicode, for example Python."
                ],
                [
                  "Utf16CodeUnit",
                  "Returned offset and length values will correspond to UTF-16 code units. Use this option if your application is written in a language that support Unicode, for example Java, JavaScript."
                ]
              ]
            }
          }
        ]
      }
    }
  ],
  "$responses": {
    "default": {
      "$properties": {
        "error": [
          {
            "#name": "code",
            "Enum": {
              "new": [
                [
                  "InvalidRequest",
                  "Invalid request error"
                ],
                [
                  "InvalidArgument",
                  "Invalid argument error"
                ],
                [
                  "Unauthorized",
                  "Unauthorized access error"
                ],
                [
                  "Forbidden",
                  "Forbidden access error"
                ],
                [
                  "NotFound",
                  "Not found error"
                ],
                [
                  "ProjectNotFound",
                  "Project not found error"
                ],
                [
                  "OperationNotFound",
                  "Operation not found error"
                ],
                [
                  "AzureCognitiveSearchNotFound",
                  "Azure Cognitive Search not found error"
                ],
                [
                  "AzureCognitiveSearchIndexNotFound",
                  "Azure Cognitive Search index not found error"
                ],
                [
                  "TooManyRequests",
                  "Too many requests error"
                ],
                [
                  "AzureCognitiveSearchThrottling",
                  "Azure Cognitive Search throttling error"
                ],
                [
                  "AzureCognitiveSearchIndexLimitReached",
                  "Azure Cognitive Search index limit reached error"
                ],
                [
                  "InternalServerError",
                  "Internal server error"
                ],
                [
                  "ServiceUnavailable",
                  "Service unavailable error"
                ],
                [
                  "Timeout",
                  "Timeout error"
                ],
                [
                  "QuotaExceeded",
                  "Quota exceeded error"
                ],
                [
                  "Conflict",
                  "Conflict error"
                ],
                [
                  "Warning",
                  "Warning error"
                ]
              ],
              "old": [
                [
                  "InvalidRequest",
                  ""
                ],
                [
                  "InvalidArgument",
                  ""
                ],
                [
                  "Unauthorized",
                  ""
                ],
                [
                  "Forbidden",
                  ""
                ],
                [
                  "NotFound",
                  ""
                ],
                [
                  "ProjectNotFound",
                  ""
                ],
                [
                  "OperationNotFound",
                  ""
                ],
                [
                  "AzureCognitiveSearchNotFound",
                  ""
                ],
                [
                  "AzureCognitiveSearchIndexNotFound",
                  ""
                ],
                [
                  "TooManyRequests",
                  ""
                ],
                [
                  "AzureCognitiveSearchThrottling",
                  ""
                ],
                [
                  "AzureCognitiveSearchIndexLimitReached",
                  ""
                ],
                [
                  "InternalServerError",
                  ""
                ],
                [
                  "ServiceUnavailable",
                  ""
                ],
                [
                  "Timeout",
                  ""
                ],
                [
                  "QuotaExceeded",
                  ""
                ],
                [
                  "Conflict",
                  ""
                ],
                [
                  "Warning",
                  ""
                ]
              ]
            }
          },
          {
            "innererror": [
              {
                "#name": "code",
                "Enum": {
                  "new": [
                    [
                      "InvalidRequest",
                      "Invalid request error"
                    ],
                    [
                      "InvalidParameterValue",
                      "Invalid parameter value error"
                    ],
                    [
                      "KnowledgeBaseNotFound",
                      "Knowledge base not found error"
                    ],
                    [
                      "AzureCognitiveSearchNotFound",
                      "Azure Cognitive Search not found error"
                    ],
                    [
                      "AzureCognitiveSearchThrottling",
                      "Azure Cognitive Search throttling error"
                    ],
                    [
                      "ExtractionFailure",
                      "Extraction failure error"
                    ],
                    [
                      "InvalidRequestBodyFormat",
                      "Invalid request body format error"
                    ],
                    [
                      "EmptyRequest",
                      "Empty request error"
                    ],
                    [
                      "MissingInputDocuments",
                      "Missing input documents error"
                    ],
                    [
                      "InvalidDocument",
                      "Invalid document error"
                    ],
                    [
                      "ModelVersionIncorrect",
                      "Model version incorrect error"
                    ],
                    [
                      "InvalidDocumentBatch",
                      "Invalid document batch error"
                    ],
                    [
                      "UnsupportedLanguageCode",
                      "Unsupported language code error"
                    ],
                    [
                      "InvalidCountryHint",
                      "Invalid country hint error"
                    ]
                  ],
                  "old": [
                    [
                      "InvalidRequest",
                      ""
                    ],
                    [
                      "InvalidParameterValue",
                      ""
                    ],
                    [
                      "KnowledgeBaseNotFound",
                      ""
                    ],
                    [
                      "AzureCognitiveSearchNotFound",
                      ""
                    ],
                    [
                      "AzureCognitiveSearchThrottling",
                      ""
                    ],
                    [
                      "ExtractionFailure",
                      ""
                    ],
                    [
                      "InvalidRequestBodyFormat",
                      ""
                    ],
                    [
                      "EmptyRequest",
                      ""
                    ],
                    [
                      "MissingInputDocuments",
                      ""
                    ],
                    [
                      "InvalidDocument",
                      ""
                    ],
                    [
                      "ModelVersionIncorrect",
                      ""
                    ],
                    [
                      "InvalidDocumentBatch",
                      ""
                    ],
                    [
                      "UnsupportedLanguageCode",
                      ""
                    ],
                    [
                      "InvalidCountryHint",
                      ""
                    ]
                  ]
                }
              }
            ]
          }
        ]
      }
    }
  }
}

⚼ Request

POST:  /:query-text
{
api-version: string ,
textQueryOptions:
{
question: string ,
records:
[
{
id: string ,
text: string ,
}
,
]
,
language: string ,
stringIndexType: enum ,
}
,
}

⚐ Response (200)

{
answers:
[
{
answer: string ,
confidenceScore: number ,
id: string ,
answerSpan:
{
text: string ,
confidenceScore: number ,
offset: integer ,
length: integer ,
}
,
offset: integer ,
length: integer ,
}
,
]
,
}

⚐ Response (default)

{
$headers:
{
x-ms-error-code: string ,
}
,
$schema:
{
error:
{
code: enum ,
message: string ,
target: string ,
details:
[
string ,
]
,
innererror:
{
code: enum ,
message: string ,
details: object ,
target: string ,
innererror: string ,
}
,
}
,
}
,
}