Skip to content

Search feature flags#1897

Merged
mascarpon3 merged 4 commits intomainfrom
search-feature-flags
Mar 18, 2026
Merged

Search feature flags#1897
mascarpon3 merged 4 commits intomainfrom
search-feature-flags

Conversation

@mascarpon3
Copy link
Contributor

@mascarpon3 mascarpon3 commented Feb 19, 2026

Purpose

For beta testing purposes we need to be able to activate Find hybrid search to some users, Find full-text search to some others and leave remaining users on basic DRF title search.

Proposal

The solution proposed is based on django-waffle .

  • install waffle and activate the default app in settings.
  • implement _get_search_type in DocumentViewset to determine which search type (title, hybrid or full-text) to use.
  • send the search_type in the search query.

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)

@mascarpon3 mascarpon3 changed the base branch from main to integrate-find February 19, 2026 10:11
@mascarpon3 mascarpon3 force-pushed the search-feature-flags branch 6 times, most recently from 27f10c6 to 30b145d Compare February 19, 2026 13:11
@github-actions
Copy link

Size Change: +210 B (+0.01%)

Total Size: 4.2 MB

Filename Size Change
apps/impress/out/_next/static/856d65ea/_buildManifest.js 830 B +830 B (new file) 🆕
apps/impress/out/_next/static/898af1f7/_buildManifest.js 0 B -831 B (removed) 🏆

compressed-size-action

@mascarpon3 mascarpon3 force-pushed the search-feature-flags branch 5 times, most recently from c02659a to 0112981 Compare February 19, 2026 16:25
@lunika lunika self-requested a review February 19, 2026 16:55
@mascarpon3 mascarpon3 requested a review from Copilot February 19, 2026 17:08
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

This PR implements feature flags for the search functionality using django-waffle, allowing gradual rollout of Find hybrid search and full-text search capabilities to different user groups. The implementation introduces a three-tier search system where users can be assigned different search capabilities through feature flags, with automatic fallback to simpler search methods when needed.

Changes:

  • Added django-waffle dependency and integrated it into Django middleware and installed apps
  • Implemented SearchType and FeatureFlag enums to define search types and feature flags
  • Updated search indexer methods to accept and pass search_type parameter to the Find API
  • Added _get_search_type() method in DocumentViewSet to determine search type based on user's feature flags

Reviewed changes

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

Show a summary per file
File Description
src/backend/pyproject.toml Added django-waffle 5.0.0 dependency
src/backend/impress/settings.py Configured WaffleMiddleware and waffle app
src/backend/core/enums.py Added SearchType and FeatureFlag enums
src/backend/core/services/search_indexers.py Updated search methods with search_type parameter and type hints
src/backend/core/api/viewsets.py Implemented feature flag-based search type selection logic
src/backend/core/tests/test_services_search_indexers.py Updated tests to use tuple instead of list for visited documents
src/backend/core/tests/test_services_find_document_indexer.py Updated test to include search_type parameter
src/backend/core/tests/documents/test_api_documents_search_feature_flag.py New comprehensive test for feature flag behavior
src/backend/core/tests/documents/test_api_documents_search.py Added fixture to enable hybrid search flag for existing tests
docs/search.md Documented feature flag usage and priority
CHANGELOG.md Added entry for new feature

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

self,
q: str,
token: str,
visited: tuple[()] = (),
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

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

The type hint tuple[()] is incorrect syntax. This should be tuple[str, ...] to match the parent class signature in BaseDocumentIndexer and the actual return type of get_visited_document_ids_of. The current syntax is not valid Python type hint syntax for a tuple of strings.

Suggested change
visited: tuple[()] = (),
visited: tuple[str, ...] = (),

Copilot uses AI. Check for mistakes.
Comment on lines +212 to +213
search_type:
hybrid or full-text search
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

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

The docstring for search_type parameter should include the type annotation (e.g., "search_type (SearchType, optional):") and be more descriptive. It should mention that it can be SearchType.HYBRID or SearchType.FULL_TEXT, and clarify what happens when it's None. Following the pattern of other parameters in this docstring would improve consistency.

Suggested change
search_type:
hybrid or full-text search
search_type (SearchType, optional):
Type of search to perform. Can be SearchType.HYBRID or SearchType.FULL_TEXT.
If None, the backend search service will use its default search behavior.

Copilot uses AI. Check for mistakes.
Copy link
Member

@lunika lunika left a comment

Choose a reason for hiding this comment

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

There is a typo in the tests, also spotted by Copilot. Otherwise everything is ok for me

@mascarpon3 mascarpon3 force-pushed the integrate-find branch 3 times, most recently from 36b137f to 8c48a47 Compare February 26, 2026 15:33
@mascarpon3 mascarpon3 force-pushed the integrate-find branch 7 times, most recently from 5aa4ce1 to a88264a Compare March 11, 2026 15:19
@mascarpon3 mascarpon3 force-pushed the integrate-find branch 2 times, most recently from bf53dd3 to 84de00c Compare March 16, 2026 14:04
@AntoLC AntoLC force-pushed the integrate-find branch 2 times, most recently from d2dbf2a to 702cd2f Compare March 16, 2026 15:10
@mascarpon3 mascarpon3 force-pushed the integrate-find branch 8 times, most recently from 9168ef3 to 521916c Compare March 17, 2026 15:51
Base automatically changed from integrate-find to main March 17, 2026 16:32
@mascarpon3 mascarpon3 force-pushed the search-feature-flags branch 2 times, most recently from 944f3f5 to 64ac477 Compare March 17, 2026 16:40
@mascarpon3 mascarpon3 marked this pull request as ready for review March 17, 2026 16:41
@mascarpon3 mascarpon3 force-pushed the search-feature-flags branch 5 times, most recently from 218fc25 to 5f6d884 Compare March 18, 2026 13:46
Waffle has never been used in DOcs. it must be installed.
the waffle app and middleware must also be activated in django settings.

Signed-off-by: charles <charles.englebert@protonmail.com>
For beta testing purposes we need to be able to activate
Find hybrid search to some users, Find full-text search
to some others and leave remaining users on basic DRF
title search.

Signed-off-by: charles <charles.englebert@protonmail.com>
Documentation is a way to document things

Signed-off-by: charles <charles.englebert@protonmail.com>
I add a separate test file for feature flags
so the feature flags do not interact with
the testings of other feature

Signed-off-by: charles <charles.englebert@protonmail.com>
@mascarpon3 mascarpon3 force-pushed the search-feature-flags branch from 5f6d884 to 4a74177 Compare March 18, 2026 14:35
@mascarpon3 mascarpon3 enabled auto-merge (squash) March 18, 2026 15:03
@mascarpon3 mascarpon3 merged commit 4f8aea7 into main Mar 18, 2026
26 of 27 checks passed
@mascarpon3 mascarpon3 deleted the search-feature-flags branch March 18, 2026 15:04
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