All Products
Search
Document Center

AnalyticDB:QueryCollectionData

Last Updated:Nov 05, 2025
This topic is generated by a machine translation engine without any human intervention. ALIBABA CLOUD DOES NOT GUARANTEE THE ACCURACY OF MACHINE TRANSLATED CONTENT. To request a human-translated version of this topic or provide feedback on this translation, please include it in the feedback form.

Query Vector Data

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • For mandatory resource types, indicate with a prefix of * .
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
gpdb:QueryCollectionDatacreate
*Collection
acs:gpdb:{#regionId}:{#accountId}:collection/{#DBInstanceId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
DBInstanceIdstringNo

Instance ID.

Note You can call the DescribeDBInstances API to view details of all AnalyticDB PostgreSQL instances in the target region, including the instance ID.
gp-xxxxxxxxx
CollectionstringYes

Collection name.

Note You can use the ListCollections API to view the list.
document
NamespacestringNo

Namespace.

Note You can use the ListNamespaces API to view the list.
mynamespace
NamespacePasswordstringYes

Password for the namespace.

testpassword
ContentstringNo

Content for full-text search. When this value is empty, only vector search is used; when it is not empty, both vector and full-text search are used.

Note The Vector parameter cannot be empty at the same time.
hello_world
FilterstringNo

Filter conditions for the data to be queried, in SQL WHERE format. It is an expression that returns a boolean value (true or false). Conditions can be simple comparison operators such as equal (=), not equal (<> or !=), greater than (>), less than (<), greater than or equal to (>=), less than or equal to (<=), or more complex expressions combined with logical operators (AND, OR, NOT), as well as conditions using keywords like IN, BETWEEN, and LIKE.

Note
  • For detailed syntax, refer to: https://www.postgresqltutorial.com/postgresql-tutorial/postgresql-where/
  • response > 200
    TopKlongYes

    Set the number of top results to return.

    10
    VectorarrayNo

    Vector data, with the same dimension as specified in the CreateCollection API.

    Note When the vector is empty, only full-text search results are returned.
    doubleNo

    Vector data.

    1.234
    RegionIdstringYes

    Region ID where the instance is located.

    cn-hangzhou
    MetricsstringNo

    Similarity algorithm used during retrieval. Value descriptions:

    • l2: Euclidean distance.
    • ip: Inner product (dot product) distance.
    • cosine: Cosine similarity.
    Note If this value is empty, the algorithm specified during index creation is used.
    cosine
    IncludeValuesbooleanNo

    Whether to return vector data. Value descriptions:

    • true: Return vector data.
    • false: Do not return vector data, used for full-text search scenarios.
    true
    HybridSearchstringNo

    Dual-path recall algorithm, default is empty (i.e., directly compare and sort the scores of vectors and full-text).

    Available values:

    • RRF: Reciprocal rank fusion, with a parameter k controlling the fusion effect. See HybridSearchArgs configuration for details;
    • Weight: Weighted sorting, using a parameter alpha to control the score ratio of vectors and full-text, then sorting. See HybridSearchArgs configuration for details;
    • Cascaded: Perform full-text search first, then vector search based on the full-text results;
    RRF
    HybridSearchArgsobjectNo

    The parameters of the two-way retrieval algorithm. The following parameters are supported:

    • When HybridSearch is set to RRF, the scores are calculated by using the 1/(k+rank_i) formula. The constant k is a positive integer that is greater than 1.
    { 
       "RRF": {
        "k": 60
       }
    }
    
    • When HybridSearch is set to Weight, the scores are calculated by using the alpha * vector_score + (1-alpha) * text_score formula. The alpha parameter specifies the proportion of the vector search score and the full-text search score and ranges from 0 to 1. A value of 0 specifies full-text search and a value of 1 specifies vector search.
    { 
       "Weight": {
        "alpha": 0.5
       }
    }
    
    objectNo

    The two-way retrieval parameters.

    anyNo

    The parameter values.

    { "Weight": { "alpha": 0.5 } }
    OrderBystringNo

    Defaults to empty, indicating the field for sorting. Does not support hybrid search scenarios.

    The field must belong to metadata or be a default field in the table, such as id. The supported formats are:

    • A single field, e.g., chunk_id;
    • Multiple fields, separated by commas, e.g., block_id, chunk_id;
    • Supports reverse order, e.g., block_id DESC, chunk_id DESC;
    chunk_id
    OffsetintegerNo

    Defaults to empty, indicating the starting point for pagination queries. Does not support hybrid search scenarios.

    The value must be >= 0. When this value is not empty, it will return Total, which indicates the total number of hits. This parameter works with TopK. For example, to paginate 20 and retrieve chunks with chunk_id from 0 to 44, you need to make three requests:

    • Offset=0, TopK=20 returns chunk_id 0~19
    • Offset=20, TopK=20 returns chunk_id 20~39
    • Offset=30, TopK=20 returns chunk_id 40~44
    0
    IncludeMetadataFieldsstringNo

    Defaults to empty, indicating the metadata fields to return. Multiple fields should be separated by commas.

    title,content
    WorkspaceIdstringNo

    The ID of the Workspace composed of multiple database instances. This parameter and DBInstanceId cannot both be empty. If both are specified, this parameter takes precedence.

    gp-ws-*****
    RelationalTableFilterobjectNo

    Uses another relational table to filter vector data (similar to a Join function).

    Note Data from the relational table can be returned by setting the IncludeMetadataFields parameter. For example, rds_table_name.id indicates returning the id field from the relational table.
    CollectionMetadataFieldstringNo

    The Metadata field of the vector collection, used to associate with the fields in the vector table.

    doc_id
    TableFieldstringNo

    The field in the relational table, used to associate with the Metadata field of the vector collection.

    id
    TableNamestringNo

    The name of the relational table.

    my_rds_table
    ConditionstringNo

    The filtering condition for the relational table.

    tags @> ARRAY['art']

    Response parameters

    ParameterTypeDescriptionExample
    object

    Recall results.

    Matchesarray<object>

    Data list.

    matchobject

    Single record.

    Idstring

    The unique ID of the vector data.

    doca-1234
    Metadataobject

    Metadata.

    string

    Metadata content.

    {"title":"test title", "content": "test content"}
    Valuesarray

    List of vector data.

    valuedouble

    Vector data.

    1.234
    Scoredouble

    The similarity score of this data, which is related to the algorithm (l2/ip/cosine) specified when creating the index.

    0.12345
    RequestIdstring

    Request ID.

    ABB39CC3-4488-4857-905D-2E4A051D0521
    Statusstring

    Status, with the following values:

    • success: Success.
    • fail: Failure.
    success
    Messagestring

    Detailed information when the request fails.

    0.1234
    Totalinteger

    Only returned when the Offset is not 0, this value represents the total number of hits for the search criteria.

    100

    Examples

    Sample success responses

    JSONformat

    {
      "Matches": {
        "match": [
          {
            "Id": "doca-1234",
            "Metadata": {
              "key": {
                "title": "test title",
                "content": "test content"
              }
            },
            "Values": {
              "value": [
                1.234
              ]
            },
            "Score": 0.12345
          }
        ]
      },
      "RequestId": "ABB39CC3-4488-4857-905D-2E4A051D0521",
      "Status": "success",
      "Message": 0.1234,
      "Total": 100
    }

    Error codes

    For a list of error codes, visit the Service error codes.

    Change history

    Change timeSummary of changesOperation
    2024-08-28The request parameters of the API has changedView Change Details
    2024-08-04The request parameters of the API has changedView Change Details
    2024-04-29The request parameters of the API has changed. The response structure of the API has changedView Change Details
    2024-04-22The request parameters of the API has changedView Change Details
    2023-11-07The internal configuration of the API is changed, but the call is not affectedView Change Details
    2023-08-17The request parameters of the API has changedView Change Details
    2023-08-08The response structure of the API has changedView Change Details
    2023-08-01The response structure of the API has changedView Change Details
    2023-08-01The internal configuration of the API is changed, but the call is not affectedView Change Details