Skip to content

Conversation

@uddhavdave
Copy link
Contributor

@uddhavdave uddhavdave commented Sep 5, 2024

New environment variable to check toggle between Contains and Prefix search.

Summary by CodeRabbit

  • New Features

    • Introduced a new configuration option for full-text search type, allowing users to choose between 'contains', 'eq', and 'prefix' matching.
    • Enhanced search query construction to support exact, prefix, and substring matching based on user configuration.
  • Bug Fixes

    • Improved readability of help descriptions for existing configuration fields, ensuring clarity for users.
  • Documentation

    • Updated documentation for new and existing configuration options to provide better guidance for users.

@uddhavdave uddhavdave self-assigned this Sep 5, 2024
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 5, 2024

Walkthrough

The changes introduce a new public field full_text_search_type to the Common struct for configuring search types. The get_file_list_by_inverted_index function is modified to adjust the SQL condition based on the full_text_search_type configuration, allowing for both exact and prefix matching. Additionally, help descriptions for existing fields in the Nats struct are reformatted for improved readability. The merging logic for ScanStats is updated to retain the maximum value of idx_took instead of summing it.

Changes

Files Change Summary
src/config/src/config.rs Added a new public field full_text_search_type to the Common struct and reformatted help descriptions for replicas and history in the Nats struct.
src/config/src/meta/search.rs Updated the merging logic in ScanStats to retain the maximum value of idx_took during merges.
src/service/search/cluster/mod.rs Updated get_file_list_by_inverted_index to conditionally construct the fts_condition string for exact or prefix matching based on the full_text_search_type.

Possibly related PRs

  • fix: remove start date change for cache duration #4482: The changes in this PR involve modifications to the search functionality, specifically in how query ranges are handled, which may indirectly relate to the overall search capabilities enhanced by the main PR's introduction of the full_text_search_type configuration.

Suggested labels

🧹 Updates


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@uddhavdave uddhavdave marked this pull request as ready for review September 5, 2024 07:18
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4007bf7 and 7dc3d72.

Files selected for processing (3)
  • src/config/src/config.rs (2 hunks)
  • src/config/src/meta/inverted_index/search.rs (2 hunks)
  • src/service/search/grpc/storage.rs (3 hunks)
Additional context used
Path-based instructions (3)
src/config/src/meta/inverted_index/search.rs (1)

Pattern **/*.rs: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

src/service/search/grpc/storage.rs (1)

Pattern **/*.rs: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

src/config/src/config.rs (1)

Pattern **/*.rs: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

Additional comments not posted (4)
src/config/src/meta/inverted_index/search.rs (1)

45-81: Review of PrefixSearch struct and its methods

  1. Constructor (new method, lines 51-56): The method correctly clones the terms and stores a reference to ColumnIndexMeta. This is efficient and follows Rust's ownership rules.

  2. Search Method (lines 58-69): The method uses the filter function to preprocess terms and then constructs matchers using the StartsWith automaton. This is a good use of the fst crate for efficient prefix matching. However, ensure that the IndexReader and its methods (fst and get_bitmap) are implemented to handle asynchronous operations correctly.

  3. Filter Method (lines 71-80): The method retains terms based on length and value constraints. The logic correctly checks the conditions using meta properties. This method efficiently reduces the number of terms to be processed in the search method, which can improve performance.

Overall, the implementation of PrefixSearch appears robust and well-suited for the intended functionality of prefix-based searching. Ensure that associated unit tests cover various edge cases, such as terms at the boundary of length and value constraints.

src/service/search/grpc/storage.rs (1)

22-22: Update import statement to include PrefixSearch.

The addition of PrefixSearch in the import statement is necessary for the new functionality introduced in this PR. This change is consistent with the PR's objective to allow toggling between different search types.

src/config/src/config.rs (2)

709-714: Review: New configuration field full_text_search_type

The addition of the full_text_search_type field in the Common struct is well implemented. The field is properly annotated with #[env_config] to specify the environment variable ZO_FULL_TEXT_SEARCH_TYPE, a default value of "contains", and a helpful description. This aligns with the PR's objective to allow toggling between "Contains" and "Prefix" search types.


1146-1147: Review: Updated help descriptions for replicas and history in the Nats struct

The updated help descriptions for the replicas and history fields provide clearer guidance on their usage and limitations, specifically noting that these settings cannot be modified after the bucket is initialized. This is a good improvement for user documentation and helps prevent configuration errors.

Also applies to: 1154-1155

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7dc3d72 and 3fbedb5.

Files selected for processing (2)
  • src/service/search/cluster/mod.rs (1 hunks)
  • src/service/search/grpc/storage.rs (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/service/search/grpc/storage.rs
Additional context used
Path-based instructions (1)
src/service/search/cluster/mod.rs (1)

Pattern **/*.rs: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestions

Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3fbedb5 and a02bd7f.

Files selected for processing (2)
  • src/config/src/config.rs (2 hunks)
  • src/service/search/grpc/storage.rs (4 hunks)
Files skipped from review as they are similar to previous changes (2)
  • src/config/src/config.rs
  • src/service/search/grpc/storage.rs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a02bd7f and 1e7c37d.

Files selected for processing (1)
  • src/service/search/grpc/storage.rs (7 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/service/search/grpc/storage.rs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1e7c37d and e39d32d.

Files selected for processing (1)
  • src/service/search/cluster/mod.rs (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/service/search/cluster/mod.rs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e39d32d and 497ed90.

Files selected for processing (4)
  • src/config/src/config.rs (2 hunks)
  • src/config/src/meta/inverted_index/search.rs (3 hunks)
  • src/service/search/cluster/mod.rs (3 hunks)
  • src/service/search/grpc/storage.rs (7 hunks)
Files skipped from review as they are similar to previous changes (4)
  • src/config/src/config.rs
  • src/config/src/meta/inverted_index/search.rs
  • src/service/search/cluster/mod.rs
  • src/service/search/grpc/storage.rs

@hengfeiyang hengfeiyang merged commit 1a4e53a into main Sep 12, 2024
@hengfeiyang hengfeiyang deleted the feat/add_toggle_for_fst branch September 12, 2024 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants