Skip to content

feat: add exclude_paths parameter to search#156

Open
filhocf wants to merge 1 commit into
cocoindex-io:mainfrom
filhocf:feat/exclude-paths
Open

feat: add exclude_paths parameter to search#156
filhocf wants to merge 1 commit into
cocoindex-io:mainfrom
filhocf:feat/exclude-paths

Conversation

@filhocf
Copy link
Copy Markdown

@filhocf filhocf commented May 3, 2026

Summary

Adds an exclude_paths parameter to the search function, allowing users to exclude files matching GLOB patterns from search results.

Problem

As described in #146, projects with i18n/locales folders or generated files see those files dominating search results because they contain concentrated keywords. Users need a way to exclude specific paths without removing them from the index entirely.

Solution

Added exclude_paths: list[str] | None parameter across all layers:

Layer File Change
Protocol protocol.py New field on SearchRequest
Query query.py SQL NOT GLOB clauses in _full_scan_query
Project project.py Pass-through parameter
Daemon daemon.py Pass-through parameter
Client client.py Pass-through parameter
MCP Server server.py New tool parameter with description
CLI cli.py New --exclude flag

Usage

MCP tool:

{"query": "authentication", "exclude_paths": ["i18n/locales/*", "*.min.js"]}

CLI:

ccc search 'authentication' --exclude 'i18n/locales/*' --exclude '*.min.js'

Implementation

When exclude_paths is provided, the query engine falls back to full-scan mode (same behavior as paths), applying NOT GLOB clauses in the SQL WHERE condition. This ensures excluded files are filtered at the database level.

Closes #146

Adds an exclude_paths parameter (list of GLOB patterns) to filter out
unwanted files from search results. This is useful for projects with
i18n/locales or generated files that dominate search results.

The parameter is supported across all layers:
- MCP tool (server.py)
- CLI (--exclude flag)
- Client library
- Daemon
- Query engine (SQL-level NOT GLOB filtering)

When exclude_paths is provided, the query falls back to full-scan mode
(same as paths), applying NOT GLOB clauses in the WHERE condition.

Closes cocoindex-io#146
@filhocf
Copy link
Copy Markdown
Author

filhocf commented May 3, 2026

@gemini-code-assist review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exclude path from search

1 participant