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 QueryConstruction
Query cannot be instantiated directly. Obtain instances through static factory methods or via other SDK classes.
Class Methods
create_index
@classmethoddef create_index(cls, document: Document) -> Query@classmethoddef create_index(cls, input: str, settings: DocumentSettings) -> QueryBuild 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:
| Name | Type | Description |
|---|---|---|
document (optional) | Document | An 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) | str | Path to a UTF-8 text/Markdown (.md/.txt) file, a directory of them, or a prebuilt index file. |
settings (optional) | DocumentSettings | Document settings; its SearchSettings group (algorithm, language, emit-index) drives the build and is captured for the Query’s later searches. |
Returns: Query
Methods
text_search
def text_search(self, query: str) -> strRanked 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:
| Name | Type | Description |
|---|---|---|
query | str | Natural-language query; matched case-insensitively. |
Returns: str