Skip to content

Integrate find#1834

Open
mascarpon3 wants to merge 19 commits intomainfrom
integrate-find
Open

Integrate find#1834
mascarpon3 wants to merge 19 commits intomainfrom
integrate-find

Conversation

@mascarpon3
Copy link

@mascarpon3 mascarpon3 commented Jan 27, 2026

Purpose

integrate Find to Docs

Proposal

  • add a useSeachDocs hook in charged of calling the search endpoint.
  • add a optional path param to the search route. This param represents the parent document path in case of a sub-documents (descendants) search.
  • return Indexer results directly without DB calls to retrieve the Document objects. All informations necessary for display are indexed in Find. We can skip the DB calls and improve performance.
  • remove pagination logic in the Indexer. Removing the DB calls also removes the DRF queryset object which handles the pagination. Also we consider pagination not to be necessary for search v1.
  • refactor react DocSearchContent components. DocSearchContent and DocSearchSubContent are now merged a unique component handling all search scenarios and relying on the unique search route.
  • remove the document/<document_id>/descendants route. This route is not used anymore. The logic of finding the descendants are moved to the internal _list_descendants method. This method is based on the parent path instead of the parent id which has some consequence about the user access management. Relying on the path prevents the use of the self.get_object() method which used to handle the user access logic.
  • handle language extension in title field. Find returns titles with a language extension (ex: { title.fr: "rapport d'activité" } au lieu de { "title": "rapport d'activité" }
  • add a common.test file to allow running the tests without docker
  • rename SearchIndexer -> FindDocumentIndexer. This class has to do with Find in particular and the convention is more coherent with BaseDocumentIndexer
  • update the environment variables to activate the FindDocumentIndexer.

External contributions

Thank you for your contribution! 🎉

Please ensure the following items are checked before submitting your pull request:

  • I have read and followed the contributing guidelines
  • I have read and agreed to the Code of Conduct
  • I have signed off my commits with git commit --signoff (DCO compliance)
  • I have signed my commits with my SSH or GPG key (git commit -S)
  • My commit messages follow the required format: <gitmoji>(type) title description
  • I have added a changelog entry under ## [Unreleased] section (if noticeable change)
  • I have added corresponding tests for new features or bug fixes (if applicable)

Copy link

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.

Pull request overview

Integrates Find-powered document search into the Docs UI/API, removing the previous infinite-scroll pagination approach and adding optional path-based scoping for “current doc” searches.

Changes:

  • Frontend doc search now calls a dedicated documents/search/ endpoint via a new useSearchDocs hook and removes infinite pagination.
  • Backend search endpoint proxies to the configured Find indexer, adds optional path filtering, and returns a simplified {count, results} response.
  • Development environment variables are updated to enable the indexer and store OIDC tokens in session.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/frontend/apps/impress/src/features/docs/doc-search/components/DocSearchSubPageContent.tsx Switches “current doc” search to Find-backed useSearchDocs with path scoping.
src/frontend/apps/impress/src/features/docs/doc-search/components/DocSearchModal.tsx Removes legacy filter props from search content components (target selection remains).
src/frontend/apps/impress/src/features/docs/doc-search/components/DocSearchContent.tsx Replaces infinite query + InView pagination with useSearchDocs.
src/frontend/apps/impress/src/features/docs/doc-management/api/useDocs.tsx Removes title query param support from the list-docs hook params builder.
src/frontend/apps/impress/src/features/docs/doc-management/api/searchDocs.tsx Adds new React Query hook + request param construction for Find search endpoint.
src/backend/core/services/search_indexers.py Extends indexer search call to accept a path filter and forwards it to Find.
src/backend/core/api/viewsets.py Refactors search logic, removes pagination for Find-backed results, and adds path plumbing.
src/backend/core/api/serializers.py Updates search query serializer to drop pagination params and add optional path.
env.d/development/common Enables token storage and enables the indexer in dev env.
docs/search.md Minor wording correction in search configuration docs.
CHANGELOG.md Adds an “integrate Find search” entry under Unreleased.
Comments suppressed due to low confidence (1)

src/backend/core/api/serializers.py:985

  • path is not trimmed, so a value like ' ' will pass validation even though it’s effectively blank. To match q behavior and avoid confusing/ineffective filters, set trim_whitespace=True for path (and keep allow_blank=False).
    q = serializers.CharField(required=True, allow_blank=False, trim_whitespace=True)
    path = serializers.CharField(required=False, allow_blank=False)


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

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 encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link

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.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (3)

src/backend/core/api/viewsets.py:1267

  • _search_simple still returns a paginated response (get_response_for_queryset), while the frontend search hook no longer sends pagination params. If the indexer is not configured, next will be non-null and the frontend infinite-query will keep refetching page 1 (duplicates / potential loop). Consider making the fallback path return a non-paginated response consistent with _search (and apply the optional path filter there too).
        indexer = get_document_indexer()
        if indexer:
            return self._search_with_indexer(indexer, request, params=params)

        # The indexer is not configured, we fallback on a simple icontains filter by the
        # model field 'title'.
        return self._search_simple(request, text=params.validated_data["q"])

src/backend/core/api/serializers.py:984

  • SearchDocumentSerializer removed page/page_size and added path, but there are existing backend tests that assert pagination validation and behavior for /documents/search/ (e.g. core/tests/documents/test_api_documents_search.py::test_api_documents_search_pagination and ..._invalid_params). These tests will need to be updated/removed, and new assertions should cover the path filter behavior.
    q = serializers.CharField(required=True, allow_blank=False, trim_whitespace=True)
    page_size = serializers.IntegerField(

docs/search.md:22

  • The configuration example still references core.services.search_indexers.FindDocumentIndexer, but there is no such class in the backend (the implemented class is SearchIndexer). Update the docs snippet to use the correct class path so users can enable search successfully.
Add those Django settings to the Docs application to enable the feature.

```shell
SEARCH_INDEXER_CLASS="core.services.search_indexers.FindDocumentIndexer"
SEARCH_INDEXER_COUNTDOWN=10  # Debounce delay in seconds for the indexer calls.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

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.

Pull request overview

Copilot reviewed 28 out of 28 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (3)

src/backend/core/api/viewsets.py:1180

  • This change removes the GET /documents/{id}/descendants/ action entirely (tests have been migrated to GET /documents/search/?path=...). If external clients rely on the descendants endpoint, this is a breaking API change and should be called out explicitly (and/or handled via a backward-compatible alias/deprecation path). At minimum, consider updating the API documentation/changelog to mention the removal of the descendants route and its replacement.
    @drf.decorators.action(detail=False, methods=["get"], url_path="search")
    @method_decorator(refresh_oidc_access_token)
    def search(self, request, *args, **kwargs):
        """
        Returns a DRF response containing the filtered, annotated and ordered document list.

        Applies filtering based on request parameter 'q' from `SearchDocumentSerializer`.
        Depending of the configuration it can be:
         - A fulltext search through the opensearch indexation app "find" if the backend is
           enabled (see SEARCH_INDEXER_CLASS)
         - A filtering by the model field 'title'.

        The ordering is always by the most recent first.

src/backend/core/tests/documents/test_api_documents_search_descendants.py:283

  • Variable _grand_child is not used.
    src/backend/core/tests/documents/test_api_documents_search_descendants.py:521
  • Variable _grand_child is not used.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mascarpon3 mascarpon3 marked this pull request as ready for review February 4, 2026 16:37
frontend is now calling the search endpoint
I am adding the path params to the search endpoint.
This allows searching in subdocs.
I did a mistake in the env variables file
pagination is no longer supported by Find
handle filtering on sub-docs
I am fixing a bug about dupplicated documents
I update the changelog
I am removing dead code
I am fixing various things
I am adding this file containing the
variables needed to run test without
docker

Signed-off-by: charles <charles.englebert@protonmail.com>
I remove DB access

Signed-off-by: charles <charles.englebert@protonmail.com>
I am adding a title_search with all the logic

Signed-off-by: charles <charles.englebert@protonmail.com>
The new logic allows to remove
 DocSearchSubPageContent.tsx

Signed-off-by: charles <charles.englebert@protonmail.com>
I rename SearchIndexer to FindeDocumentIndexer
I am adding a simple test about the search method and search api

Signed-off-by: charles <charles.englebert@protonmail.com>
I am fixing the _list_descendants logic
based on the parent path istead of the
parent id.

Signed-off-by: charles <charles.englebert@protonmail.com>
I am fixing various things

Signed-off-by: charles <charles.englebert@protonmail.com>
I am improving useSearchDocs by removing the q overwriting
and circular imports
@github-actions
Copy link

github-actions bot commented Feb 4, 2026

Size Change: -132 B (0%)

Total Size: 4.2 MB

Filename Size Change
apps/impress/out/_next/static/255f56a9/_buildManifest.js 0 B -831 B (removed) 🏆
apps/impress/out/_next/static/830f310f/_buildManifest.js 831 B +831 B (new file) 🆕

compressed-size-action

I am fixing various small things

Signed-off-by: charles <charles.englebert@protonmail.com>
@suitenumerique suitenumerique deleted a comment from Copilot AI Feb 5, 2026
@suitenumerique suitenumerique deleted a comment from Copilot AI Feb 5, 2026
@suitenumerique suitenumerique deleted a comment from Copilot AI Feb 5, 2026
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.

1 participant