Skip to main content

Search passages of documents.

POST/api/v1/passages/searchdocuments:search

The clustering app's fragment search, passages only: the topic clustering and the paid LLM answer the Portal queues after every search are not run (create_passage_clustering and create_passage_answer ask for them). mode meaning finds the chunks nearest the query's meaning (needs the organisation's document embeddings), best first, each with its start_offset and end_offset in the document's text and its distance (smaller is nearer); mode exact finds the document texts holding the query's words (words, "exact phrase", OR, -exclude), best score first, each with its score. filter is a tree of and, or, not and {field, op, value} leaves over the document fields the clustering app's filter builder offers (document_number, document_date, document_type, project, description, image_type, main_document_number, created_by, from_organisation, folder, tag) and custom_field.<custom_field_id> for a register column, ops eq, ne, in, gt, gte, lt, lte, contains, starts_with, ends_with; a passage whose document has no value for the field is not matched by ne or not. include adds text and page (meaning) or highlights (exact: HTML with the matched words in <span class="keyword">). Only passages of documents the caller can read are found. Needs View Document Text, and Search Semantic for mode meaning or Search Full Text for mode exact; include text needs View Search Fragments and include highlights View Search Highlights. Page through the results with cursor.

Scopedocuments:search
AsynchronousNo
MCP toolsearch_passages
Portal permissionsview_document_text
Pagingsnapshot
Default order-relevance
Sort fieldsrelevance

Parameters​

NameInTypeRequiredDescription
limitqueryintegerOptionalDefault: 50; ≥ 1
cursorquerystringOptional
sortquerystringOptionalComma-separated sort fields, - for descending.
Docwize-Versionheaderstring (date)Optional

Request body​

Content typeType
application/jsonPassageSearchInput

Responses​

StatusDescriptionBody
200Success.application/json object
400invalid_version, malformed_jsonapplication/problem+json Problem
401token_expired, unauthenticatedapplication/problem+json Problem
403forbidden, insufficient_scope, token_owner_inactiveapplication/problem+json Problem
405method_not_allowedapplication/problem+json Problem
406not_acceptableapplication/problem+json Problem
410cursor_expiredapplication/problem+json Problem
413payload_too_largeapplication/problem+json Problem
415unsupported_media_typeapplication/problem+json Problem
421wrong_regionapplication/problem+json Problem
422invalid_cursor, validation_failedapplication/problem+json Problem
500internal_errorapplication/problem+json Problem
503tenant_unavailable, unavailableapplication/problem+json Problem
504timeoutapplication/problem+json Problem

200 body​

FieldTypeRequiredDescription
itemsarray of PassageRequired
next_cursorstring or nullRequired
warningsarray of objectRequired

Errors​

The problem codes this operation can answer with. Each code links to its page.

Schemas​

Passage​

FieldTypeRequiredDescription
distancenumber or nullRequiredHow far the chunk's meaning is from the query's: smaller is nearer. Set by a meaning search.
document_idstringRequired
end_offsetinteger or nullRequiredWhere the chunk ends in the document's text; null for an exact search, and in get_passage and list_passages.
highlightsarray of PassageHighlightRequiredSnippets with the matched words marked; read with include highlights.
pageinteger or nullRequiredThe page of the document the chunk starts on (0 when the document has no pages); read with include text, get_passage and list_passages.
passage_idstring or nullRequiredNames the chunk for get_passage and list_passages; null for an exact search, which finds whole document texts.
scorenumber or nullRequiredHow well the text matches the query's words: larger is better. Set by an exact search.
start_offsetinteger or nullRequiredWhere the chunk starts in the document's text; null for an exact search, and in get_passage and list_passages.
textstring or nullRequiredThe chunk's text; read with include text, get_passage and list_passages.

PassageHighlight​

FieldTypeRequiredDescription
htmlstringRequiredThe snippet, with the matched words in <span class="keyword">.

PassageSearchInput​

FieldTypeRequiredDescription
filterobject or nullOptionalA tree of and, or, not and {field, op, value} leaves: the fields document_number, document_date, document_type, project, description, image_type, main_document_number, created_by, from_organisation, folder and tag, or custom_field.<custom_field_id> for a register column; ops eq, ne, in, gt, gte, lt, lte, contains, starts_with, ends_with.
includearray of stringOptionalWhat to read for each passage: text (the chunk's text and page; meaning mode) or highlights (snippets with the matched words marked; exact mode). Neither when left out.
modestringRequiredmeaning (the chunks nearest the query's meaning) or exact (the document texts holding the query's words).
querystringRequiredWhat to look for: a sentence for meaning, words for exact (words, "exact phrase", OR, -exclude).