-
Notifications
You must be signed in to change notification settings - Fork 100
Add support for similar docs query #674
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughA new module for similarity search has been introduced, including data structures and builder methods for constructing and executing similarity queries on an index. The Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Index
participant SimilarQuery
participant HTTP
Client->>Index: similar_query(&SimilarQuery)
Index->>HTTP: POST /indexes/{uid}/similar (with SimilarQuery)
HTTP-->>Index: SimilarResults<T>
Index-->>Client: Result<SimilarResults<T>, Error>
Assessment against linked issues
Assessment against linked issues: Out-of-scope changes
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (5)
src/lib.rs (1)
264-266
: Consider keeping module declarations alphabetically sorted for quicker discoverability
similar
is appended afterutils
, which breaks the existing (roughly) alphabetical ordering of the publicmod
list (search
,settings
,snapshots
, …). Re-ordering modules helps future contributors locate items faster.-/// Module related to similar queries and results. -pub mod similar; +/// Module related to similar queries and results. +pub mod similar; // move this so the list stays alphabetically orderedPurely cosmetic – adjust only if you value the convention.
src/search.rs (1)
110-118
: Visibility bump looks good; double-check companion helpersExposing
serialize_with_wildcard
aspub(crate)
is necessary for the newsimilar
module — nice catch.
Ifsimilar
ever needs the crop helper as well (serialize_attributes_to_crop_with_wildcard
), remember to apply the same visibility change or move both helpers to a sharedutils
sub-module to avoid future leakage.src/similar.rs (3)
38-39
: Clarify documentation for theid
fieldThe comment "Search Doc ID" is ambiguous. Consider clarifying that this is the ID of the reference document used for the similarity search.
- /// Search Doc ID + /// ID of the reference document used for the similarity search pub id: String,
212-214
: Remove unnecessary clone inbuild
methodThe
build
method clones the entire query object unnecessarily. Consider returning a reference or removing this method if not needed.- pub fn build(&mut self) -> SimilarQuery<'a, Http> { - self.clone() - } + pub fn build(&self) -> &SimilarQuery<'a, Http> { + self + }Alternatively, if the
build
method is not essential (sinceexecute
can be called directly), consider removing it entirely to simplify the API.
223-225
: Fix typo and track embedder configurationThere's a typo in the comment, and the TODO indicates missing functionality.
// TODO: set UserProvided EembdderConfig // Embedder have not been implemented -// But Now It does't work +// But Now It doesn't workWould you like me to create an issue to track the implementation of embedder configuration functionality?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/indexes.rs
(2 hunks)src/lib.rs
(1 hunks)src/search.rs
(1 hunks)src/similar.rs
(1 hunks)
🔇 Additional comments (1)
src/indexes.rs (1)
1657-1669
: LGTM!The implementation correctly follows the established pattern for query methods and properly integrates with the similar module.
/// let query = SimilarQuery::new(&movies, "1", "default").build(); | ||
/// let results = query.similar_query::<Movie>(&query).await.unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix documentation example error
The example incorrectly calls similar_query
on the query
object instead of the movies
index object.
let query = SimilarQuery::new(&movies, "1", "default").build();
-let results = query.similar_query::<Movie>(&query).await.unwrap();
+let results = movies.similar_query::<Movie>(&query).await.unwrap();
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
/// let query = SimilarQuery::new(&movies, "1", "default").build(); | |
/// let results = query.similar_query::<Movie>(&query).await.unwrap(); | |
/// let query = SimilarQuery::new(&movies, "1", "default").build(); | |
/// let results = movies.similar_query::<Movie>(&query).await.unwrap(); |
🤖 Prompt for AI Agents
In src/indexes.rs around lines 1650 to 1651, the documentation example
incorrectly calls similar_query on the query object instead of the movies index
object. Fix this by changing the call to similar_query to be on the movies index
object, passing the query as an argument, ensuring the example correctly
demonstrates usage.
Pull Request
Related issue
Fixes #646
What does this PR do?
embedders
setting and other vector/hybrid search related configuration #554 is merged.PR checklist
Please check if your PR fulfills the following requirements:
Thank you so much for contributing to Meilisearch!
Summary by CodeRabbit
New Features
Documentation