Skip to content

Commit c51a8de

Browse files
committed
📝(backend) add fulltext search documentation
Add documentation for env & Find+Docs configuration in dev mode Signed-off-by: Fabre Florian <ffabre@hybird.org>
1 parent 51195c7 commit c51a8de

File tree

5 files changed

+58
-0
lines changed

5 files changed

+58
-0
lines changed

docs/architecture.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ flowchart TD
1212
Back --> DB("Database (PostgreSQL)")
1313
Back <--> Celery --> DB
1414
Back ----> S3("Minio (S3)")
15+
Back -- REST API --> Find
1516
```
1617

1718
### Architecture decision records

docs/env.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ These are the environment variables you can set for the `impress-backend` contai
9393
| OIDC_USERINFO_SHORTNAME_FIELD | OIDC token claims to create shortname | first_name |
9494
| POSTHOG_KEY | Posthog key for analytics | |
9595
| REDIS_URL | Cache url | redis://redis:6379/1 |
96+
| SEARCH_INDEXER_CLASS | Class of the backend for document indexation & search | |
97+
| SEARCH_INDEXER_BATCH_SIZE | Size of each batch for indexation of all documents | 100000 |
98+
| SEARCH_INDEXER_COUNTDOWN | Minimum debounce delay of indexation jobs (in seconds) | 1 |
99+
| SEARCH_INDEXER_URL | Find application endpoint for indexation | |
100+
| SEARCH_INDEXER_SECRET | Token for indexation queries | |
101+
| SEARCH_INDEXER_QUERY_URL | Find application endpoint for search | |
96102
| SENTRY_DSN | Sentry host | |
97103
| SESSION_COOKIE_AGE | duration of the cookie session | 60*60*12 |
98104
| SPECTACULAR_SETTINGS_ENABLE_DJANGO_DEPLOY_CHECK | | false |

docs/search.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Setup the Find search for Impress
2+
3+
This configuration will enable the fulltext search feature for Docs :
4+
- Each save on **core.Document** or **core.DocumentAccess** will trigger the indexer
5+
- The `api/v1.0/documents/search/` will work as a proxy with the Find API for fulltext search.
6+
7+
## Create an index service for Docs
8+
9+
Configure a **Service** for Docs application with these settings
10+
11+
- **Name**: `docs`<br>_request.auth.name of the Docs application._
12+
- **Client id**: `impress`<br>_Name of the token audience or client_id of the Docs application._
13+
14+
See [how-to-use-indexer.md](how-to-use-indexer.md) for details.
15+
16+
## Configure settings of Docs
17+
18+
Add those Django settings the Docs application to enable the feature.
19+
20+
```shell
21+
SEARCH_INDEXER_CLASS="core.services.search_indexers.FindDocumentIndexer"
22+
SEARCH_INDEXER_COUNTDOWN=10 # Debounce delay in seconds for the indexer calls.
23+
24+
# The token from service "docs" of Find application (development).
25+
SEARCH_INDEXER_SECRET="find-api-key-for-docs-with-exactly-50-chars-length"
26+
SEARCH_INDEXER_URL="http://find:8000/api/v1.0/documents/index/"
27+
28+
# Search endpoint. Uses the OIDC token for authentication
29+
SEARCH_INDEXER_QUERY_URL="http://find:8000/api/v1.0/documents/search/"
30+
```
31+
32+
We also need to enable the **OIDC Token** refresh or the authentication will fail quickly.
33+
34+
```shell
35+
# Store OIDC tokens in the session
36+
OIDC_STORE_ACCESS_TOKEN = True # Store the access token in the session
37+
OIDC_STORE_REFRESH_TOKEN = True # Store the encrypted refresh token in the session
38+
OIDC_STORE_REFRESH_TOKEN_KEY = "your-32-byte-encryption-key==" # Must be a valid Fernet key (32 url-safe base64-encoded bytes)
39+
```

docs/system-requirements.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,17 @@ Production deployments differ significantly from development environments. The t
9797
| 5433 | PostgreSQL (Keycloak) |
9898
| 1081 | MailCatcher |
9999

100+
**With fulltext search service**
101+
102+
| Port | Service |
103+
| --------- | --------------------- |
104+
| 8081 | Find (Django) |
105+
| 9200 | Opensearch |
106+
| 9600 | Opensearch admin |
107+
| 5601 | Opensearch dashboard |
108+
| 25432 | PostgreSQL (Find) |
109+
110+
100111
## 6. Sizing Guidelines
101112

102113
**RAM** – start at 8 GB dev / 16 GB staging / 32 GB prod. Postgres and Keycloak are the first to OOM; scale them first.

env.d/development/common

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ OIDC_OP_JWKS_ENDPOINT=http://nginx:8083/realms/impress/protocol/openid-connect/c
3636
OIDC_OP_AUTHORIZATION_ENDPOINT=http://localhost:8083/realms/impress/protocol/openid-connect/auth
3737
OIDC_OP_TOKEN_ENDPOINT=http://nginx:8083/realms/impress/protocol/openid-connect/token
3838
OIDC_OP_USER_ENDPOINT=http://nginx:8083/realms/impress/protocol/openid-connect/userinfo
39+
OIDC_OP_INTROSPECTION_ENDPOINT=http://nginx:8083/realms/impress/protocol/openid-connect/token/introspect
3940

4041
OIDC_RP_CLIENT_ID=impress
4142
OIDC_RP_CLIENT_SECRET=ThisIsAnExampleKeyForDevPurposeOnly

0 commit comments

Comments
 (0)