Skip to content

fix: adjust search directory priority in semantic search#332

Merged
Johnson-zs merged 1 commit into
linuxdeepin:semantic-searchfrom
Johnson-zs:semantic-search
Jun 30, 2026
Merged

fix: adjust search directory priority in semantic search#332
Johnson-zs merged 1 commit into
linuxdeepin:semantic-searchfrom
Johnson-zs:semantic-search

Conversation

@Johnson-zs

@Johnson-zs Johnson-zs commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Modified the search directory priority logic in semantic search to
prioritize NLP-parsed directories over caller-specified ones. This
change better reflects user intent when they specify locations in
natural language queries (e.g. "search in documents").

The previous implementation gave higher priority to caller-specified
directories, which could override the user's explicit intent from
their natural language query. For example, if a user searches "find
xxx in documents" while the application provides Downloads as default
directory, we should search in Documents first.

Log:
Fixed semantic search to properly prioritize user-specified locations
from natural language queries over default directories

Influence:

  1. Test searches with locations specified in natural language (e.g.
    "find in documents")
  2. Verify behavior when both natural language locations and caller
    defaults exist
  3. Check home directory fallback when no locations specified
  4. Test various combinations of natural language inputs and default
    directories

fix: 调整语义搜索中目录优先级

修改了语义搜索中目录优先级逻辑,将NLP解析出的目录优先于调用者指定的目
录。这一改动更好地反映了用户在自然语言查询中指定位置时的意图(例如"在文
档里找xxx")。

之前的实现将调用者指定的目录设为更高优先级,可能会覆盖用户在自然语言查询
中明确表达的意图。例如,当用户搜索"在文档里找xxx"而应用程序默认在下载目
录搜索时,我们应该优先在文档目录搜索。

Log:
修复语义搜索功能,使其正确优先处理自然语言查询中用户指定的位置而非默认
目录

Influence:

  1. 测试包含自然语言位置指定的搜索(如"在文档中查找")
  2. 验证当自然语言位置和调用者默认目录同时存在时的行为
  3. 检查未指定位置时回退到主目录的情况
  4. 测试各种自然语言输入和默认目录的组合

Summary by Sourcery

Bug Fixes:

  • Ensure semantic search respects user-specified locations extracted from natural language queries ahead of default directories.

Modified the search directory priority logic in semantic search to
prioritize NLP-parsed directories over caller-specified ones. This
change better reflects user intent when they specify locations in
natural language queries (e.g. "search in documents").

The previous implementation gave higher priority to caller-specified
directories, which could override the user's explicit intent from
their natural language query. For example, if a user searches "find
xxx in documents" while the application provides Downloads as default
directory, we should search in Documents first.

Log:
Fixed semantic search to properly prioritize user-specified locations
from natural language queries over default directories

Influence:
1. Test searches with locations specified in natural language (e.g.
"find in documents")
2. Verify behavior when both natural language locations and caller
defaults exist
3. Check home directory fallback when no locations specified
4. Test various combinations of natural language inputs and default
directories

fix: 调整语义搜索中目录优先级

修改了语义搜索中目录优先级逻辑,将NLP解析出的目录优先于调用者指定的目
录。这一改动更好地反映了用户在自然语言查询中指定位置时的意图(例如"在文
档里找xxx")。

之前的实现将调用者指定的目录设为更高优先级,可能会覆盖用户在自然语言查询
中明确表达的意图。例如,当用户搜索"在文档里找xxx"而应用程序默认在下载目
录搜索时,我们应该优先在文档目录搜索。

Log:
修复语义搜索功能,使其正确优先处理自然语言查询中用户指定的位置而非默认
目录

Influence:
1. 测试包含自然语言位置指定的搜索(如"在文档中查找")
2. 验证当自然语言位置和调用者默认目录同时存在时的行为
3. 检查未指定位置时回退到主目录的情况
4. 测试各种自然语言输入和默认目录的组合
@sourcery-ai

sourcery-ai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts semantic search directory selection to prioritize NLP-parsed directories over caller-provided defaults, ensuring the search respects user-specified locations from natural language queries while still falling back to caller defaults and then the home directory.

Sequence diagram for updated semantic search directory priority

sequenceDiagram
    actor User
    participant Caller as CallerApp
    participant SemanticSearcherData
    participant QueryBuilder

    User->>Caller: requestSearch(naturalLanguage, searchDirectories)
    Caller->>SemanticSearcherData: doSearch(naturalLanguage, searchDirectories)

    SemanticSearcherData->>QueryBuilder: build(intent)
    QueryBuilder-->>SemanticSearcherData: plan

    alt plan.searchDirectories not empty
        SemanticSearcherData->>SemanticSearcherData: use plan.searchDirectories
    else searchDirectories not empty
        SemanticSearcherData->>SemanticSearcherData: use searchDirectories
    else
        SemanticSearcherData->>SemanticSearcherData: use QDir::homePath()
    end

    SemanticSearcherData-->>Caller: searchResults
Loading

File-Level Changes

Change Details Files
Reordered search directory priority to favor NLP-parsed directories over caller-specified directories, with home directory as final fallback.
  • Updated the priority comment to reflect new ordering of NLP-parsed, caller-specified, and home directory paths.
  • Changed the conditional logic to first use plan.searchDirectories when present, then searchDirectories, and finally QDir::homePath() as fallback.
  • Added an inline Chinese comment explaining that NLP-parsed paths are the most direct expression of user intent and should take precedence over default paths.
src/dfm-search/dfm-search-lib/semantic/semanticsearcher.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • When both NLP-parsed and caller-specified directories are present you now fully ignore the caller directories instead of merging them; consider whether appending caller defaults after NLP directories would better align with the described prioritization rather than a hard override.
  • The inline comment describing directory priority is helpful; you might also briefly note what happens when both sources are non-empty to make the precedence and non-merging behavior explicit for future maintainers.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- When both NLP-parsed and caller-specified directories are present you now fully ignore the caller directories instead of merging them; consider whether appending caller defaults after NLP directories would better align with the described prioritization rather than a hard override.
- The inline comment describing directory priority is helpful; you might also briefly note what happens when both sources are non-empty to make the precedence and non-merging behavior explicit for future maintainers.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Johnson-zs

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Johnson-zs Johnson-zs merged commit 434710a into linuxdeepin:semantic-search Jun 30, 2026
36 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants