SearchKnowledgeBase

Updated at:
Copy as MD

Searches a knowledge base.

Operation description

Searches a specified knowledge base by using a text query or an image. For the version parameter, use the display name DRAFT, LATEST_PUBLISHED, or vN. Pass tag filter conditions based on the actual operators used by the backend.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request syntax

POST /api/v1/knowledge-bases/{knowledgeBaseId}/search HTTP/1.1

Path Parameters

Parameter

Type

Required

Description

Example

knowledgeBaseId

string

No

The knowledge base ID.

kd-620ad908ec651

Request parameters

Parameter

Type

Required

Description

Example

body

object

No

The search request.

query

string

No

The search query.

What is the tax amount on the invoice?

version

string

No

The knowledge base version.

v1

documentIds

array

No

The list of document IDs.

string

No

The document ID.

539ddb688fe811f182f637422a0713b5

image

object

No

The image search input.

url

string

No

The image URL.

https://example.com/invoice.png

base64

string

No

The Base64-encoded image.

data:image/png;base64,iVBORw0KGgoAAA...

objectKey

string

No

The object key of the image.

uploaded/invoice.png

pageNumber

integer

No

The page number.

1

pageSize

integer

No

The number of items per page.

5

retrievalConfig

object

No

The retrieval configuration.

candidateCount

integer

No

The number of candidates to recall.

5

minScore

number

No

The minimum relevance score.

0.2

semanticWeight

number

No

The weight for semantic relevance.

0.5

enableQueryExpansion

boolean

No

Specifies whether to enable query expansion.

true

translationLanguages

array

No

The list of translation languages.

string

No

The language.

English

enableEvidenceCompletion

boolean

No

Specifies whether to enable multi-hop evidence completion. Default value: false. For pilot knowledge bases, this feature can be used on the first page of DRAFT text retrieval. The pageSize can be 5, 10, or 20, which requires a minimum candidateCount of 40, 48, or 64, respectively. When enabled, results are returned by document.

true

tagFilter

object

No

The tag filter.

relation

string

No

The condition relation.

or

conditions

array<object>

No

The list of tag conditions.

object

No

The tag condition.

field

string

No

The tag field.

category

op

string

No

The operator.

in

value

any

No

The tag value.

invoice

rerankModelId

integer

No

The rerank model ID.

123

enableKnowledgeGraph

boolean

No

Specifies whether to enable the knowledge graph.

false

rerankModelName

string

No

The name of the rerank model activated for the tenant. If both rerankModelId and this parameter are specified, this parameter takes precedence.

qwen3-rerank

includeWiki

boolean

No

Specifies whether to use Wiki evidence. This parameter is optional and conditionally returned, and is added for backward compatibility. Default value: false. If set to true, a unified evidenceResults field is additionally returned without disguising Wiki content as original text. Constraint: {"default":false}.

true

evidencePageToken

string

No

The evidence page token. This parameter is optional and conditionally returned. It can only be passed when includeWiki is set to true. Omit this parameter for the first evidence page, and pass the evidenceNextToken from the previous page as is for subsequent pages. The candidate pool, subject, parameters, and page size are fixed, and the token expires in 5 minutes without renewal. An expired token returns a 409 error and does not trigger an automatic re-search. The pageNumber parameter only controls the legacy results. Constraint: {"minLength":1,"maxLength":4096}.

example-opaque-next-token

Response elements

Element

Type

Description

Example

object

The search results.

requestId

string

The request ID.

019FCC42-90DE-56D3-A10D-3C06995DED17

pageNumber

integer

The page number.

1

pageSize

integer

The number of items per page.

5

totalCount

integer

The total count.

2

queryLabels

array

The query labels.

string

The query labels.

invoice

results

array<object>

The list of search results.

array<object>

The search result.

chunkId

string

The chunk ID.

7f0de3e041322a1d

knowledgeBaseId

string

The knowledge base ID.

kd-xxxxxxxxxx

documentId

string

The document ID.

539ddb688fe811f182f637422a0713b5

documentName

string

The document name.

invoice.pdf

content

string

The chunk content.

Tax amount 1.59

contentType

string

The content type.

table

score

number

The overall relevance score.

0.26136884

scoreDetails

object

The relevance details.

semanticScore

number

The semantic relevance score.

0.5227377

keywordScore

number

The keyword relevance score.

0.0000000014285714

parentChunkId

string

The parent chunk ID.

parent-chunk-id

tags

array

The list of tags.

string

The tag.

invoice

locations

array<object>

The list of document locations.

object

The document location.

pageNumber

integer

The page number.

1

left

integer

The left boundary.

13

right

integer

The right boundary.

566

top

integer

The top boundary.

12

bottom

integer

The bottom boundary.

364

images

array<object>

The list of associated images.

object

The associated image.

imageId

string

The image ID.

kd-620ad908ec651-41253795bafd7a1c

url

string

The temporary access URL.

https://example.com/signed-image

scalarFields

any

The scalar fields of the structured knowledge base. These fields are returned by their original column names and are not used for retrieval.

{"question":"How do I reset it?","category":"account"}

mediaStartMs

integer

The start time of the audio or video chunk in the original media, in milliseconds. This field is not returned for non-media chunks.

1250

mediaEndMs

integer

The end time of the audio or video chunk in the original media, in milliseconds. This field is not returned for non-media chunks.

8400

mediaTimeline

array<object>

The time ranges of sentence-by-sentence or paragraph-by-paragraph content within the chunk in the original media. This field is not returned for non-audio chunks.

object

The media timeline segment.

text

string

The segment text.

The first sentence

startMs

integer

The start time of the segment.

1250

endMs

integer

The end time of the segment.

4200

code

integer

The returned status code.

0

message

string

The returned message.

success

accessDeniedDetail

string

The details of the access denial.

{"PolicyType":"AccountLevelIdentityBasedPolicy","NoPermissionType":"ImplicitDeny","AuthAction":"milvusknowledgebase:SearchKnowledgeBase"}

success

boolean

Indicates whether the request is successful.

true

httpStatusCode

integer

The HTTP status code.

0

evidenceNextToken

string

Optional or conditionally returned. Required when includeWiki is set to true. The cursor for the next page of evidence, which is null for the last page. Not used for legacy results pagination. Null is allowed and can be omitted. Constraints: {"minLength":1,"maxLength":4096}.

example-opaque-next-token

evidenceResults

array<object>

Optional or conditionally returned. Returned only when includeWiki is set to true. The current page of unified and merged results. Constraints: {"minItems":0,"maxItems":100}.

[{"evidenceId":"wiki_section_page_1_sec_1_rev_7","kind":"wiki_section","knowledgeBaseId":"example_kb","documentId":null,"chunkId":null,"pageId":"page_1","sectionId":"sec_1","entityId":null,"relationId":null,"revisionId":"rev_7","batchId":"batch_7","title":"Warranty instructions","content":"The warranty period for Product A is 18 months.","score":0.62,"sourceRefs":[{"documentId":"doc_manual","chunkId":"chunk_1","sourceRevisionId":"source_rev_7","version":"DRAFT"}],"sourceRefCount":1,"sourceRefsTruncated":false,"sourceTaskId":"11111111111111111111111111111111"}]

array<object>

Required and always returned. A structured object. Conditional requirements and cross-field rules are validated by the backend. Refer to the operation description and full contract for details.

{"evidenceId":"wiki_section_page_1_sec_1_rev_7","kind":"wiki_section","knowledgeBaseId":"example_kb","documentId":null,"chunkId":null,"pageId":"page_1","sectionId":"sec_1","entityId":null,"relationId":null,"revisionId":"rev_7","batchId":"batch_7","title":"Warranty instructions","content":"The warranty period for Product A is 18 months.","score":0.62,"sourceRefs":[{"documentId":"doc_manual","chunkId":"chunk_1","sourceRevisionId":"source_rev_7","version":"DRAFT"}],"sourceRefCount":1,"sourceRefsTruncated":false,"sourceTaskId":"11111111111111111111111111111111"}

evidenceId

string

Required and always returned. An opaque business ID generated by the server. Ownership is validated, and arbitrary paths are not accepted. Constraints: {"minLength":1,"maxLength":128,"pattern":"^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$"}.

wiki_section_page_1_sec_1_rev_7

kind

string

Required and always returned. The actual evidence object type. Constraints: {"enum":["raw","wiki_page","wiki_section","graph_fact"],"maxLength":64}.

Valid values:

  • raw
  • wiki_page
  • wiki_section
  • graph_fact

wiki_section

knowledgeBaseId

string

Required and always returned. An opaque business ID generated by the server. Ownership is validated, and arbitrary paths are not accepted. Constraints: {"minLength":1,"maxLength":128,"pattern":"^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$"}.

example_kb

documentId

string

Required and always returned. Null is allowed. The semantics of null values follow the field description. Null is allowed and can be omitted. Constraints: {"minLength":1,"maxLength":128,"pattern":"^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$"}.

null

chunkId

string

Required and always returned. Null is allowed. The semantics of null values follow the field description. Null is allowed and can be omitted. Constraints: {"minLength":1,"maxLength":128,"pattern":"^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$"}.

null

pageId

string

Required and always returned. Null is allowed. The semantics of null values follow the field description. Null is allowed and can be omitted. Constraints: {"minLength":1,"maxLength":128,"pattern":"^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$"}.

page_1

sectionId

string

Required and always returned. Null is allowed. The semantics of null values follow the field description. Null is allowed and can be omitted. Constraints: {"minLength":1,"maxLength":128,"pattern":"^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$"}.

sec_1

entityId

string

Required and always returned. Null is allowed. The semantics of null values follow the field description. Null is allowed and can be omitted. Constraints: {"minLength":1,"maxLength":128,"pattern":"^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$"}.

null

relationId

string

Required and always returned. Null is allowed. The semantics of null values follow the field description. Null is allowed and can be omitted. Constraints: {"minLength":1,"maxLength":128,"pattern":"^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$"}.

null

revisionId

string

Required and always returned. An opaque business ID generated by the server. Ownership is validated, and arbitrary paths are not accepted. Constraints: {"minLength":1,"maxLength":128,"pattern":"^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$"}.

example_value

batchId

string

Required and always returned. Null is allowed. The semantics of null values follow the field description. Null is allowed and can be omitted. Constraints: {"minLength":1,"maxLength":128,"pattern":"^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$"}.

null

title

string

Required and always returned. The display title after authorization. Constraints: {"maxLength":1024}.

Warranty instructions

content

string

Required and always returned. The readable evidence text. Constraints: {"maxLength":65535}.

The warranty period for Product A is 18 months

score

number

Required and always returned. A finite numerical value used for unified ranking. For hybrid, it is the relevance of the existing Dealer.rerank. For rerank, it is the text and model hybrid relevance of the existing Dealer.rerank_by_model, along semanticWeight and rank features, and is not a relevance probability. minScore is applied according to the existing unified scoring rules. Can be null for non-ranked factual evidence. Null is allowed and can be omitted.

0.62

sourceRefs

array<object>

Required and always returned. The actually supported sources. Constraints: {"minItems":1,"maxItems":1000}.

[{"documentId":"doc_manual","chunkId":"chunk_1","sourceRevisionId":"source_rev_7","version":"DRAFT","contentHash":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}]

object

Required and always returned. A structured object.

{"documentId":"example_value","chunkId":"example_value","sourceRevisionId":"example_value","version":"DRAFT","contentHash":"0000000000000000000000000000000000000000000000000000000000000000"}

documentId

string

Required and always returned. An opaque business ID generated by the server. Ownership is validated, and arbitrary paths are not accepted. Constraints: {"minLength":1,"maxLength":128,"pattern":"^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$"}.

example_value

chunkId

string

Required and always returned. An opaque business ID generated by the server. Ownership is validated, and arbitrary paths are not accepted. Constraints: {"minLength":1,"maxLength":128,"pattern":"^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$"}.

example_value

sourceRevisionId

string

Required and always returned. An opaque business ID generated by the server. Ownership is validated, and arbitrary paths are not accepted. Constraints: {"minLength":1,"maxLength":128,"pattern":"^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$"}.

example_value

version

string

Required and always returned. The display name of the version. Does not fall back to draft if invalid or unavailable. Constraints: {"maxLength":64,"pattern":"^(DRAFT|LATEST_PUBLISHED|v[1-9][0-9]*)$","default":"DRAFT"}.

DRAFT

documentName

string

Optional or conditionally returned. The document name that can be returned only after authorization. Constraints: {"maxLength":1024}.

example_value

pageNumber

integer

Optional or conditionally returned. Null is allowed. The semantics of null values follow the field description. Null is allowed and can be omitted. Constraints: {"minimum":1,"maximum":9223372036854775807}.

1

mediaStartMs

integer

Optional or conditionally returned. Null is allowed. The semantics of null values follow the field description. Null is allowed and can be omitted. Constraints: {"minimum":0,"maximum":9223372036854775807}.

0

mediaEndMs

integer

Optional or conditionally returned. Null is allowed. The semantics of null values follow the field description. Null is allowed and can be omitted. Constraints: {"minimum":0,"maximum":9223372036854775807}.

0

sourceRefCount

integer

Required and always returned. The total number of source chunk references. Authentication is performed on the full set. Constraints: {"minimum":1,"maximum":9223372036854775807}.

1

sourceRefsTruncated

boolean

Required and always returned. True when a single sourceRefs contains only the first 1,000 items. You can paginate and verify by using sourceTaskId.

false

sourceTaskId

string

Required and always returned. The entry for complete sources. Must be a non-null locator when sourceRefsTruncated is true. Source operation references held by artifacts or revisions remain readable, and archiving task details does not delete the source manifest. Null is allowed and can be omitted. Constraints: {"minLength":32,"maxLength":32,"pattern":"^[0-9a-f]{32}$"}.

null

Examples

Success response

JSON format

{
  "requestId": "019FCC42-90DE-56D3-A10D-3C06995DED17",
  "pageNumber": 1,
  "pageSize": 5,
  "totalCount": 2,
  "queryLabels": [
    "invoice"
  ],
  "results": [
    {
      "chunkId": "7f0de3e041322a1d",
      "knowledgeBaseId": "kd-xxxxxxxxxx",
      "documentId": "539ddb688fe811f182f637422a0713b5",
      "documentName": "invoice.pdf",
      "content": "Tax amount 1.59",
      "contentType": "table",
      "score": 0.26136884,
      "scoreDetails": {
        "semanticScore": 0.5227377,
        "keywordScore": 1.4285714e-9
      },
      "parentChunkId": "parent-chunk-id",
      "tags": [
        "invoice"
      ],
      "locations": [
        {
          "pageNumber": 1,
          "left": 13,
          "right": 566,
          "top": 12,
          "bottom": 364
        }
      ],
      "images": [
        {
          "imageId": "kd-620ad908ec651-41253795bafd7a1c",
          "url": "https://example.com/signed-image"
        }
      ],
      "scalarFields": "{\"question\":\"How do I reset it?\",\"category\":\"account\"}",
      "mediaStartMs": 1250,
      "mediaEndMs": 8400,
      "mediaTimeline": [
        {
          "text": "The first sentence",
          "startMs": 1250,
          "endMs": 4200
        }
      ]
    }
  ],
  "code": 0,
  "message": "success",
  "accessDeniedDetail": "{\"PolicyType\":\"AccountLevelIdentityBasedPolicy\",\"NoPermissionType\":\"ImplicitDeny\",\"AuthAction\":\"milvusknowledgebase:SearchKnowledgeBase\"}",
  "success": true,
  "httpStatusCode": 0,
  "evidenceNextToken": "example-opaque-next-token",
  "evidenceResults": [
    {
      "evidenceId": "wiki_section_page_1_sec_1_rev_7",
      "kind": "wiki_section",
      "knowledgeBaseId": "example_kb",
      "documentId": "null",
      "chunkId": "null",
      "pageId": "page_1",
      "sectionId": "sec_1",
      "entityId": "null",
      "relationId": "null",
      "revisionId": "example_value",
      "batchId": "null",
      "title": "Warranty instructions",
      "content": "The warranty period for Product A is 18 months",
      "score": 0.62,
      "sourceRefs": [
        {
          "documentId": "example_value",
          "chunkId": "example_value",
          "sourceRevisionId": "example_value",
          "version": "DRAFT",
          "documentName": "example_value",
          "pageNumber": 1,
          "mediaStartMs": 0,
          "mediaEndMs": 0
        }
      ],
      "sourceRefCount": 1,
      "sourceRefsTruncated": false,
      "sourceTaskId": "null"
    }
  ]
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.