mirror of
https://github.com/suitenumerique/docs.git
synced 2026-04-25 17:15:01 +02:00
✨(backend) update make index command
the index command has new params to add on the make command Signed-off-by: charles <charles.englebert@protonmail.com>
This commit is contained in:
2
Makefile
2
Makefile
@@ -260,7 +260,7 @@ demo: ## flush db then create a demo for load testing purpose
|
|||||||
.PHONY: demo
|
.PHONY: demo
|
||||||
|
|
||||||
index: ## index all documents to remote search
|
index: ## index all documents to remote search
|
||||||
@$(MANAGE) index
|
@$(MANAGE) index $(args)
|
||||||
.PHONY: index
|
.PHONY: index
|
||||||
|
|
||||||
# Nota bene: Black should come after isort just in case they don't agree...
|
# Nota bene: Black should come after isort just in case they don't agree...
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
The `index` management command is used to index documents to the remote search indexer.
|
The `index` management command is used to index documents to the remote search indexer.
|
||||||
|
|
||||||
It sends an asynchronous task to the Celery worker.
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Make Command
|
### Make Command
|
||||||
@@ -13,12 +11,8 @@ It sends an asynchronous task to the Celery worker.
|
|||||||
make index
|
make index
|
||||||
|
|
||||||
# With custom parameters
|
# With custom parameters
|
||||||
make index batch_size=200 lower_time_bound="2024-01-01T00:00:00"
|
make index args="--batch-size 100 --lower-time-bound 2024-01-01T00:00:00 --upper-time-bound 2026-01-01T00:00:00"
|
||||||
|
|
||||||
# All parameters
|
|
||||||
make index batch_size=200 \
|
|
||||||
lower_time_bound="2024-01-01T00:00:00" \
|
|
||||||
upper_time_bound="2024-01-31T23:59:59" \
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Command line
|
### Command line
|
||||||
@@ -28,16 +22,16 @@ python manage.py index \
|
|||||||
--lower-time-bound "2024-01-01T00:00:00" \
|
--lower-time-bound "2024-01-01T00:00:00" \
|
||||||
--upper-time-bound "2024-01-31T23:59:59" \
|
--upper-time-bound "2024-01-31T23:59:59" \
|
||||||
--batch-size 200 \
|
--batch-size 200 \
|
||||||
--async_mode
|
--async
|
||||||
```
|
```
|
||||||
|
|
||||||
### Django Admin
|
### Django Admin
|
||||||
|
|
||||||
The command is available in the Django admin interface:
|
The command is available in the Django admin interface:
|
||||||
|
|
||||||
1. Go to `/admin/core/run-indexing/`, you arrive at the "Run Indexing Command" page
|
1. Go to `/admin/run-indexing/`, you arrive at the "Run Indexing Command" page
|
||||||
3. Fill in the form with the desired parameters
|
2. Fill in the form with the desired parameters
|
||||||
4. Click **"Run Indexing Command"**
|
3. Click **"Run Indexing Command"**
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
|
|
||||||
@@ -58,12 +52,12 @@ The command is available in the Django admin interface:
|
|||||||
- **default:** `None`
|
- **default:** `None`
|
||||||
- **description:** Only documents updated before this date will be indexed.
|
- **description:** Only documents updated before this date will be indexed.
|
||||||
|
|
||||||
## `--async_mode`
|
### `--async`
|
||||||
- **type:** Boolean flag
|
- **type:** Boolean flag
|
||||||
- **default:** `False`
|
- **default:** `False`
|
||||||
- **description:** Runs asynchronously is async_mode==True.
|
+- **description:** When set, dispatches the indexing job to a Celery worker instead of running it synchronously.
|
||||||
|
|
||||||
## Crash Safe Mode
|
## Crash Safe Mode
|
||||||
|
|
||||||
The command saves the updated.at of the last document of each successful batch into the `bulk-indexer-checkpoint` cache variable.
|
The command saves the `updated_at` of the last document of each successful batch into the `bulk-indexer-checkpoint` cache variable.
|
||||||
If the process crashes, this value can be used as `lower-time-bound` to resume from the last successfully indexed document.
|
If the process crashes, this value can be used as `lower-time-bound` to resume from the last successfully indexed document.
|
||||||
|
|||||||
Reference in New Issue
Block a user