LM-Kit OneDocs2026.8.10lm-kit.com
Document Utilities

PDF Search

Searches text within a PDF document.#

POST/lmkit/v1/pdf-search

Performs layout-aware text search within a PDF document. Returns matching text spans with context snippets, relevance scores, page numbers, and bounding box coordinates. Supports exact text, regular expression, and fuzzy (Damerau-Levenshtein edit distance) matching. Text normalization options allow whitespace collapsing, diacritics removal, and punctuation/symbol stripping. Unlike the semantic search endpoints (which operate on pre-indexed collections), this performs direct, real-time search within a specific uploaded document. This is a pure document processing operation that does not require an AI model. If processing exceeds the configured timeout, returns 202 Accepted with a job_id. Poll GET /lmkit/v1/jobs/ for status and results.

Request body

application/json ·

PropertyTypeDescription
inputrequiredstring

The input PDF document to search. When input_format is 'Base64EncodedFile', provide a base64-encoded PDF payload. When 'FileIdentifier', provide the file ID previously returned by the lmkit/v1/files/upload endpoint.

input_format

How the input is provided. Accepted values: 'Base64EncodedFile' or 'FileIdentifier'. 'Base64EncodedFile' expects a base64-encoded PDF file. 'FileIdentifier' references a file previously uploaded via lmkit/v1/files/upload. Defaults to 'Base64EncodedFile'.

queryrequiredstring

The search text or pattern. For 'Text' mode, an exact substring. For 'Regex' mode, a .NET regular expression pattern. For 'Fuzzy' mode, the approximate text to locate.

search_mode

The type of search to perform. 'Text': exact substring matching. 'Regex': regular expression matching. 'Fuzzy': approximate matching using Damerau-Levenshtein edit distance. Defaults to 'Text'.

case_sensitiveboolean

Whether the text search should be case-sensitive. Only applies to 'Text' mode. Defaults to false.

whole_wordboolean

When true, only matches bounded by non-word characters on both sides are returned. Only applies to 'Text' mode. Defaults to false.

regex_ignore_caseboolean

When true, the regex pattern ignores case. Only applies to 'Regex' mode. Defaults to true.

max_edit_distanceobject (int32)

Maximum Damerau-Levenshtein edit distance for fuzzy matching. Clamped to [1, 10]. Only applies to 'Fuzzy' mode. Defaults to 2.

min_scoreobject (double)

Minimum normalized fuzzy score in the range [0..1]. Only applies to 'Fuzzy' mode. Defaults to 0.75.

token_awareboolean

When true, discounts whitespace substitution costs in fuzzy matching. Only applies to 'Fuzzy' mode. Defaults to true.

normalize_whitespaceboolean

When true, collapses whitespace in document text before searching. Defaults to true.

ignore_diacriticsboolean

When true, removes diacritical marks (accents) before searching. Defaults to true.

ignore_punctuationboolean

When true, strips punctuation characters before searching. Defaults to false.

ignore_symbolsboolean

When true, strips symbol characters before searching. Defaults to false.

max_resultsobject (int32)

Maximum number of matches to return across all pages. Clamped to [1, 5000]. Defaults to 100.

context_charsobject (int32)

Number of characters of surrounding context to include in each match snippet. Clamped to [0, 1000]. Defaults to 40.

page_rangestring

An optional page range to search (e.g. "1-3", "1,3,5", "2-"). When empty or not specified, all pages are searched. Page numbers are 1-based.

Responses

StatusTypeDescription
200

OK

202

Accepted

400

Bad Request

404

Not Found

500application/json

Internal Server Error

curl -X POST "$LMKIT_ONE_URL/lmkit/v1/pdf-search" \
  -H "Authorization: Bearer $LMKIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "input": "",
  "input_format": "Base64EncodedFile",
  "query": "",
  "search_mode": "Text",
  "case_sensitive": false,
  "whole_word": false
}'