Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.

Implement multimodal( FTS, vector, hybrid) search capability#463

Open
subin-chella wants to merge 1 commit into
reorproject:mainfrom
subin-chella:Feature-Support-hybrid-search
Open

Implement multimodal( FTS, vector, hybrid) search capability#463
subin-chella wants to merge 1 commit into
reorproject:mainfrom
subin-chella:Feature-Support-hybrid-search

Conversation

@subin-chella
Copy link
Copy Markdown
Collaborator

@subin-chella subin-chella commented Oct 21, 2024

  • Add new multiModalSearch function in lanceTableWrapper
  • Support vector, text, and hybrid search modes
  • Integrate with MainSidebar component for user interface
  • Update DBResultPreview and DBSearchPreview to handle new result format
  • Improve search result display with conditional rendering
    fixes Is there a search for text option? #86

Test:
https://github.com/user-attachments/assets/ca162f51-e005-4840-a3be-3ce72a7438f2

- Add new multiModalSearch function in lanceTableWrapper
- Support vector, text, and hybrid search modes
- Integrate with MainSidebar component for user interface
- Update DBResultPreview and DBSearchPreview to handle new result format
- Improve search result display with conditional rendering fixes 86
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR implements multimodal search capability, adding support for vector, text, and hybrid search modes across several components. The changes address the issue of providing a literal text search option alongside the existing AI-based similarity search.

  • Added multiModalSearch function in LanceDBTableWrapper class, supporting vector, text, and hybrid search types
  • Introduced new IPC handler for multimodal search in ipcHandlers.ts
  • Updated SearchComponent with a dropdown to select search type (vector, text, or hybrid)
  • Modified DBSearchPreview component to conditionally render similarity scores for vector search results
  • Improved search results display in SearchComponent, separating vector and text results

7 file(s) reviewed, 14 comment(s)
Edit PR Review Bot Settings | Greptile

return searchResults
})

ipcMain.handle(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

style: The multi-modal search handler is implemented correctly, but consider adding error handling for invalid searchType values.

Comment on lines +145 to +146
? `${filter} AND content LIKE '%${sanitizedTextQuery}%'`
: `content LIKE '%${sanitizedTextQuery}%'`
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

style: LIKE with wildcards on both sides can be slow for large datasets. Consider using full-text search capabilities if available in LanceDB

Comment on lines +137 to +139
vectorResults = rawVectorResults
.map(convertRecordToDBType<DBQueryResult>)
.filter((r): r is DBQueryResult => r !== null)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

logic: Filtering out null results here may lead to fewer results than the specified limit. Consider adjusting the limit to account for potential null results

Comment thread electron/preload/index.ts
limit: number,
searchType: 'vector' | 'text' | 'hybrid',
filter?: string,
) => Promise<{ vectorResults: DBQueryResult[]; textResults: DBQueryResult[] }>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

style: Consider adding a type alias for the return type of multiModalSearch for better readability and maintainability.

Comment on lines +67 to +72
{entry._distance != null && (
<>
{/* eslint-disable-next-line no-underscore-dangle */}| Similarity:{' '}
{cosineDistanceToPercentage(entry._distance)}%{' '}
</>
)}{' '}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

style: Consider moving this logic to a separate function for better readability and reusability

{cosineDistanceToPercentage(entry._distance)}%{' '}
</>
)}{' '}
| {modified && <span className="text-xs text-gray-400">Modified {modified}</span>}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

style: Add a space before the pipe character for consistent formatting

Comment on lines +17 to +20
const [searchResults, setSearchResults] = useState<{ vectorResults: DBQueryResult[]; textResults: DBQueryResult[] }>({
vectorResults: [],
textResults: [],
})
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

style: Consider using a more specific type for searchResults instead of an inline object type

Comment on lines +87 to +95
{searchResults?.textResults?.length > 0 && (
<div className="mt-4 w-full">
<h3 className="mb-2 text-white">Text Search Results</h3>
{searchResults.textResults.map((result, index) => (
// eslint-disable-next-line react/no-array-index-key
<DBSearchPreview key={`text-${index}`} dbResult={result} onSelect={openFileSelectSearch} />
))}
</div>
)}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

style: Add error handling for cases where searchResults is undefined

Comment thread src/components/Sidebars/SearchComponent.tsx
@joseplayero
Copy link
Copy Markdown
Collaborator

thanking you for attempting this @subin-chella

imo this should be solved with a full text search index not sql expression like you have implemented in pr.

@milaiwi has been working on this exact implementation so would be good to hear thoughts

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Is there a search for text option?

2 participants