Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

community[minor]: keywordSearchWithScore on OpenSearchVectorStore #5823

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

johnnoG
Copy link

@johnnoG johnnoG commented Jun 20, 2024

Description of the Change

This PR adds a new method keywordSearchWithScore to the OpenSearchVectorStore class. This method performs a keyword search on the OpenSearch index and returns the matched documents along with their scores. This enhancement will allow users to retrieve both documents and their relevance scores from the OpenSearch index, providing more detailed search results.

Relevant Context

The keywordSearchWithScore method:

  • Accepts a keyword query, a limit on the number of results, and an optional filter.
  • Constructs an OpenSearch query to match documents based on the provided keyword and filter.
  • Returns an array of tuples, each containing a document and its corresponding score.

Tests have been added to ensure the method works correctly and handles errors appropriately. Documentation has also been updated to reflect this new functionality.

Example Usage

const results = await vectorStore.keywordSearchWithScore('example query', 10);
results.forEach(([document, score]) => {
  console.log('Document:', document);
  console.log('Score:', score);
});

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jun 20, 2024
Copy link

vercel bot commented Jun 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2024 1:13pm
langchainjs-docs ✅ Ready (Inspect) Visit Preview Jun 20, 2024 1:13pm

@dosubot dosubot bot added the auto:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features label Jun 20, 2024
@bracesproul bracesproul changed the title keywordSearchWithScore on OpenSearchVectorStore community[minor]: keywordSearchWithScore on OpenSearchVectorStore Jun 20, 2024
Copy link
Collaborator

@bracesproul bracesproul left a comment

Choose a reason for hiding this comment

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

lgtm, thank you!

@dosubot dosubot bot added the lgtm PRs that are ready to be merged as-is label Jun 20, 2024
@bracesproul
Copy link
Collaborator

Looks like CI Is failing, could you push up a fix @johnnoG

@bracesproul bracesproul removed the lgtm PRs that are ready to be merged as-is label Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants