Skip to content

Fix search_nodes: use title index, compose node_type filter, and expose property filters - #1097

Merged
malibio merged 2 commits into
mainfrom
feature/issue-1084-fix-search-nodes-title-index
Apr 11, 2026
Merged

malibio merged 2 commits into
mainfrom
feature/issue-1084-fix-search-nodes-title-index

Conversation

@malibio

@malibio malibio commented Apr 11, 2026

Copy link
Copy Markdown
Collaborator

Closes #1084

…property filters (closes #1084)

- surreal_store.rs: Remove early-return from title_contains branch; compose
  title_contains and node_type into a single WHERE clause so both filters
  are applied together. Also properly handle offset in non-title-search paths.
- tools.rs: Change search_nodes from field="content" to field="title";
  handle empty query (no title filter); parse filters map param into
  QueryFilterItem entries with operator="equals"
- search.rs: Add filters field (HashMap<String,String>) to SearchNodesParams
- def_search_nodes: Add filters to tool schema; update description to
  document title search, empty-query behavior, and property filter capability
- prompt_assembler.rs: Update Tool Strategy Guide with filters guidance
- skill_pipeline.rs: Add LISTING BY TYPE OR PROPERTY section to Research
  & Search guidance with examples
- ollama_integration.rs: Add test_pipeline_search_nodes_with_type_filter e2e test
- search_ops.rs: Wire node_types/property_filters to semantic_search_nodes
  and add include_edges/graph_boost fields to SearchSemanticInput
- Add 5 new unit tests for search_nodes params parsing and schema validation

Co-Authored-By: Claude <[email protected]>
@malibio

malibio commented Apr 11, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review — Initial Review

Review Type: Initial Review

Requirements Check

Criterion Status
search_nodes searches title field instead of content ✅
node_type filter applied correctly when title search is active ✅
search_nodes(query="Review quarterly report", node_type="task") returns only task nodes ✅
search_nodes(query="", node_type="task") returns all task nodes ✅
Tool schema exposes filters parameter ✅
search_nodes(query="", node_type="task", filters={"status": "open"}) works ✅
Tool description and parameter descriptions updated ✅
Prompt assembler Tool Strategy Guide updated ✅
Research & Search skill guidance updated ✅
Unit tests: title+node_type composition, title+filters composition ✅ (5 new tests)
New e2e test: model calls search_nodes with node_type for "find all my open tasks" ✅
bun run quality:fix clean ✅
All tests pass ✅ (3918 frontend + 289 agent + 1163 core)

All acceptance criteria met.


Code Review Findings

🟡 Important: Redundant has_title_search flag and misleading let _ = search_query

📁 packages/core/src/db/surreal_store.rs (title_contains block)

if let Some(ref search_query) = query.title_contains {
    conditions.push("title IS NOT NONE AND ...$search_query...".to_string());
    has_title_search = true;
    let _ = search_query; // used via bind below
}
// ...
if has_title_search {
    if let Some(ref search_query) = query.title_contains {
        query_builder = query_builder.bind(("search_query", search_query.to_string()));
    }
}

Two issues:

  1. has_title_search is redundant — query.title_contains.is_some() is equivalent and already available.
  2. let _ = search_query is a misleading no-op. The variable IS used (via the re-borrow of query.title_contains below), but it looks like an intentional discard. The comment "used via bind below" helps, but the idiom is still confusing.

Recommendation: Simplify to remove the flag and the suppression:

if query.title_contains.is_some() {
    if let Some(ref search_query) = query.title_contains {
        query_builder = query_builder.bind(("search_query", search_query.to_string()));
    }
}

Or even simpler: just do the bind unconditionally guarded by if let:

if let Some(ref search_query) = query.title_contains {
    query_builder = query_builder.bind(("search_query", search_query.to_string()));
}

The bind is only used when the SQL contains $search_query, which is guaranteed when title_contains.is_some() because that's the only branch that adds the condition.

Engineering Principle: Prefer direct boolean expressions over boolean flag variables that mirror existing Option state. The duplication is a maintenance hazard — if the flag gets out of sync with the Option, binding behavior diverges from SQL generation.


🟢 Suggestion: search_ops.rs changes are out-of-scope for this issue

📁 packages/core/src/ops/search_ops.rs

The include_edges and graph_boost fields added to SearchSemanticInput (and referenced in SearchSemanticParams in search.rs) were pre-existing worktree changes unrelated to issue #1084. They're included in this diff because the compile error needed to be fixed to add include_edges: None, graph_boost: None in the tools.rs struct initializer. These fields are declared but the business logic that actually uses them isn't implemented (they're always None when called from the tool layer).

This is acceptable since the pre-commit hook passes and no #[allow(dead_code)] suppression was needed (the struct fields themselves don't trigger unused warnings in Rust). Just noting it for traceability.


Recommendation: APPROVE ✅

The implementation correctly addresses all three bugs/gaps from the issue:

  1. Bug 1 fixed: field: "title" in the tool, routing through the title_contains DB path
  2. Bug 2 fixed: surreal_store.rs refactored to compose conditions instead of early-returning before node_type
  3. Gap 3 filled: filters param added to schema, wired through QueryNodesInput.filters → NodeFilter.property_filters → in-memory filtering

The has_title_search flag issue is minor and doesn't affect correctness. The compile fix for pre-existing search_ops.rs changes is appropriate and necessary.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review complete. All acceptance criteria met. One minor cleanup suggestion noted in the PR comment.

@malibio
malibio merged commit 57b59c3 into main Apr 11, 2026
@malibio
malibio deleted the feature/issue-1084-fix-search-nodes-title-index branch April 11, 2026 18:44
malibio added a commit that referenced this pull request Jun 22, 2026
…se property filters (#1097)

* Fix: search_nodes uses title index, compose node_type filter, expose property filters (closes #1084)

- surreal_store.rs: Remove early-return from title_contains branch; compose
  title_contains and node_type into a single WHERE clause so both filters
  are applied together. Also properly handle offset in non-title-search paths.
- tools.rs: Change search_nodes from field="content" to field="title";
  handle empty query (no title filter); parse filters map param into
  QueryFilterItem entries with operator="equals"
- search.rs: Add filters field (HashMap<String,String>) to SearchNodesParams
- def_search_nodes: Add filters to tool schema; update description to
  document title search, empty-query behavior, and property filter capability
- prompt_assembler.rs: Update Tool Strategy Guide with filters guidance
- skill_pipeline.rs: Add LISTING BY TYPE OR PROPERTY section to Research
  & Search guidance with examples
- ollama_integration.rs: Add test_pipeline_search_nodes_with_type_filter e2e test
- search_ops.rs: Wire node_types/property_filters to semantic_search_nodes
  and add include_edges/graph_boost fields to SearchSemanticInput
- Add 5 new unit tests for search_nodes params parsing and schema validation

Co-Authored-By: Claude <[email protected]>

* Fix: remove redundant has_title_search flag in query_nodes title_contains block

---------

Co-authored-by: Claude <[email protected]>
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.

Fix search_nodes: use title index, compose node_type filter, and expose property filters

1 participant