<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Matthew Martin</title>
    <description>The latest articles on DEV Community by Matthew Martin (@dreaminhex).</description>
    <link>https://dev.to/dreaminhex</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4236133%2Fbf24baf0-5b6c-4657-a22f-f02a56fec28c.jpg</url>
      <title>DEV Community: Matthew Martin</title>
      <link>https://dev.to/dreaminhex</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dreaminhex"/>
    <language>en</language>
    <item>
      <title>Full-Text and Vector Search for Scanned PDFs with HexDB</title>
      <dc:creator>Matthew Martin</dc:creator>
      <pubDate>Thu, 19 Nov 2026 19:44:48 +0000</pubDate>
      <link>https://dev.to/dreaminhex/full-text-and-vector-search-for-scanned-pdfs-with-hexdb-53lo</link>
      <guid>https://dev.to/dreaminhex/full-text-and-vector-search-for-scanned-pdfs-with-hexdb-53lo</guid>
      <description>&lt;p&gt;I write database software and record music with my band &lt;a href="https://ashesgone.com" rel="noopener noreferrer"&gt;Ashes Gone&lt;/a&gt;, so here's a search problem I'd actually care about. Somewhere in a folder of scanned studio notes is the sheet that says, “Mute the room microphones for the final chorus.” I can remember that decision months later. There's no chance I'm going to remember &lt;code&gt;scan_0042.pdf&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In HexDB 2.5, I can upload that PDF and find it by typing &lt;em&gt;room microphones&lt;/em&gt;. If all I remember is &lt;em&gt;we wanted the drums to sound drier at the end&lt;/em&gt;, I can search for that, too. The first lookup uses optical character recognition (OCR) and a full-text index. The second uses a vector index on the words extracted from the very same file.&lt;/p&gt;

&lt;p&gt;HexDB is an open-source, encrypted document database written in Rust. It stores JSON records and binary files. When I &lt;a href="https://dev.to/dreaminhex/introducing-hexdb-for-documents-and-files-5bi4"&gt;introduced HexDB on DEV&lt;/a&gt;, it could already search text embedded in a PDF. Version 2.5.1 added Tesseract OCR for pages that arrive as images. Here's how to try both kinds of search on the current release, 2.5.9.&lt;/p&gt;

&lt;h2&gt;
  
  
  Give the database a page to read
&lt;/h2&gt;

&lt;p&gt;Use a phone or scanner to make a one-page PDF of a &lt;strong&gt;printed&lt;/strong&gt; note. For this example, put “Mute the room microphones for the final chorus. Keep the close drum mics up.” on the page and save it as &lt;code&gt;scan_0042.pdf&lt;/code&gt;. A PDF where you can't select the words is ideal. If your scanner adds its own text layer, the search still works, but HexDB may read that layer directly.&lt;/p&gt;

&lt;p&gt;Start a local HexDB instance using the &lt;a href="https://github.com/dreaminhex/hexdb/blob/v2.5.9/README.md#with-docker" rel="noopener noreferrer"&gt;Docker quick start&lt;/a&gt;. Use the full image, &lt;code&gt;ghcr.io/dreaminhex/hexdb:2.5.9&lt;/code&gt;, which includes Tesseract and English language data. Sign in as the local administrator at &lt;code&gt;http://localhost:7700/ui/&lt;/code&gt;, create an API key on the Account page, and set &lt;code&gt;HEXDB_TOKEN&lt;/code&gt; to that key in your shell.&lt;/p&gt;

&lt;p&gt;HexDB calls a collection a &lt;em&gt;tessellation&lt;/em&gt;. Creating one with &lt;code&gt;kind: files&lt;/code&gt; gives it a text index that already covers filenames, folders, tags, descriptions, and extracted metadata. Run these commands in Bash with a recent version of curl.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;base&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;http://localhost:7700
&lt;span class="nv"&gt;auth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Authorization: Bearer ${HEXDB_TOKEN:?Set HEXDB_TOKEN to your local API key}"&lt;/span&gt;

curl -fsS -H &lt;span class="s2"&gt;"$auth"&lt;/span&gt; &lt;span class="s2"&gt;"$base/tessellations"&lt;/span&gt; \
  --json &lt;span class="s1"&gt;'{"name":"studio","kind":"files"}'&lt;/span&gt;

curl -fsS -H &lt;span class="s2"&gt;"$auth"&lt;/span&gt; -T scan_0042.pdf \
  &lt;span class="s2"&gt;"$base/studio/_files/sessions/scan_0042.pdf"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The upload creates a file record. A background worker reads the PDF and, for a scan, puts the recognized words in &lt;code&gt;meta.text&lt;/code&gt;. By default, HexDB tries OCR on PDFs with fewer than 200 characters of embedded text and reads up to the first 20 pages. That limit matters if the sentence you're hunting for is on page 21. You can change it with &lt;code&gt;files.ocr_pages&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Find the words and see where they came from
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -fsS -H &lt;span class="s2"&gt;"$auth"&lt;/span&gt; &lt;span class="s2"&gt;"$base/studio/_query"&lt;/span&gt; --json &lt;span class="s1"&gt;'{
  "filter": {"$text": "room microphones"},
  "fields": ["name", "path", "meta.text", "meta.ocr"]
}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once extraction finishes, the result should include &lt;code&gt;scan_0042.pdf&lt;/code&gt;. Both search terms must appear in the indexed content. Returning &lt;code&gt;meta.text&lt;/code&gt; lets you read what HexDB recognized, and &lt;code&gt;meta.ocr&lt;/code&gt; identifies the engine and pages processed when OCR ran. If you query immediately after uploading and get no match, check the file record's &lt;code&gt;extract.status&lt;/code&gt;. It moves from &lt;code&gt;pending&lt;/code&gt; to &lt;code&gt;done&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;At this point you already have a searchable archive. Tesseract runs locally, and this keyword lookup needs no model or embedding provider.&lt;/p&gt;

&lt;h2&gt;
  
  
  Search by meaning within a folder
&lt;/h2&gt;

&lt;p&gt;Now imagine a few months have passed. You remember how you wanted the drums to &lt;em&gt;sound&lt;/em&gt;, but “room microphones” has escaped you. This is where I'd add vector search.&lt;/p&gt;

&lt;p&gt;Configure an &lt;a href="https://github.com/dreaminhex/hexdb/blob/v2.5.9/MANUAL.md#vector-search" rel="noopener noreferrer"&gt;embeddings provider&lt;/a&gt; on the lattice, then create the following index. I've selected only &lt;code&gt;meta.text&lt;/code&gt; as its source. HexDB sends the extracted words to the provider you choose. A local embedding model is an option when the session notes need to stay on your own hardware.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -fsS -H &lt;span class="s2"&gt;"$auth"&lt;/span&gt; &lt;span class="s2"&gt;"$base/tessellations/studio/indexes"&lt;/span&gt; --json &lt;span class="s1"&gt;'{
  "kind": "vector",
  "fields": ["embedding"],
  "source": ["meta.text"]
}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Creating the index queues existing records that need embeddings, including the sheet you already uploaded. For a more interesting test, upload a second sheet about guitar tuning to the same folder. Once both have embeddings, ask for the three closest matches.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -fsS -H &lt;span class="s2"&gt;"$auth"&lt;/span&gt; &lt;span class="s2"&gt;"$base/studio/_query"&lt;/span&gt; --json &lt;span class="s1"&gt;'{
  "filter": {"path": {"$startsWith": "/sessions/"}},
  "near": {
    "field": "embedding",
    "text": "a drier drum sound at the end of the song",
    "k": 3
  },
  "fields": ["name", "path", "meta.text"]
}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each match has a similarity score. Does the drum sheet rank above the guitar sheet, even though the query never mentions microphones? You can inspect the returned text and judge the result yourself. The folder filter narrows the question, and HexDB applies the caller's read permissions and row filters to the query.&lt;/p&gt;

&lt;p&gt;The same search is available to a read-only MCP client. One addition in 2.5 is the &lt;em&gt;Oracle&lt;/em&gt;, an optional HexDB node that handles AI requests. It can wait on a model while a storage node looks up the notes using the requesting musician's permissions. That lets me give AI traffic its own machine without handing an agent an administrator key or copying the studio archive onto that machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  What changed in HexDB 2.5.9?
&lt;/h2&gt;

&lt;p&gt;Once those files are in the database, ordinary database questions are fair game. For example, this SQL query lists the session sheets that Tesseract actually processed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ocr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pages&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;studio&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ocr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;engine&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'tesseract'&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In 2.5.9, SQL reads only the fields a statement uses. Here the engine can leave the extracted text and embedding out of the read. That makes a difference when you want a two-column report over thousands of records carrying pages of text.&lt;/p&gt;

&lt;p&gt;There's also a change for anyone feeding a second system from HexDB. Say a stream plugin maintains a separate catalog and stays offline longer than HexDB retains its change history. In 2.5.9 the plugin pauses in &lt;code&gt;needs_resync&lt;/code&gt;. An administrator can have it send a snapshot of the current documents before it resumes, or explicitly choose to resume from now. A current snapshot can rebuild a catalog. It can't tell you every edit that happened while the plugin was away, which is why I want that decision visible to the operator.&lt;/p&gt;

&lt;p&gt;The test I'd give HexDB is simple. Pick two files from your own domain, rename them both to something useless, and search for a detail you remember. Then try asking in words that never appear on either page. If the wrong file wins, I'd like to hear what you searched for and what you expected to find.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://hexdb.app/" rel="noopener noreferrer"&gt;HexDB website&lt;/a&gt; · &lt;a href="https://github.com/dreaminhex/hexdb/tree/v2.5.9" rel="noopener noreferrer"&gt;Source and quick start&lt;/a&gt; · &lt;a href="https://github.com/dreaminhex/hexdb/blob/v2.5.9/MANUAL.md#16-files" rel="noopener noreferrer"&gt;File storage and search manual&lt;/a&gt; · &lt;a href="https://github.com/dreaminhex/hexdb/releases/tag/v2.5.9" rel="noopener noreferrer"&gt;2.5.9 release notes&lt;/a&gt;&lt;/p&gt;

</description>
      <category>database</category>
      <category>rust</category>
      <category>opensource</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Introducing HexDB for Documents and Files</title>
      <dc:creator>Matthew Martin</dc:creator>
      <pubDate>Tue, 10 Nov 2026 01:54:09 +0000</pubDate>
      <link>https://dev.to/dreaminhex/introducing-hexdb-for-documents-and-files-5bi4</link>
      <guid>https://dev.to/dreaminhex/introducing-hexdb-for-documents-and-files-5bi4</guid>
      <description>&lt;p&gt;An application can have customer records, uploaded documents, full-text search, and semantic search over those documents. Keeping the data, permissions, and updates consistent across those features can become a project of its own.&lt;/p&gt;

&lt;p&gt;I've built HexDB to bring those pieces closer together.&lt;/p&gt;

&lt;p&gt;HexDB is an encrypted, replicated database for JSON documents and binary files, with full-text and vector search. The core server is written in Rust and runs as one binary.&lt;/p&gt;

&lt;p&gt;I'm Matthew "Doc" Martin, a software architect with more than 25 years in software development. HexDB is my independent project, built during late nights and weekends alongside my day job. With versions 2.4.3 and 2.4.4 released, this seems like a good time to introduce it here.&lt;/p&gt;

&lt;h1&gt;
  
  
  Documents and files in one database
&lt;/h1&gt;

&lt;p&gt;HexDB stores JSON documents in collections called tessellations. You can query them through REST, GraphQL, gRPC, or SQL, with drivers for Node.js, Python, .NET, Java through JDBC, and ODBC.&lt;/p&gt;

&lt;p&gt;SQL currently supports reads. Writes go through the APIs and drivers.&lt;/p&gt;

&lt;p&gt;Files are part of the database too. They have queryable metadata, version history, resumable uploads, and access controls. Their content is encrypted, deduplicated, and compressed when that helps.&lt;/p&gt;

&lt;p&gt;Consider an application with customer records and uploaded invoices. You need to find the records, retrieve the files, restrict access, and perhaps search the invoices by their contents. HexDB provides those capabilities within the same database platform.&lt;/p&gt;

&lt;p&gt;It also includes an admin UI for managing documents, files, users, indexes, and the cluster. I want the operational side to be approachable, including when you're the person building the application and keeping it running.&lt;/p&gt;

&lt;h1&gt;
  
  
  Vector search alongside ordinary queries
&lt;/h1&gt;

&lt;p&gt;Vector search is an index type in HexDB. You can supply your own embeddings or configure an embedding provider and have HexDB generate them from selected fields.&lt;/p&gt;

&lt;p&gt;Similarity searches use the same documents, permissions, row filters, and field masks as other queries. You can combine a semantic search with an ordinary filter.&lt;/p&gt;

&lt;p&gt;For example, after configuring an embedding provider and a vector index on an articles collection, this request searches published articles by meaning:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -X POST http://localhost:7700/articles/_query \
  -H &lt;span class="s2"&gt;"Authorization: Bearer YOUR_API_KEY"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{
    "filter": { "status": "published" },
    "near": {
      "field": "embedding",
      "text": "storage engines for edge devices",
      "k": 5
    }
  }'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same approach works with extracted text from uploaded files. A search can find a document by what it discusses, even when its filename isn't useful.&lt;/p&gt;

&lt;p&gt;Automatic embeddings use the provider you configure, including supported local providers. The selected source text goes to that provider. Usage controls include per-user allowances and a monthly token budget.&lt;/p&gt;

&lt;p&gt;Each HexDB server also exposes an MCP endpoint for authenticated, read-only access by external agents. Optional A2A support lets another agent delegate a question to HexDB's own chat system. Those lookups run with the calling user's permissions.&lt;/p&gt;

&lt;h1&gt;
  
  
  Security around both records and uploads
&lt;/h1&gt;

&lt;p&gt;My work in payments influences the questions I ask about data handling: who can read a value, where it gets copied, and what remains after a request finishes.&lt;/p&gt;

&lt;p&gt;HexDB includes encryption at rest, role-based access, row filters, field masking, MFA, and an audit trail. Schema-defined tokenization can replace sensitive field values before the document reaches its write-ahead log, storage, replicas, or backups.&lt;/p&gt;

&lt;p&gt;There are two tokenization modes. One-way tokens support matching without recovering the original value. Vault tokens keep the original in a separate encrypted vault, with explicit permission and auditing for detokenization.&lt;/p&gt;

&lt;p&gt;File uploads also have integrated malware scanning and quarantine. YARA-X is built into supported builds, and HexDB connects to a separately running ClamAV daemon for signature-based scanning. Files flagged by a scanner are quarantined instead of becoming normal downloadable files or being replicated.&lt;/p&gt;

&lt;p&gt;That distinction matters for deployment: the core database is one binary; ClamAV is an additional service. The supplied Docker Compose and Helm configurations include it.&lt;/p&gt;

&lt;p&gt;The latest release adds cluster-wide IP blocking with optional expiry, signed responses between servers, and overwriting sensitive decrypted field values in memory when requests finish using them. It also fixes a change-feed issue so users cannot learn about deletions of records they weren't allowed to see.&lt;/p&gt;

&lt;h1&gt;
  
  
  A foreign key question that changed the engine
&lt;/h1&gt;

&lt;p&gt;One of the changes in 2.4.3 began with a prospect asking about foreign keys.&lt;/p&gt;

&lt;p&gt;HexDB now supports optional foreign keys in document schemas. With enforcement enabled, a write referencing a missing parent is refused.&lt;/p&gt;

&lt;p&gt;The interesting part is when that check happens.&lt;/p&gt;

&lt;p&gt;Suppose an order references a customer:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A request checks that the customer exists.&lt;/li&gt;
&lt;li&gt;Another request deletes that customer.&lt;/li&gt;
&lt;li&gt;The first request commits the order.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A successful check at step one isn't enough to prevent an orphan at step three.&lt;/p&gt;

&lt;p&gt;HexDB checks the relationship as part of the commit itself. Cascading deletes also re-check for newly written children at commit time, closing a related race.&lt;/p&gt;

&lt;p&gt;The CLI gained document, transaction, and schema operations with idempotency keys, so retrying after a dropped connection won't apply the same write twice. A new “Writing safely” manual section explains the guarantees for inserts, updates, upserts, deletes, and transactions.&lt;/p&gt;

&lt;p&gt;This is the kind of feedback I want from people evaluating HexDB. A concrete application requirement can expose something worth changing in the engine.&lt;/p&gt;

&lt;h1&gt;
  
  
  Recovery and performance in the latest releases
&lt;/h1&gt;

&lt;p&gt;A group of HexDB servers is called a lattice. One server, the Overseer, handles writes; eligible replicas can take over if it fails.&lt;/p&gt;

&lt;p&gt;Version 2.4.4 brings failover down to 15–20 seconds, about half the previous time. It also addresses isolated servers electing themselves and servers disagreeing about leadership when the whole cluster starts together.&lt;/p&gt;

&lt;p&gt;Hosted routing now sends traffic only to servers that have the data. In one provisioning run, a new three-region hosted lattice went from nothing to fully ready in 33 seconds.&lt;/p&gt;

&lt;p&gt;Storage and query improvements include:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Measurement&lt;/th&gt;
&lt;th&gt;Before&lt;/th&gt;
&lt;th&gt;After&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Small-record storage in the measured workload&lt;/td&gt;
&lt;td&gt;177 bytes&lt;/td&gt;
&lt;td&gt;40 bytes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GROUP BY over 100,000 documents&lt;/td&gt;
&lt;td&gt;320 ms&lt;/td&gt;
&lt;td&gt;210 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The storage improvement comes from per-file compression dictionaries that capture patterns shared by documents. Reading a stored document also takes about half the work.&lt;/p&gt;

&lt;p&gt;These are measurements from the specific workloads used for the release. They give a useful starting point for evaluating the changes against your own data.&lt;/p&gt;

&lt;h1&gt;
  
  
  Try HexDB and tell me what you find
&lt;/h1&gt;

&lt;p&gt;HexDB is available through npm, PyPI, NuGet, Maven, Homebrew, Chocolatey, Debian packages, and Docker. You can run it yourself or explore hosted lattices.&lt;/p&gt;

&lt;p&gt;The repository has installation instructions, examples, and the technical manual:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://hexdb.app" rel="noopener noreferrer"&gt;HexDB website&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/dreaminhex/hexdb" rel="noopener noreferrer"&gt;Source code and getting started&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/dreaminhex/hexdb/releases/tag/v2.4.4" rel="noopener noreferrer"&gt;Version 2.4.4 release notes&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'd like to hear from developers working with documents, uploaded files, sensitive fields, or semantic search. What would you need to test before considering HexDB for an application? Which integration would make it easier to evaluate?&lt;/p&gt;

&lt;p&gt;The foreign-key question already changed the engine. I'm interested in the next question.&lt;/p&gt;

</description>
      <category>database</category>
      <category>rust</category>
      <category>opensource</category>
      <category>security</category>
    </item>
  </channel>
</rss>
