Skip to content

Add fractional search feature to ripgrep_search tool#943

Draft
codegen-sh[bot] wants to merge 2 commits intodevelopfrom
codegen-fractional-search-feature-a7b3c9
Draft

Add fractional search feature to ripgrep_search tool#943
codegen-sh[bot] wants to merge 2 commits intodevelopfrom
codegen-fractional-search-feature-a7b3c9

Conversation

@codegen-sh
Copy link
Contributor

@codegen-sh codegen-sh bot commented Mar 22, 2025

This PR adds a new fractional_search parameter to the ripgrep_search tool that enables automatic fallback to searching for individual words when a multi-word search returns no results.

Features

  • Added a new boolean parameter fractional_search (default: False) to the search functions
  • When enabled and a multi-word search returns no results, the system will:
    • Split the query into individual words
    • Search for each word separately (skipping very short words < 3 chars)
    • Combine the results while avoiding duplicates
    • Return the combined results as if they were from the original query
  • Implemented for both the ripgrep and Python search implementations

Benefits

  • Improves search experience by providing relevant results even when exact phrases aren't found
  • Helps users find related code without having to manually try different search terms
  • Maintains the original search behavior by default (opt-in feature)

Example Usage

# Search with automatic fallback to individual words
ripgrep_search(query="transaction date validation", fractional_search=True)

This addresses the request from Eduardo Pujol to implement a fractional search feature as a fallback mechanism when multi-word searches don't yield results.


💻 View my work • React 👍 or 👎

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.

0 participants