Skip to main content
Search for text patterns and return matching nodes with character positions and matched text. Designed for agent workflows that need to identify exactly which nodes to tag or link to data attributes.

Usage

kdx document locate <file.kddb> --pattern <regex> [flags]

Flags

FlagDescriptionDefault
--patternRegex pattern to search for (required)
--typeComma-separated node types to match (e.g., word,line)All types
--page NFilter to page number (1-based)All pages
--max NMaximum number of results0 (unlimited)
--prettyPretty-print JSON outputfalse

Output Fields

FieldDescription
nodeIdNode ID for use with tag command
typeNode type (word, line, etc.)
contentFull node content
pagePage number (1-based)
matchStartCharacter offset where match begins
matchEndCharacter offset where match ends
matchTextThe actual matched text
bboxBounding box coordinates (if available)

Examples

Locate Words Matching a Pattern

kdx document locate invoice.kddb --pattern "\\$[\\d,]+\\.\\d{2}" --type word --max 5
{"nodeId":245,"type":"word","content":"$1,234.56","page":1,"matchStart":0,"matchEnd":9,"matchText":"$1,234.56"}
{"nodeId":302,"type":"word","content":"$500.00","page":1,"matchStart":0,"matchEnd":7,"matchText":"$500.00"}

Locate on a Specific Page

kdx document locate report.kddb --pattern "revenue" --page 5 --pretty
{
  "nodeId": 1042,
  "type": "line",
  "content": "Total revenue for fiscal year 2024",
  "page": 5,
  "matchStart": 6,
  "matchEnd": 13,
  "matchText": "revenue",
  "bbox": {"x1": 72.0, "y1": 340.2, "x2": 540.0, "y2": 352.8}
}

Agent Workflow: Locate then Tag

# Step 1: Find nodes containing amounts
kdx document locate invoice.kddb --pattern "\\$[\\d,]+" --type word

# Step 2: Tag a found node
kdx document tag invoice.kddb --node-id 245 --name "invoice/amount"
Use locate instead of grep when you need the nodeId for subsequent tag or data set-attribute operations. The matchText field confirms exactly what was matched.
Filter by --type word for precise single-token matches, or --type line for broader context.