How to keep a document index current as files change

A GroupDocs.Search index is the agent’s memory of a folder: built once, kept on disk, and brought up to date with one call. Run the server locally in Docker, and after files change ask the agent to refresh — update_index re-reads only the changed, added and deleted files:

docker run --rm -i -v $(pwd)/documents:/data \
  ghcr.io/groupdocs-search/search-net-mcp:latest

I edited some contracts. Refresh the contracts index, then tell me which contracts mention a penalty now.

Note
The commands and config snippets on this page are for the .NET build of the server, which ships as a Docker image only. Installation and client setup: MCP server for .NET. Other platforms will expose the same tools with their own launch command; everything else on this page applies unchanged.

Prerequisites

State across sessions

session 1    add_to_index --> index "contracts" --+
                                                 |  kept on disk in
session 2    search, get_text_fragments <--------+  /data/.groupdocs-search-
             (nothing is re-read)                    index/contracts
files edit   update_index --> re-reads changed, added, deleted files only
new project  create_index {"indexName":"legal-2026"} --> a separate index

What the agent sees

Captured from server 26.10.1. The NDA was edited to add a penalty clause between the first and second calls:

-> get_index_info {"indexName":"contracts"}
<- { "documentCount": 5, "indexedPaths": [ "contracts" ],
     "documentsWithErrors": [], "status": "Ready" }

-> update_index {"indexName":"contracts"}
<- Index 'contracts' updated: 0 added, 1 updated, 0 removed;
   5 document(s) in the index.

-> search {"query":"penalty","indexName":"contracts"}
<- documentsFound 3 — the edited initech-nda.docx now matches on its
   new clause

One index per project

Start a separate index called legal-2026 for this year’s contracts.

-> create_index {"indexName":"legal-2026"}
<- Index 'legal-2026' created. Add documents with add_to_index
   (indexName: 'legal-2026').

Names keep corpora apart — contracts, mail, reports, one per client — and each index lives in its own folder under /data/.groupdocs-search-index. get_index_info without a name lists them all.

The lifecycle, and the one rule about removal

create_index (optional)
      |
      v
add_to_index ---> search ---> get_text_fragments
      ^              ^
      |              |  get_index_info: counts, paths, status
update_index  (files changed on disk)
      |
remove_from_index  (only a path that was given to add_to_index)

The engine removes paths that were added, not files inside them:

-> remove_from_index {"documentPath":"contracts/hooli-supply-terms.txt",
                      "indexName":"contracts"}
<- Removal failed for 'contracts/hooli-supply-terms.txt':
   'contracts/hooli-supply-terms.txt' is inside the indexed folder
   'contracts'. GroupDocs.Search removes whole indexed paths only: remove
   that folder, then add back the files or sub-folders you want with
   add_to_index. Indexed paths: 'contracts'.

If you expect to drop parts of a corpus — drafts, a year, a client — index them as separate paths (contracts/2025, contracts/2026), so each one can be removed on its own. Deleting a file on disk and calling update_index also removes it.

Keeping it current without asking

  • On a schedule: any MCP-capable automation can call update_index nightly; the call is cheap when little has changed.
  • In the agent’s instructions: tell it to refresh before answering (snippet below).
  • After a bulk copy: one update_index picks up every added file.

Expected result

The index reflects the folder after one call, and the counts say what changed. Indexes built by GroupDocs.Search 22.7–26.8 are converted on first use, with a .pre-26.10-backup copy kept next to the index.

Troubleshooting

SymptomCauseFix
The index is empty after restarting the container/data was not a mounted host foldermount it: -v /path/to/documents:/data
A deleted file still matchesthe index was not updatedupdate_index
"…is inside the indexed folder"removing a file from an added folderremove the folder, or index sub-folders separately

FAQ

Does update_index re-read everything? No — changed, added and deleted files in the index’s paths only.

Can two projects share documents? Yes: add the same path to two indexes. Each index keeps its own copy of the text.

Where does the index live if my documents are read-only? Mount a writable folder at /index and set GROUPDOCS_MCP_INDEX_PATH=/index — configuration.

Add to your CLAUDE.md or AGENTS.md

Agents follow project instructions about when to use a tool. Paste this into the instruction file your agent reads (CLAUDE.md, AGENTS.md, .github/copilot-instructions.md, .cursorrules):

This project's documents are indexed in the groupdocs-search index named
<project>. Call update_index (indexName: <project>) before answering questions
about them if files may have changed since the last session.

Honest limits

  • Evaluation mode: an index holds at most 100 documents and a search returns at most 10 — the response says so in its evaluation field. Licensing.
  • Full-text, not semantic: it matches words, not meaning. Ask the agent to try variants (OR, fuzzy: true).
  • No OCR: scans without a text layer are indexed by their file properties only.
  • Docker only: there is no dnx channel for this product (why).

Read more