SearchRelevantContentCommand

Searches for relevant content in a Amazon Q Business application based on a query. This operation takes a search query text, the Amazon Q Business application identifier, and optional filters (such as content source and maximum results) as input. It returns a list of relevant content items, where each item includes the content text, the unique document identifier, the document title, the document URI, any relevant document attributes, and score attributes indicating the confidence level of the relevance.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { QBusinessClient, SearchRelevantContentCommand } from "@aws-sdk/client-qbusiness"; // ES Modules import
// const { QBusinessClient, SearchRelevantContentCommand } = require("@aws-sdk/client-qbusiness"); // CommonJS import
const client = new QBusinessClient(config);
const input = { // SearchRelevantContentRequest
  applicationId: "STRING_VALUE", // required
  queryText: "STRING_VALUE", // required
  contentSource: { // ContentSource Union: only one key present
    retriever: { // RetrieverContentSource
      retrieverId: "STRING_VALUE", // required
    },
  },
  attributeFilter: { // AttributeFilter
    andAllFilters: [ // AttributeFilters
      {
        andAllFilters: [
          "<AttributeFilter>",
        ],
        orAllFilters: [
          "<AttributeFilter>",
        ],
        notFilter: "<AttributeFilter>",
        equalsTo: { // DocumentAttribute
          name: "STRING_VALUE", // required
          value: { // DocumentAttributeValue Union: only one key present
            stringValue: "STRING_VALUE",
            stringListValue: [ // DocumentAttributeStringListValue
              "STRING_VALUE",
            ],
            longValue: Number("long"),
            dateValue: new Date("TIMESTAMP"),
          },
        },
        containsAll: {
          name: "STRING_VALUE", // required
          value: {//  Union: only one key present
            stringValue: "STRING_VALUE",
            stringListValue: [
              "STRING_VALUE",
            ],
            longValue: Number("long"),
            dateValue: new Date("TIMESTAMP"),
          },
        },
        containsAny: {
          name: "STRING_VALUE", // required
          value: {//  Union: only one key present
            stringValue: "STRING_VALUE",
            stringListValue: [
              "STRING_VALUE",
            ],
            longValue: Number("long"),
            dateValue: new Date("TIMESTAMP"),
          },
        },
        greaterThan: {
          name: "STRING_VALUE", // required
          value: {//  Union: only one key present
            stringValue: "STRING_VALUE",
            stringListValue: [
              "STRING_VALUE",
            ],
            longValue: Number("long"),
            dateValue: new Date("TIMESTAMP"),
          },
        },
        greaterThanOrEquals: {
          name: "STRING_VALUE", // required
          value: {//  Union: only one key present
            stringValue: "STRING_VALUE",
            stringListValue: [
              "STRING_VALUE",
            ],
            longValue: Number("long"),
            dateValue: new Date("TIMESTAMP"),
          },
        },
        lessThan: "<DocumentAttribute>",
        lessThanOrEquals: "<DocumentAttribute>",
      },
    ],
    orAllFilters: [
      "<AttributeFilter>",
    ],
    notFilter: "<AttributeFilter>",
    equalsTo: "<DocumentAttribute>",
    containsAll: "<DocumentAttribute>",
    containsAny: "<DocumentAttribute>",
    greaterThan: "<DocumentAttribute>",
    greaterThanOrEquals: "<DocumentAttribute>",
    lessThan: "<DocumentAttribute>",
    lessThanOrEquals: "<DocumentAttribute>",
  },
  maxResults: Number("int"),
  nextToken: "STRING_VALUE",
};
const command = new SearchRelevantContentCommand(input);
const response = await client.send(command);
// { // SearchRelevantContentResponse
//   relevantContent: [ // RelevantContentList
//     { // RelevantContent
//       content: "STRING_VALUE",
//       documentId: "STRING_VALUE",
//       documentTitle: "STRING_VALUE",
//       documentUri: "STRING_VALUE",
//       documentAttributes: [ // DocumentAttributes
//         { // DocumentAttribute
//           name: "STRING_VALUE", // required
//           value: { // DocumentAttributeValue Union: only one key present
//             stringValue: "STRING_VALUE",
//             stringListValue: [ // DocumentAttributeStringListValue
//               "STRING_VALUE",
//             ],
//             longValue: Number("long"),
//             dateValue: new Date("TIMESTAMP"),
//           },
//         },
//       ],
//       scoreAttributes: { // ScoreAttributes
//         scoreConfidence: "VERY_HIGH" || "HIGH" || "MEDIUM" || "LOW" || "NOT_AVAILABLE",
//       },
//     },
//   ],
//   nextToken: "STRING_VALUE",
// };

SearchRelevantContentCommand Input

Parameter
Type
Description
applicationId
Required
string | undefined

The unique identifier of the Amazon Q Business application to search.

contentSource
Required
ContentSource | undefined

The source of content to search in.

queryText
Required
string | undefined

The text to search for.

attributeFilter
AttributeFilter | undefined

Enables filtering of responses based on document attributes or metadata fields.

maxResults
number | undefined

The maximum number of results to return.

nextToken
string | undefined

The token for the next set of results. (You received this token from a previous call.)

SearchRelevantContentCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
nextToken
string | undefined

The token to use to retrieve the next set of results, if there are any.

relevantContent
RelevantContent[] | undefined

The list of relevant content items found.

Throws

Name
Fault
Details
AccessDeniedException
client

You don't have access to perform this action. Make sure you have the required permission policies and user accounts and try again.

InternalServerException
server

An issue occurred with the internal server used for your Amazon Q Business service. Wait some minutes and try again, or contact Support  for help.

LicenseNotFoundException
client

You don't have permissions to perform the action because your license is inactive. Ask your admin to activate your license and try again after your licence is active.

ResourceNotFoundException
client

The application or plugin resource you want to use doesn’t exist. Make sure you have provided the correct resource and try again.

ThrottlingException
client

The request was denied due to throttling. Reduce the number of requests and try again.

ValidationException
client

The input doesn't meet the constraints set by the Amazon Q Business service. Provide the correct input and try again.

QBusinessServiceException
Base exception class for all service exceptions from QBusiness service.