mirror of
https://github.com/suitenumerique/docs.git
synced 2026-08-22 07:32:23 +02:00
## 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 ](https://waffle.readthedocs.io/en/stable/types/flag.html). - [x] install waffle and activate the default app in settings. - [x] implement `_get_search_type` in `DocumentViewset` to determine which search type (title, hybrid or full-text) to use. - [x] 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: - [x] I have read and followed the [contributing guidelines](https://github.com/suitenumerique/docs/blob/main/CONTRIBUTING.md) - [x] I have read and agreed to the [Code of Conduct](https://github.com/suitenumerique/docs/blob/main/CODE_OF_CONDUCT.md) - [x] I have signed off my commits with `git commit --signoff` (DCO compliance) - [x] I have signed my commits with my SSH or GPG key (`git commit -S`) - [x] My commit messages follow the required format: `<gitmoji>(type) title description` - [x] I have added a changelog entry under `## [Unreleased]` section (if noticeable change) - [x] I have added corresponding tests for new features or bug fixes (if applicable) --------- Signed-off-by: charles <charles.englebert@protonmail.com>
53 lines
2.0 KiB
Markdown
53 lines
2.0 KiB
Markdown
# Setup Find search for Docs
|
|
|
|
This configuration will enable Find searches:
|
|
- Each save on **core.Document** or **core.DocumentAccess** will trigger the indexing of the document into Find.
|
|
- The `api/v1.0/documents/search/` will be used as proxy for searching documents from Find indexes.
|
|
|
|
## Create an index service for Docs
|
|
|
|
Configure a **Service** for Docs application with these settings
|
|
|
|
- **Name**: `docs`<br>_request.auth.name of the Docs application._
|
|
- **Client id**: `impress`<br>_Name of the token audience or client_id of the Docs application._
|
|
|
|
See [how-to-use-indexer.md](how-to-use-indexer.md) for details.
|
|
|
|
## Configure settings of Docs
|
|
|
|
Find uses a service provider authentication for indexing and a OIDC authentication for searching.
|
|
|
|
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.
|
|
SEARCH_INDEXER_QUERY_LIMIT=50 # Maximum number of results expected from the search endpoint
|
|
|
|
INDEXING_URL="http://find:8000/api/v1.0/documents/index/"
|
|
SEARCH_URL="http://find:8000/api/v1.0/documents/search/"
|
|
|
|
# Service provider authentication
|
|
SEARCH_INDEXER_SECRET="find-api-key-for-docs-with-exactly-50-chars-length"
|
|
|
|
# OIDC authentication
|
|
OIDC_STORE_ACCESS_TOKEN=True # Store the access token in the session
|
|
OIDC_STORE_REFRESH_TOKEN=True # Store the encrypted refresh token in the session
|
|
OIDC_STORE_REFRESH_TOKEN_KEY="<your-32-byte-encryption-key==>"
|
|
```
|
|
|
|
`OIDC_STORE_REFRESH_TOKEN_KEY` must be a valid Fernet key (32 url-safe base64-encoded bytes).
|
|
To create one, use the `bin/generate-oidc-store-refresh-token-key.sh` command.
|
|
|
|
## Feature flags
|
|
|
|
The Find search integration is controlled by two feature flags:
|
|
- `flag_find_hybrid_search`
|
|
- `flag_find_full_text_search`
|
|
|
|
If a user has both flags activated the most advanced search is used (hybrid > full text > title).
|
|
A user with no flag will default to the basic title search.
|
|
|
|
Feature flags can be activated through the admin interface.
|