Skip to content

Conversation

@pc223
Copy link
Contributor

@pc223 pc223 commented Jul 12, 2021

I just found out we can use this field System.Search.Rank to sort, seems much better than order by file name. Thought?

https://docs.microsoft.com/en-us/windows/win32/properties/props-system-search-rank

original results:

image

current results:

image

@taooceros
Copy link
Member

I have a though in #356 previously, but haven't implemented it. It is good to hear that there is an option to sort based on match!

@pc223
Copy link
Contributor Author

pc223 commented Jul 13, 2021

I have a though in #356 previously, but haven't implemented it. It is good to hear that there is an option to sort based on match!

Yeah, I'm experimenting with this new sort for plugin Explorer, by default, seems much better.

We can get the System.Search.Rank data out too if needed for debugging, just add it after SELECT.

@jjw24
Copy link
Member

jjw24 commented Jul 14, 2021

Will try out after later

@taooceros
Copy link
Member

I think this one is good to be included in 1.9.0? Also, Rank can be used for scoring.

@taooceros taooceros added this to the 1.9.0 milestone Nov 15, 2021
@taooceros taooceros modified the milestones: 1.9.0, 1.9.1 Dec 9, 2021
@taooceros taooceros modified the milestones: 1.9.1, 1.10.0 Dec 29, 2021
@jjw24 jjw24 modified the milestones: 1.10.0, Future Dec 12, 2022
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@Jack251970 Jack251970 modified the milestones: Future, 1.20.0 Apr 12, 2025
@Jack251970 Jack251970 requested a review from Copilot April 12, 2025 12:53
@Jack251970 Jack251970 marked this pull request as ready for review April 12, 2025 12:53
@Jack251970 Jack251970 added the enhancement New feature or request label Apr 12, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs:63

  • Using LIKE and CONTAINS operators on System.Search.Rank (a numeric field) may lead to unintended behavior. Please verify that filtering with text-based operators is valid for this property or if additional type conversion is required.
var queryConstraint = searchString.IsWhiteSpace() ? "" : $"AND ({OrderIdentifier} LIKE '{searchString}%' OR CONTAINS({OrderIdentifier},'\"{searchString}*\"'))";

Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs:86

  • There is no visible test coverage for the new ordering logic using System.Search.Rank. Please consider adding tests to confirm that ordering and filtering behave as expected.
return $"{CreateBaseQuery().GenerateSQLFromUserQuery(replacedSearchString)} AND {RestrictionsForAllFilesAndFoldersSearch} ORDER BY {OrderIdentifier}";

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 12, 2025

📝 Walkthrough

Walkthrough

The changes update the ordering mechanism for search result queries in the WindowsIndex module. A new constant, OrderIdentifier (set to "System.Search.Rank DESC"), replaces the previous FileName constant. This update is applied consistently across the Directory, FilesAndFolders, and FileContent methods in the query construction. Additionally, the test cases in the ExplorerTest class have been modified to reference OrderIdentifier instead of the hardcoded System.FileName in their SQL queries. Furthermore, new asynchronous search methods have been added to the WindowsIndexSearchManager class.

Changes

File(s) Change Summary
Plugins/Flow.Launcher.Plugin.Explorer/.../QueryConstructor.cs Removed the FileName constant; added OrderIdentifier with the value "System.Search.Rank DESC"; updated the SQL query construction in the Directory, FilesAndFolders, and FileContent methods to use OrderIdentifier for ordering; renamed property settings to Settings and changed method CreateQueryHelper to internal static.
Flow.Launcher.Test/.../ExplorerTest.cs Updated test cases to replace hardcoded ORDER BY System.FileName with dynamic reference to QueryConstructor.OrderIdentifier.
Plugins/Flow.Launcher.Plugin.Explorer/.../WindowsIndexSearchManager.cs Added new methods: SearchAsync, ContentSearchAsync, and EnumerateAsync, which return IAsyncEnumerable<SearchResult>; modified HandledEngineNotAvailableExceptionAsync to directly reference Main.Context.API.

Poem

I'm a rabbit with joyful hops and clever tweaks,
Sorting queries with fresh new peaks.
The old name hops off in the breeze,
As OrderIdentifier now leads with ease.
In this code garden, change sings bright,
Viva the flow of order and light!

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

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
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c8d16a8 and 136a4aa.

📒 Files selected for processing (1)
  • Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
🔇 Additional comments (4)
Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs (4)

69-69: Appropriate use of rank for ordering results

Using OrderIdentifier (System.Search.Rank DESC) in the ORDER BY clause is an appropriate change that will sort results by relevance rather than file name.


86-86: Improved results ordering by relevance

Using System.Search.Rank for ordering search results will provide more relevant matches first, which aligns with the PR objectives of improving search result ordering.


123-128: Well-documented constant with appropriate reference

The OrderIdentifier constant is well-documented with a clear description and link to the official Microsoft documentation, which is excellent for maintainability.


136-136: Consistent use of rank-based ordering

Applying the same ordering mechanism to file content searches ensures consistent behavior across different search types, which is good for user experience.

@github-actions

This comment has been minimized.

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

🧹 Nitpick comments (1)
Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs (1)

123-128: Well-documented constant with reference to Microsoft docs

The documentation for OrderIdentifier is clear and includes a helpful link to the official Microsoft documentation.

Consider adding a brief explanation of why System.Search.Rank is preferred over filename ordering for additional clarity.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 136a4aa and 8b44b08.

📒 Files selected for processing (2)
  • Flow.Launcher.Test/Plugins/ExplorerTest.cs (4 hunks)
  • Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: gitStream.cm
🔇 Additional comments (8)
Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs (4)

63-63: Fixed logical error by directly using System.FileName

This correctly fixes the issue identified in previous reviews, where using OrderIdentifier (System.Search.Rank) with LIKE and CONTAINS operators was problematic since it's a numeric value, not a string column.


69-69: Improved search experience with relevance-based ordering

Using OrderIdentifier in the ORDER BY clause aligns with the PR objective of ordering search results by relevance rank instead of filename.


86-86: Consistently applied relevance-based ordering

Using OrderIdentifier for the FilesAndFolders method ensures a consistent approach to relevance-based ordering across all search types.


136-136: Applied relevance ranking to file content searches

Using OrderIdentifier for file content searches is particularly beneficial, as it will prioritize files where the search terms are more prominent.

Flow.Launcher.Test/Plugins/ExplorerTest.cs (4)

42-43: Improved test maintainability with dynamic references

Using string interpolation with {QueryConstructor.OrderIdentifier} improves maintainability by centralizing the ordering mechanism definition. If the ordering approach changes in the future, these tests won't need to be updated separately.


62-62: Updated test expectations for specific item search

This change correctly aligns the test expectations with the updated behavior in the QueryConstructor.


90-91: Updated test expectations for folders and files search

These changes ensure the tests properly validate the new relevance-based ordering behavior.


129-129: Updated file content search test expectations

This change completes the consistent update of all test cases to use the new relevance-based sorting mechanism.

@github-actions

This comment has been minimized.

@Jack251970 Jack251970 requested a review from Copilot April 12, 2025 13:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs:40

  • Changing CreateQueryHelper to a static method might limit its ability to access instance-specific settings or state if needed in future updates. Please confirm that this change is intentional in the context of the overall design.
internal static CSearchQueryHelper CreateQueryHelper()

@github-actions

This comment has been minimized.

@Jack251970 Jack251970 changed the title [Explorer] Testing new search order: System.Search.Rank Introduce new search order - System.Search.Rank - for Explorer plugin Apr 12, 2025
@gitstream-cm
Copy link

gitstream-cm bot commented Apr 12, 2025

🥷 Code experts: Jack251970, jjw24

Jack251970 has most 👩‍💻 activity in the files.
jjw24, Jack251970 have most 🧠 knowledge in the files.

See details

Flow.Launcher.Test/Plugins/ExplorerTest.cs

Activity based on git-commit:

Jack251970
APR
MAR
FEB 23 additions & 47 deletions
JAN
DEC
NOV

Knowledge based on git-blame:
jjw24: 41%
Jack251970: 5%

Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs

Activity based on git-commit:

Jack251970
APR
MAR
FEB
JAN
DEC 36 additions & 1 deletions
NOV

Knowledge based on git-blame:
jjw24: 57%
Jack251970: 25%

Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndexSearchManager.cs

Activity based on git-commit:

Jack251970
APR
MAR
FEB
JAN
DEC
NOV

Knowledge based on git-blame:
jjw24: 50%

To learn more about /:\ gitStream - Visit our Docs

1 similar comment
@gitstream-cm
Copy link

gitstream-cm bot commented Apr 12, 2025

🥷 Code experts: Jack251970, jjw24

Jack251970 has most 👩‍💻 activity in the files.
jjw24, Jack251970 have most 🧠 knowledge in the files.

See details

Flow.Launcher.Test/Plugins/ExplorerTest.cs

Activity based on git-commit:

Jack251970
APR
MAR
FEB 23 additions & 47 deletions
JAN
DEC
NOV

Knowledge based on git-blame:
jjw24: 41%
Jack251970: 5%

Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs

Activity based on git-commit:

Jack251970
APR
MAR
FEB
JAN
DEC 36 additions & 1 deletions
NOV

Knowledge based on git-blame:
jjw24: 57%
Jack251970: 25%

Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndexSearchManager.cs

Activity based on git-commit:

Jack251970
APR
MAR
FEB
JAN
DEC
NOV

Knowledge based on git-blame:
jjw24: 50%

To learn more about /:\ gitStream - Visit our Docs

@Jack251970 Jack251970 requested a review from Copilot April 12, 2025 13:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

@github-actions
Copy link

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, or 📝 job summary for details.

❌ Errors Count
❌ forbidden-pattern 22
⚠️ non-alpha-in-dictionary 19

See ❌ Event descriptions for more information.

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

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

🧹 Nitpick comments (1)
Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndexSearchManager.cs (1)

86-99: These methods support the System.Search.Rank implementation

These new public methods align well with the PR objective of using System.Search.Rank for sorting search results. They provide the interface needed to leverage the updated SQL query handling in QueryConstructor where the ORDER BY clause was changed to use the new OrderIdentifier constant.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8b44b08 and a9748ac.

📒 Files selected for processing (2)
  • Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs (5 hunks)
  • Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndexSearchManager.cs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs
🧰 Additional context used
🧬 Code Graph Analysis (1)
Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndexSearchManager.cs (1)
Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs (1)
  • Constants (6-41)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
🔇 Additional comments (4)
Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndexSearchManager.cs (4)

86-89: Clean implementation of the SearchAsync wrapper method

Good addition of this public async method which provides a clean interface for the WindowsIndexFilesAndFoldersSearchAsync functionality. The method properly accepts a CancellationToken for cancellation support which is important for async operations.


91-94: Well-structured ContentSearchAsync wrapper method

This addition provides a clean public interface for content search functionality, implementing the IContentIndexProvider interface. The parameter names are clear and descriptive with appropriate token handling.


96-99: Good implementation of the EnumerateAsync wrapper method

This method properly implements the IPathIndexProvider interface with a clear signature. Good job passing all parameters to the underlying implementation method including the recursive flag and cancellation token.


108-110: Simplified API reference in error handling method

Good refactoring to directly use Main.Context.API instead of storing it in a local variable. This makes the code more direct while maintaining the same functionality in the exception handling.

Also applies to: 116-117

@Jack251970 Jack251970 merged commit 9414710 into Flow-Launcher:dev Apr 12, 2025
6 checks passed
@Jack251970
Copy link
Member

@pc223 Thanks for this!

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants