Skip to content

Semantic search: add node_type and property-based filtering #1059

Description

@malibio

Problem

semantic_search currently only supports query, limit, and threshold. The scoped variant (semantic_search_scoped) adds node type filtering via SearchScope, but this is a post-filter applied in Rust after fetching results — not a database-level filter.

There is no way to filter semantic search results by:

  • Specific node type(s) (e.g., only skill nodes)
  • Property values (e.g., source == "built-in")

Use Cases

  1. Skill pipeline: needs to search only skill nodes for intent matching — currently fetches all types and post-filters, wasting capacity
  2. Scoped searches: MCP search_semantic exposes scope but not fine-grained type/property filters
  3. Built-in vs user content: no way to restrict search to user-created content or built-in system content

Proposed Solution

Add optional node_type and property_filters parameters to semantic_search:

pub async fn semantic_search(
    &self,
    query: &str,
    limit: usize,
    threshold: f32,
    node_type: Option<&str>,                      // NEW
    property_filters: Option<&[PropertyFilter]>,   // NEW
) -> Result<Vec<EmbeddingSearchResult>, NodeServiceError>

Where possible, push filters into the SurrealDB query (WHERE clause on the embedding table join) rather than post-filtering in Rust.

Acceptance Criteria

  • semantic_search accepts optional node_type filter
  • semantic_search accepts optional property-based filters (at minimum: equality check)
  • Filters are applied at the database level where possible (not just post-filter)
  • Skill pipeline uses node_type: Some("skill") instead of post-filtering
  • MCP search_semantic handler exposes node_type parameter
  • Existing callers (no filters) continue to work unchanged
  • Tests cover filtered and unfiltered paths

Activity

  1. added
    enhancement
    on Apr 7, 2026
  2. malibio commented on Apr 7, 2026

    @malibio
    CollaboratorAuthor

    Baseline: 128 passed, 0 failed

  3. self-assigned this
    on Apr 7, 2026
  4. added a commit that references this issue on Apr 7, 2026
    16fe675
  5. added 4 commits that reference this issue on Apr 7, 2026
    5d284c1
    e3a28fa
    6b2c7c4
    f2dbe8a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

backendenhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions