Skip to content

Commit 4eb7d6d

Browse files
committed
chore: Bump to v0.8.0
1 parent 0489c7c commit 4eb7d6d

File tree

6 files changed

+51
-29
lines changed

6 files changed

+51
-29
lines changed

django_opensearch_dsl/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from .documents import Document # noqa
44
from .fields import * # noqa
55

6-
__version__ = "0.7.0"
6+
__version__ = "0.8.0"
77

88

99
def autodiscover() -> None:

django_opensearch_dsl/management/commands/opensearch.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ def add_arguments(self, parser: argparse.ArgumentParser) -> None:
274274
)
275275
subparser.set_defaults(func=self.__list_index)
276276
subparser.add_argument(
277+
"-u",
277278
"--using",
278279
type=connection,
279280
default=connection("default"),
@@ -288,6 +289,7 @@ def add_arguments(self, parser: argparse.ArgumentParser) -> None:
288289
)
289290
subparser.set_defaults(func=self._manage_index)
290291
subparser.add_argument(
292+
"-u",
291293
"--using",
292294
type=connection,
293295
default=connection("default"),
@@ -338,6 +340,7 @@ def add_arguments(self, parser: argparse.ArgumentParser) -> None:
338340
],
339341
)
340342
subparser.add_argument(
343+
"-u",
341344
"--using",
342345
type=connection,
343346
default=connection("default"),

docs/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog
22

3+
### 0.8.0 (2025-11-24)
4+
5+
* Add `--using` and `--database` options to the CLI to respectively specify which
6+
OpenSearch and database connection to use [#87](https://github.com/Codoc-os/django-opensearch-dsl/pull/87)).
7+
8+
**BREAKING CHANGES**:
9+
10+
* `django_opensearch_dsl.documents.Document.get_queryset` now take an optional `alias` argument to specify which
11+
database connection to use.
12+
* `django_opensearch_dsl.documents.Document.get_indexing_queryset` now take an optional `alias` argument to specify
13+
which database connection to use.
14+
315
### 0.7.0 (2025-04-11)
416

517
* `--refresh` and `--parallel` options of the CLI now default to the respective value of `OPENSEARCH_DSL_AUTO_REFRESH`

docs/document.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,12 @@ class EventDocument(Document):
139139

140140
---
141141

142-
* `def get_indexing_queryset(self, filter_=None, exclude=None, count=None, verbose=False, action=CommandAction.INDEX, stdout=sys.stdout)`
142+
* `def get_indexing_queryset(self, filter_=None, exclude=None, alias=None, count=None, verbose=False, action=CommandAction.INDEX, stdout=sys.stdout)`
143143

144144
* `filter_` (`Optional[Q]`) - Given to `get_queryset()`.
145145
* `exclude` (`Optional[Q]`) - Given to `get_queryset()`.
146146
* `count` (`Optional[int]`) - Given to `get_queryset()`.
147+
* `alias` (`Optional[str]`) - Given to `get_queryset()`.
147148
* `verbose` (`bool`) - If set to `True`, will display the progression of the action on standard output.
148149
* `action` (`CommandAction`) - Used by the verbose.
149150
* `stdout` (`io.FileIO`) - Standard output used when verbose is `True` (default to `stdout`).
@@ -165,9 +166,9 @@ class EventDocument(Document):
165166
class Django:
166167
model = Event
167168

168-
def get_indexing_queryset(self):
169+
def get_indexing_queryset(self, filter_=None, exclude=None, alias=None, count=None, verbose=False, action=CommandAction.INDEX, stdout=sys.stdout):
169170
"""Use iterator to chunk the queryset, discarding any verbose."""
170-
qs = self.get_queryset()
171+
qs = self.get_queryset(filter_=filter_, exclude=exclude, count=count).using(alias)
171172
return qs.iterator()
172173
```
173174

docs/management.md

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ positional arguments:
6060
INDEX Only manage the given indices.
6161
6262
optional arguments:
63-
-h, --help show this help message and exit
64-
--force Do not ask for confirmation.
65-
--ignore-error Do not stop on error.
63+
-h, --help show this help message and exit
64+
-u USING, --using USING Alias of the OpenSearch connection to use. Default to 'default'.
65+
--force Do not ask for confirmation.
66+
--ignore-error Do not stop on error.
6667
```
6768

6869
### Description
@@ -80,11 +81,15 @@ created/deleted. If no index is provided, the action is applied to all indices.
8081
Use the `--force` options to bypass the confirmation step, and use the `--ignore-error` option to not stop on error (such as
8182
trying to create an already created index).
8283

84+
You can specify which Opensearch connection to use with the `--using` option.
85+
8386
## `list` Subcommand
8487

8588
The `list` subcommand displays a summary of each index, indicated whether they are created or not, and the number of
8689
document indexed.
8790

91+
You can specify which Opensearch connection to use with the `--using` option.
92+
8893
Sample output :
8994

9095
```text
@@ -110,32 +115,33 @@ positional arguments:
110115
{index,delete,update}
111116
Whether you want to create, delete or rebuild the indices.
112117
113-
optional arguments:
118+
options:
114119
-h, --help show this help message and exit
115-
-f [FILTERS [FILTERS ...]], --filters [FILTERS [FILTERS ...]]
116-
Filter object in the queryset. Argument must be formatted as
117-
'[lookup]=[value]', e.g. 'document_date__gte=2020-05-21. The accepted
118-
value type are:
119-
- 'None' ('[lookup]=')
120-
- 'float' ('[lookup]=1.12')
121-
- 'int' ('[lookup]=23')
122-
- 'datetime.date' ('[lookup]=2020-10-08')
123-
- 'list' ('[lookup]=1,2,3,4') Value between comma ',' can be of any
124-
other accepted value type
125-
- 'str' ('[lookup]=week')
126-
Values that didn't match any type above will be interpreted as a str.
127-
The list of lookup function can be found here:
128-
https://docs.djangoproject.com/en/dev/ref/models/querysets/#field-lookups
129-
-e [EXCLUDES [EXCLUDES ...]], --excludes [EXCLUDES [EXCLUDES ...]]
130-
Exclude objects from the queryset. Argument must be formatted as
131-
'[lookup]=[value]', see '--filters' for more information.
120+
-u USING, --using USING
121+
Alias of the OpenSearch connection to use. Default to 'default'.
122+
-d DATABASE, --database DATABASE
123+
Nominates a database.
124+
-f [FILTERS ...], --filters [FILTERS ...]
125+
Filter object in the queryset. Argument must be formatted as '[lookup]=[value]', e.g. 'document_date__gte=2020-05-21.
126+
The accepted value type are:
127+
- 'None' ('[lookup]=')
128+
- 'float' ('[lookup]=1.12')
129+
- 'int' ('[lookup]=23')
130+
- 'datetime.date' ('[lookup]=2020-10-08')
131+
- 'list' ('[lookup]=1,2,3,4') Value between comma ',' can be of any other accepted value type
132+
- 'str' ('[lookup]=week') Value that didn't match any type above will be interpreted as a str
133+
The list of lookup function can be found here: https://docs.djangoproject.com/en/dev/ref/models/querysets/#field-lookups
134+
-e [EXCLUDES ...], --excludes [EXCLUDES ...]
135+
Exclude objects from the queryset. Argument must be formatted as '[lookup]=[value]', see '--filters' for more information
132136
--force Do not ask for confirmation.
133-
-i [INDICES [INDICES ...]], --indices [INDICES [INDICES ...]]
137+
-i [INDICES ...], --indices [INDICES ...]
134138
Only update documents on the given indices.
135139
-c COUNT, --count COUNT
136140
Update at most COUNT objects (0 to index everything).
137-
-p, --parallel Parallelize the communication with Opensearch.
138-
-r, --refresh Make operations performed on the indices immediately available for search.
141+
-r, --refresh Whether the operations performed on the indices are immediately available for search. Default to `OPENSEARCH_DSL_AUTO_REFRESH` (which default to `False`)
142+
--no-refresh
143+
-p, --parallel Whether to run bulk operations in parallel. Default to `OPENSEARCH_DSL_PARALLEL` (which default to `False`)
144+
--no-parallel
139145
-m, --missing When used with 'index' action, only index documents not indexed yet.
140146
```
141147

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
setup(
4040
name='django-opensearch-dsl',
41-
version='0.7.0',
41+
version='0.8.0',
4242
description="""Wrapper around opensearch-py for django models""",
4343
long_description=LONG_DESCRIPTION,
4444
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)