This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /api/python/query.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Query

Entry point for querying document content. A Query holds a built, in-memory search index over a document (or a file / folder / prebuilt index) and answers ranked text-search questions against it — the “index once, query many” model. Build one with the static CreateIndex / CreateIndex factories, then call TextSearch on the returned instance as often as you like. The ranking itself lives in the engine-independent NativeSDK.Search assembly; this licensed, bridge-exposed facade applies the entitlement gate and delegates.

from nutrient_sdk import Query

Construction

Query cannot be instantiated directly. Obtain instances through static factory methods or via other SDK classes.

Class Methods

create_index

@classmethod
def create_index(cls, document: Document) -> Query
@classmethod
def create_index(cls, input: str, settings: DocumentSettings) -> Query

Build a Query over any document, regardless of its source format. The document is converted to layout-preserving plain text in memory with the SDK’s TextExporter (page-boundary markers forced on, then restored) and tokenized + ranked once. Then call TextSearch on the returned Query as many times as you like — each query skips this conversion and build. The Query captures the document’s settings and is independent of it, so the document may be closed once the Query is built. Hits are reported by their original document page plus an approximate within-page line.

Parameters:

NameTypeDescription
document (optional)DocumentAn open document of any supported input format. Its DocumentSettings (the SearchSettings group plus Markdown settings) drives the conversion and later queries — configure it on the document (e.g. via Document.Open(path, settings)).
input (optional)strPath to a UTF-8 text/Markdown (.md/.txt) file, a directory of them, or a prebuilt index file.
settings (optional)DocumentSettingsDocument settings; its SearchSettings group (algorithm, language, emit-index) drives the build and is captured for the Query’s later searches.

Returns: Query


Methods

def text_search(self, query: str) -> str

Ranked BM-25 search over this Query’s built index — the “index once, query many” path. No document conversion or index rebuild happens here; only the query runs. Each hit is reported by its original document page (for a document-built index) or line range (for plain text). The per-query knobs (top-k, context, mode, display) come from the settings captured when the Query was built. Returns an empty string when nothing clears the relevance floor.

Parameters:

NameTypeDescription
querystrNatural-language query; matched case-insensitively.

Returns: str