This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /api/csharp/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.

using Nutrient;

The SDK creates this class through factory methods or other SDK objects.

Methods

CreateIndex

public static Query CreateIndex(Document document)

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
documentDocumentAn 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)).

Returns: Query

public static Query CreateIndex(string input, DocumentSettings settings)

Build a Query from a file path — a text/Markdown (.md/.txt) file, a directory of them (searched as one attributed corpus), or a prebuilt index. Any other file is rejected (open other formats as a Document and use CreateIndex). Then call TextSearch on the returned Query. A prebuilt index built from a document keeps its page provenance; plain text reports line ranges.

Parameters

NameTypeDescription
inputstringPath to a UTF-8 text/Markdown (.md/.txt) file, a directory of them, or a prebuilt index file.
settingsDocumentSettingsDocument settings; its SearchSettings group (algorithm, language, emit-index) drives the build and is captured for the Query’s later searches.

Returns: Query

TextSearch

public string TextSearch(string query)

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
querystringNatural-language query; matched case-insensitively.

Returns: string

Resource management

public void Dispose()

Query implements IDisposable and owns native resources. Always call Dispose() or use a C# using declaration: it is not released automatically.