Skip to content

merge new-file-search#213

Merged
deepin-bot[bot] merged 19 commits into
linuxdeepin:masterfrom
Johnson-zs:develop/new-file-search
May 20, 2025
Merged

merge new-file-search#213
deepin-bot[bot] merged 19 commits into
linuxdeepin:masterfrom
Johnson-zs:develop/new-file-search

Conversation

@Johnson-zs
Copy link
Copy Markdown
Contributor

@Johnson-zs Johnson-zs commented May 20, 2025

Summary by Sourcery

Unify file search implementation to use the DFM6 Search API and remove legacy deepin-anything/fsearch code, refactor file and semantic search workflows accordingly, add debounced front-end search requests, and update build configuration to depend on dfm6-search.

New Features:

  • Introduce debounced search initiation with dynamic delays in QueryController
  • Support boolean and type-based keyword queries for file search

Enhancements:

  • Replace FileNameWorker and FileNameSearcher internals with DFMSEARCH-based SearchOptions/SearchQuery abstractions
  • Extend FileSearchUtils with pinyin detection and DFM file type mapping
  • Rename semantic anything query to FileNameQuery and integrate it with the DFM6 search engine

Build:

  • Add dfm6-search dependency in CMake and remove ENABLE_DEEPINANYTHING/ENABLE_FSEARCH flags

Chores:

  • Remove all 3rd-party deepin-anything and fsearch code and related interfaces
  • Clean up obsolete configuration and default preferences for removed search backends

Johnson-zs and others added 19 commits May 20, 2025 09:48
- Added dfm6-search as a dependency in debian/control.
- Updated CMakeLists.txt to find and link dfm6-search.
- Refactored FileNameSearcher to utilize dfm6-search for file name indexing.
- Removed outdated Anything interface and related methods to streamline search functionality.

Log: enhance file searching capabilities with dfm6-search integration
- Added a debounce timer to optimize search performance by delaying the search execution based on input changes.
- Introduced a new method `performSearch` to handle the actual search logic.
- Updated `onSearchTextChanged` to manage pending search text and adjust debounce timing based on input length.
- Enhanced the overall search flow by ensuring that unnecessary searches are minimized.

Log: Improve search responsiveness and efficiency.
- Updated FileNameWorker to support boolean keyword queries for improved search accuracy.
- Modified FileSearchUtils to parse and store boolean keywords from input.
- Refactored search logic to handle both simple and boolean search types based on user input.

Log: improve search capabilities by integrating boolean keyword support
- Updated the constant name from MAX_SEARCH_NUM_TOTAOL to MAX_SEARCH_NUM_TOTAL for clarity and consistency.

Log: fix typo in constant definition to ensure proper functionality
fd leak due to SearchEngine crated

Log: fix fd leak
- Added methods to create search options and queries for improved search accuracy.
- Implemented configuration for file name options based on search type.
- Refactored searchByDFMSearch to streamline the search process and handle results effectively.
- Updated FileSearchUtils to support type keywords for enhanced search capabilities.

Log: improve file name searching by integrating DFM search features
- Increased debounce timer interval from 100ms to 200ms for improved responsiveness.
- Modified debounce delay logic to set a shorter delay of 50ms for longer input (5 characters or more) to enhance search performance.

Log: optimize debounce mechanism for better search input handling
- Remove any references to 'anything'
- Integrate with DFM search interface

Log: improve AI searching by integrating DFM search features
- Deleted FSearch related source and header files to streamline the project.
- Updated CMake configuration to remove references to FSearch.
- Adjusted searcher implementation to focus on the new file name searcher.

Log: clean up project by removing obsolete FSearch integration
- Introduced a new enum ProcessResult to handle search outcomes more effectively.
- Updated processSearchResults method to process individual file results and return appropriate status.
- Enhanced searchByDFMSearch to handle search result validation and termination conditions.
- Increased maximum search results limit for improved performance.

Log: improve search result handling and processing logic in FileNameQuery
Update version

Log: update version
- Changed the assignment of info.keyword in FileSearchUtils::parseContent from a search helper method to directly using the content string.
- This adjustment simplifies the keyword extraction process when JSON parsing fails.

Log: streamline keyword handling in file search utility

Bug: https://pms.uniontech.com/bug-view-313835.html
- Adjusted debounce timing based on the byte length of the search text for improved responsiveness.
- Enhanced comments for clarity regarding the debounce delay adjustments.

Log: improve search input handling by refining debounce mechanism
- Added support for "folder" type in TypeCond and EngineCond to allow for more comprehensive search conditions.
- Updated logic in FileNameQuery to ensure proper handling of file types and extensions based on entity properties.

Log: improve search functionality by expanding file type recognition

Bug: https://pms.uniontech.com/bug-view-316609.html
- Replaced synchronous search execution with a callback-based approach to enhance responsiveness during file searches.
- Introduced a termination flag to manage search result processing more effectively.
- Streamlined the searchByDFMSearch method for better clarity and performance.

Log: optimize search processing by implementing callback mechanism in FileNameQuery
@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

@deepin-ci-robot
Copy link
Copy Markdown

deepin pr auto review

关键摘要:

  • 删除了与文件搜索相关的多个文件和类,包括fsearch相关的代码,这可能会影响文件搜索功能。
  • 删除了与anything相关的接口和类,这可能会影响使用anything进行文件搜索的功能。
  • 删除了与数据库操作相关的多个文件和类,包括databasebtreequery等,这可能会影响数据库的加载、保存和搜索功能。
  • 删除了与线程池相关的文件和类,包括fsearch_thread_pool,这可能会影响多线程搜索的性能。

是否建议立即修改:

建议立即修改的原因是,删除这些文件和类可能会影响搜索功能,特别是文件搜索功能,这是用户最常用的功能之一。如果这些功能被删除或损坏,用户可能会遇到搜索结果不完整或无法搜索的问题。因此,建议立即恢复这些文件和类,并确保它们能够正常工作。

@github-actions
Copy link
Copy Markdown

TAG Bot

TAG: 6.0.10
EXISTED: no
DISTRIBUTION: unstable

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 20, 2025

Reviewer's Guide

This PR replaces the previous deepin-anything and fsearch-based file search with a unified dfm6-search integration, refactors FileNameWorker and FileNameSearcher to use SearchOptions/SearchQuery APIs, removes legacy traversal and DBus code, introduces debounce logic in QueryController, and updates configuration and build scripts accordingly.

Sequence Diagram for QueryController Search Debouncing

sequenceDiagram
    actor User
    participant QC as QueryController
    participant QCP as QueryControllerPrivate
    participant DT as QTimer (m_debounceTimer)
    participant DGS as DaemonGrandSearchInterface

    User->>QC: types search text (onSearchTextChanged)
    activate QC
    QC->>DT: stop()
    QC->>QCP: m_pendingSearchText = new text
    QC->>DT: start(debounceDelay)
    deactivate QC

    DT-->>QCP: timeout()
    activate QCP
    QCP->>QCP: performSearch()
    QCP->>QCP: m_searchText = m_pendingSearchText
    QCP->>QCP: m_pendingSearchText.clear()
    QCP->>QCP: m_missionId = new UUID
    QCP->>DGS: Search(m_missionId, m_searchText)
    activate DGS
    DGS-->>QCP: return status
    deactivate DGS
    QCP->>QCP: m_keepAliveTimer.start()
    deactivate QCP
Loading

Class Diagram for FileNameSearcher Changes

classDiagram
    class FileNameSearcher {
        +FileNameSearcher(QObject* parent)
        +name() const QString
        +isActive() const bool
        +activate() bool
        +createWorker() const ProxyWorker*
        +action(const QString& action, const QString& item) bool
        -supportParallelSearch() const bool (removed)
    }
    FileNameSearcher ..> FileNameWorker : creates
Loading

File-Level Changes

Change Details Files
Replace deepin-anything/fsearch with dfm6-search in FileNameWorker
  • Remove ComDeepinAnythingInterface and searchUserPath implementation
  • Introduce createSearchOptions, createSearchQuery, processSearchResults, configureFileNameOptions methods
  • Drop m_supportParallelSearch flag and searchByAnything logic
  • Use engine->searchSync(query) via SearchFactory
searcher/file/filenameworker.cpp
searcher/file/filenameworker_p.h
searcher/file/filesearchutils.cpp
searcher/file/filesearchutils.h
Refactor FileNameSearcher to use DFM search API
  • Simplify isActive using DFMSEARCH::Global
  • Remove supportParallelSearch method
  • Update worker constructor signature
searcher/file/filenamesearcher.cpp
searcher/file/filenamesearcher.h
Implement debounce mechanism in QueryController
  • Add m_debounceTimer and m_pendingSearchText
  • Extract performSearch slot and delay search execution
  • Compute debounceDelay based on text length
  • Stop previous timers on text change
business/query/querycontroller.cpp
business/query/querycontroller_p.h
Clean up configuration and remove legacy search flags
  • Remove ENABLE_DEEPINANYTHING and ENABLE_FSEARCH guards
  • Simplify defaultSearcher and updateConfig1
  • Drop file-fsearch preferences
configuration/configer.cpp
Enhance FileSearchUtils for dfm-search
  • Add buildDFMSearchFileTypes for mapping groups to types
  • Add isPinyin to detect pinyin queries
  • Populate typeKeywords in parseContent
searcher/file/filesearchutils.cpp
searcher/file/filesearchutils.h
Rename and refactor semantic file query classes to FileNameQuery
  • Rename AnythingQuery to FileNameQuery
  • Implement DFM search in semantic database code
  • Update includes and class references
searcher/semantic/database/filenamequery.cpp
searcher/semantic/database/filenamequery_p.h
searcher/semantic/semanticworker.cpp
Update CMake and build scripts for dfm6-search
  • Add find_package(dfm6-search) and link dfm6-search
  • Remove 3rdparty fsearch and interfaces from sources
  • Use ENABLE_SEMANTIC for x86_64 only
CMakeLists.txt
Purge legacy fsearch and anything interface references
  • Remove fsearch 3rdparty directory
  • Drop GRANDSEARCH_CLASS_FILE_FSEARCH definitions
  • Clean global searchhelper, utils and searchergroup
global/builtinsearch.h
global/searchhelper.cpp
searcher/searchergroup.cpp
global/utils.cpp
searcher/searchergroup_p.h

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

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey @Johnson-zs - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 3 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

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.


initAnything();
// TODO (search): 搜索目录为user, by anything
m_searchPath = QDir::rootPath();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue: Update or remove outdated comment about search path

The comment still mentions user directories, but m_searchPath now uses QDir::rootPath(). Update it to match the code or adjust the path selection if needed.

Comment on lines +166 to +167
options.setSearchMethod(SearchMethod::Indexed);
return options;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (performance): Missing maxResults cap in semantic file-name queries

createSearchOptions doesn’t set maxResults; use the MAX_SEARCH_NUM_TOTAL limit to cap results.

Suggested change
options.setSearchMethod(SearchMethod::Indexed);
return options;
options.setSearchMethod(SearchMethod::Indexed);
options.setMaxResults(MAX_SEARCH_NUM_TOTAL);
return options;

searcher/file/filesearchutils.h
searcher/file/filesearchutils.cpp
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Consider adding comments to explain the revised file search logic.

Since the old fsearch vs. deepin-anything logic was replaced by dfm6-search and new ENABLE_SEMANTIC conditions, please add comments explaining the current file search process for maintainability.

Suggested change
# -------------------------------------------------------------------------
# File Search Module
# We now use the dfm6‐search engine as the core searcher. If ENABLE_SEMANTIC
# is turned ON, semantic-aware indexing and querying components are built in;
# otherwise only the basic path-based searcher is compiled.
#
# Legacy fsearch vs. deepin-anything logic has been replaced by this unified
# dfm6‐search implementation for maintainability and extensibility.
# -------------------------------------------------------------------------
searcher/extend/extendworker.cpp

}

bool FileNameWorkerPrivate::searchByDFMSearch()
{
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (complexity): Consider keeping the new helper methods and the refactored search flow, as they improve code clarity and maintainability.

No action needed – the refactoring has actually collapsed a huge amount of bespoke logic into a single, focused searchByDFMSearch() call with a clear flow (via the helper methods). The small, single‐use helpers here improve readability and separation of concerns rather than introduce unnecessary indirection.

@Johnson-zs
Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot
Copy link
Copy Markdown

deepin-bot Bot commented May 20, 2025

This pr force merged! (status: blocked)

@deepin-bot deepin-bot Bot merged commit e306380 into linuxdeepin:master May 20, 2025
8 of 10 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.

3 participants