diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 308fe289..3cf068db 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: test +name: test elasticsearch on: [push, pull_request] @@ -9,28 +9,9 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.6', '3.7', '3.8', '3.9'] + python-version: ['3.7', '3.8', '3.9', '3.10'] es-version: ['6', '7'] include: - - python-version: 3.6 - tox_env: py36-django22-elasticsearch7 - requirements: django_2_2 - - python-version: 3.6 - tox_env: py36-django31-elasticsearch7 - requirements: django_3_1 - - python-version: 3.6 - tox_env: py36-django32-elasticsearch7 - requirements: django_3_2 - - - python-version: 3.6 - tox_env: py36-django22-elasticsearch6 - requirements: django_2_2 - - python-version: 3.6 - tox_env: py36-django31-elasticsearch6 - requirements: django_3_1 - - python-version: 3.6 - tox_env: py36-django32-elasticsearch6 - requirements: django_3_2 - python-version: 3.7 tox_env: py37-django22-elasticsearch7 @@ -92,6 +73,26 @@ jobs: tox_env: py39-django32-elasticsearch6 requirements: django_3_2 + - python-version: '3.10' + tox_env: py310-django22-elasticsearch7 + requirements: django_2_2 + - python-version: '3.10' + tox_env: py310-django31-elasticsearch7 + requirements: django_3_1 + - python-version: '3.10' + tox_env: py310-django32-elasticsearch7 + requirements: django_3_2 + + - python-version: '3.10' + tox_env: py310-django22-elasticsearch6 + requirements: django_2_2 + - python-version: '3.10' + tox_env: py310-django31-elasticsearch6 + requirements: django_3_1 + - python-version: '3.10' + tox_env: py310-django32-elasticsearch6 + requirements: django_3_2 + services: elasticsearch: image: bitnami/elasticsearch:${{ matrix.es-version }} diff --git a/.github/workflows/test_opensearch.yml b/.github/workflows/test_opensearch.yml new file mode 100644 index 00000000..197cfbba --- /dev/null +++ b/.github/workflows/test_opensearch.yml @@ -0,0 +1,158 @@ +name: test opensearch + +on: [push, pull_request] + +jobs: + test: + name: Test + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ['3.7', '3.8', '3.9', '3.10'] + es-version: ['1', '2'] + include: + + - python-version: 3.7 + tox_env: py37-django22-opensearch2 + requirements: django_2_2 + - python-version: 3.7 + tox_env: py37-django31-opensearch2 + requirements: django_3_1 + - python-version: 3.7 + tox_env: py37-django32-opensearch2 + requirements: django_3_2 + + - python-version: 3.7 + tox_env: py37-django22-opensearch1 + requirements: django_2_2 + - python-version: 3.7 + tox_env: py37-django31-opensearch1 + requirements: django_3_1 + - python-version: 3.7 + tox_env: py37-django32-opensearch1 + requirements: django_3_2 + + - python-version: 3.8 + tox_env: py38-django22-opensearch2 + requirements: django_2_2 + - python-version: 3.8 + tox_env: py38-django31-opensearch2 + requirements: django_3_1 + - python-version: 3.8 + tox_env: py38-django32-opensearch2 + requirements: django_3_2 + + - python-version: 3.8 + tox_env: py38-django22-opensearch1 + requirements: django_2_2 + - python-version: 3.8 + tox_env: py38-django31-opensearch1 + requirements: django_3_1 + - python-version: 3.8 + tox_env: py38-django32-opensearch1 + requirements: django_3_2 + + - python-version: 3.9 + tox_env: py39-django22-opensearch2 + requirements: django_2_2 + - python-version: 3.9 + tox_env: py39-django31-opensearch2 + requirements: django_3_1 + - python-version: 3.9 + tox_env: py39-django32-opensearch2 + requirements: django_3_2 + + - python-version: 3.9 + tox_env: py39-django22-opensearch1 + requirements: django_2_2 + - python-version: 3.9 + tox_env: py39-django31-opensearch1 + requirements: django_3_1 + - python-version: 3.9 + tox_env: py39-django32-opensearch1 + requirements: django_3_2 + + - python-version: '3.10' + tox_env: py310-django22-opensearch2 + requirements: django_2_2 + - python-version: '3.10' + tox_env: py310-django31-opensearch2 + requirements: django_3_1 + - python-version: '3.10' + tox_env: py310-django32-opensearch2 + requirements: django_3_2 + + - python-version: '3.10' + tox_env: py310-django22-opensearch1 + requirements: django_2_2 + - python-version: '3.10' + tox_env: py310-django31-opensearch1 + requirements: django_3_1 + - python-version: '3.10' + tox_env: py310-django32-opensearch1 + requirements: django_3_2 + + services: + elasticsearch: + image: opensearchproject/opensearch:${{ matrix.es-version }} + ports: + - 9200:9200 + options: >- + -e="http.host=0.0.0.0" + -e="transport.host=127.0.0.1" + -e="discovery.type=single-node" + -e="plugins.security.disabled=true" + --health-cmd="curl http://localhost:9200/_cluster/health" + --health-interval=10s + --health-timeout=5s + --health-retries=10 + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools wheel + pip install pip-tools + python -m pip install tox + echo "examples/requirements/${{ matrix.requirements }}.in" + pip-compile examples/requirements/${{ matrix.requirements }}.in + echo "examples/requirements/opensearch_1x.in" + pip-compile examples/requirements/opensearch_1x.in + echo "examples/requirements/opensearch_2x.in" + pip-compile examples/requirements/opensearch_2x.in + echo "pip-compile examples/requirements/test.in" + pip-compile examples/requirements/test.in + python -m pip install -r examples/requirements/${{ matrix.requirements }}.txt + python -m pip install -r examples/requirements/opensearch_${{ matrix.es-version }}x.txt + python -m pip install -r examples/requirements/test.txt + - name: Run tests + uses: nick-invision/retry@v2 + with: + command: tox -e ${{ matrix.tox_env }} -c tox_opensearch.ini -- --color yes + timeout_minutes: 15 + max_attempts: 3 + - name: Upload to Codecov + uses: codecov/codecov-action@v2 + - name: Coveralls + uses: AndreMiras/coveralls-python-action@develop + with: + parallel: true + flag-name: Run Tests + + coveralls_finish: + needs: test + runs-on: ubuntu-latest + steps: + - name: Coveralls Finished + env: + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + GITHUB_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + uses: AndreMiras/coveralls-python-action@develop + with: + parallel-finished: true + debug: True diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 28c96503..28728286 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -15,6 +15,13 @@ are used for versioning (schema follows below): 0.3.4 to 0.4). - All backwards incompatible changes are mentioned in this document. +0.23 +---- +2022-07-21 + +- Make it compatible with both Elasticsearch and OpenSearch. +- Drop support for Elasticsearch 6.x. + 0.22.5 ------ 2022-07-04 diff --git a/COMPATIBILITY.rst b/COMPATIBILITY.rst new file mode 100644 index 00000000..a8123941 --- /dev/null +++ b/COMPATIBILITY.rst @@ -0,0 +1,36 @@ +Compatibility +============= +OpenSearch was based on Elasticsearch 7.10. Therefore, there's no point of +supporting and testing things for Elasticsearch 6.x (which is a legacy anyway). + +Elasticsearch +------------- +Tested versions: 6.x, 7.x. + +6.x +~~~~ +6.x is tested against: + +- django-elasticsearch-dsl + +7.x +~~~ +7.x is tested against: + +- django-anysearch-dsl + +OpenSearch +---------- +Tested versions: 1.x, 2.x + +1.x +~~~ +1.x is tested against: + +- django-anysearch-dsl + +2.x +~~~ +2.x is tested against: + +- django-anysearch-dsl diff --git a/README.rst b/README.rst index fa5ba9df..b4d57bb7 100644 --- a/README.rst +++ b/README.rst @@ -88,7 +88,7 @@ Demos ===== Online demo ----------- -Check the `live demo app `__ +Check the `live demo app `__ (Django 3.1 + Django REST Framework 3.12 + Elasticsearch 7.5) hosted on Heroku and bonsai.io. diff --git a/docker-compose-opensearch-1.yml b/docker-compose-opensearch-1.yml new file mode 100644 index 00000000..6738606d --- /dev/null +++ b/docker-compose-opensearch-1.yml @@ -0,0 +1,24 @@ +version: '3' + +services: + + opensearch: + container_name: django_elasticsearch_dsl_drf_opensearch + build: + context: . + dockerfile: ./docker/opensearch/Dockerfile + volumes: + - osdata1:/usr/share/opensearch/data + ports: + - "9200:9200" + - "9300:9300" + environment: +# - bootstrap.memory_lock=true + - discovery.type=single-node + - cluster.routing.allocation.disk.watermark.low=97% + - cluster.routing.allocation.disk.watermark.high=98% + - cluster.routing.allocation.disk.watermark.flood_stage=99% + - "ES_JAVA_OPTS=-Xms512m -Xmx512m" + +volumes: + osdata1: diff --git a/docker-compose-opensearch-2.yml b/docker-compose-opensearch-2.yml new file mode 100644 index 00000000..1e5d681c --- /dev/null +++ b/docker-compose-opensearch-2.yml @@ -0,0 +1,24 @@ +version: '3' + +services: + + opensearch: + container_name: django_elasticsearch_dsl_drf_opensearch_2 + build: + context: . + dockerfile: ./docker/opensearch/Dockerfile_2 + volumes: + - osdata2:/usr/share/opensearch/data + ports: + - "9200:9200" + - "9300:9300" + environment: +# - bootstrap.memory_lock=true + - discovery.type=single-node + - cluster.routing.allocation.disk.watermark.low=97% + - cluster.routing.allocation.disk.watermark.high=98% + - cluster.routing.allocation.disk.watermark.flood_stage=99% + - "ES_JAVA_OPTS=-Xms512m -Xmx512m" + +volumes: + osdata2: diff --git a/docker-compose.yml b/docker-compose.yml index 1ecef4a3..5cc6f122 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: context: . dockerfile: ./docker/elasticsearch/Dockerfile volumes: - - esdata:/usr/share/elasticsearch/data + - esdata1:/usr/share/elasticsearch/data ports: - "9200:9200" - "9300:9300" @@ -62,5 +62,5 @@ services: volumes: data: - esdata: + esdata1: node_modules: diff --git a/docker/elasticsearch/Dockerfile b/docker/elasticsearch/Dockerfile index ccc686fc..09c60496 100644 --- a/docker/elasticsearch/Dockerfile +++ b/docker/elasticsearch/Dockerfile @@ -1,4 +1,4 @@ -FROM docker.elastic.co/elasticsearch/elasticsearch:7.5.2 +FROM docker.elastic.co/elasticsearch/elasticsearch:7.10.2 ADD ./docker/elasticsearch/elasticsearch.yml /usr/share/elasticsearch/config/ USER root RUN chown elasticsearch:elasticsearch config/elasticsearch.yml diff --git a/docker/opensearch/Dockerfile b/docker/opensearch/Dockerfile new file mode 100644 index 00000000..06325882 --- /dev/null +++ b/docker/opensearch/Dockerfile @@ -0,0 +1,5 @@ +FROM opensearchproject/opensearch:1.0.1 +ADD ./docker/opensearch/opensearch.yml /usr/share/opensearch/config/ +USER root +RUN chown opensearch:opensearch config/opensearch.yml +USER opensearch diff --git a/docker/opensearch/Dockerfile_2 b/docker/opensearch/Dockerfile_2 new file mode 100644 index 00000000..98dff87f --- /dev/null +++ b/docker/opensearch/Dockerfile_2 @@ -0,0 +1,5 @@ +FROM opensearchproject/opensearch:2.0.1 +ADD ./docker/opensearch/opensearch.yml /usr/share/opensearch/config/ +USER root +RUN chown opensearch:opensearch config/opensearch.yml +USER opensearch diff --git a/docker/opensearch/opensearch.yml b/docker/opensearch/opensearch.yml new file mode 100644 index 00000000..1c20fd92 --- /dev/null +++ b/docker/opensearch/opensearch.yml @@ -0,0 +1,4 @@ +http.host: 0.0.0.0 +transport.host: 127.0.0.1 +discovery.type: single-node +plugins.security.disabled: true \ No newline at end of file diff --git a/docs/changelog.rst b/docs/changelog.rst index 28c96503..565b0521 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,878 +1 @@ -Release history and notes -========================= -`Sequence based identifiers -`_ -are used for versioning (schema follows below): - -.. code-block:: text - - major.minor[.revision] - -- It's always safe to upgrade within the same minor version (for example, from - 0.3 to 0.3.4). -- Minor version changes might be backwards incompatible. Read the - release notes carefully before upgrading (for example, when upgrading from - 0.3.4 to 0.4). -- All backwards incompatible changes are mentioned in this document. - -0.22.5 ------- -2022-07-04 - -- Return 0 for count when using EmptySearch. - -0.22.4 ------- -2022-01-24 - -- Skip some parts of the ViewSet class definition on empty `document`. - -0.22.3 ------- -2022-01-24 - -- Make running of ViewSet checks flexible (to allow dynamic document definition). -- Added the `FacetedFilterSearchFilterBackend`. - -0.22.2 ------- -2021-08-29 - -- Tested against Django 3.2. - -0.22.1 ------- -2021-05-01 - -- `DictionaryProxy` gets an optional `meta` argument, which will hold meta - information of the hit. - -0.22 ----- -2021-03-26 - -.. note:: - - Release dedicated to my dear son, Raffi, who turns 16 at the end of the - month. Happy birthday, dear Raffi. - -- Make it easier to override the `DictionaryProxy` by moving it to the - scope of the `BaseDocumentViewSet`. -- Add `tzinfo` check for better date vs datetime determination. -- Broader `EmptySearch` compatibility with `elasticsearch_dsl.Search`. -- Remove old Django code from docs. -- Allow more specific targeting for nested sort fields. -- Add more tests. - -0.21 ----- -2021-02-04 - -.. note:: - - Release dedicated to defenders of Armenia and Artsakh (Nagorno Karabakh) - and all the victims of Turkish and Azerbaijani aggression. - -- Drop support for Python 2.7 and 3.5. -- Drop support for Django 1.11, 2.0 and 2.1. -- Tested against Django 3.1 and Python 3.9. -- Take options (ex: boost, fuzziness) into consideration - in `NestedQueryBackend`. -- Added an example of a proper date formatting. -- Added an example of alternative document ID. -- Added experimental `QueryFriendlyPageNumberPagination` which fires just a single - query instead of used two used by `PageNumberPagination`. - -0.20.9 ------- -2020-10-16 - -.. note:: - - Help to rebuild the Armenian homeland. Please, `make a donation - `__. All donations received are solely for - humanitarian purposes. - -- Implemented ``geo_shape`` filter. - -0.20.8 ------- -2020-04-10 - -- Fixes in ``skip_duplicates`` option support for native suggester. - -0.20.7 ------- -2020-04-10 - -- Make ``skip_duplicates`` available for native suggester. - -0.20.6 ------- -2020-04-04 - -- Basic implementation of RegExp field lookup. - -0.20.5 ------- -2019-12-30 - -- Minor fixes. - -0.20.4 ------- -2019-12-25 - -- Tested against Django 3.0. -- Tested against Python 3.8. -- Tested against Django REST Framework 3.11. -- Minor fixes. -- Test optimisations. - -0.20.3 ------- -2019-09-20 - -- Testing the auxiliary versions module. - -0.20.2 ------- -2019-08-30 - -- Minor improvements in test coverage. - -0.20.1 ------- -2019-08-18 - -- Minor Elasticsearch 7.x compatibility fixes. - -0.20 ----- -2019-08-17 - -- Adding Elasticsearch 7.x support. - -0.19 ----- -2019-08-06 - -.. note:: - - Dropping support for Elasticsearch versions prior 6.x. This is unfortunate, - but this project depends on the upstream ``django-elasticsearch-dsl`` where - as of version 6.4.x the support for older Elasticsearch versions was - dropped. Use ``django-elasticsearch-dsl-drf`` version 0.18 if you need - to work with 5.x or 2.x. - -- Dropping support for Elasticsearch versions prior to 6.x. - -0.18 ----- -2019-06-26 - -.. note:: - - Support for Django versions prior 1.11 has been dropped. - Support for Django REST Framework prior 3.9 has been dropped. - -- Dropping support for Django versions prior 1.11. -- Dropping support for Django REST Framework versions prior 3.9. -- Fix Django REST Framework deprecations. - -0.17.7 ------- -2019-05-30 - -.. note:: - - Support for Django 1.8, 1.9 and 1.10 will be dropped in the next release. - As usual, compatibility shims won't be removed directly. The change - will affect the test matrix only first. - -- Prevent unicode errors in tests on Python 2.7. -- Fixes in occasionally failing search test (``test_search`` and - ``test_filtering_geo_spatial``). -- Working travis. -- Fixed issue with errors on empty ``ids`` filter. - -0.17.6 ------- -2019-04-08 - -- Minor fixes. -- Additions to the docs. - -0.17.5 ------- -2019-04-03 - -.. note:: - - Dropping support for Python 3.4. As of this version everything works, but - no longer tested. - -- Minor fixes. -- Dropping Python 3.4 support. -- Django 2.2 support. - -0.17.4 ------- -2019-03-13 - -- Source backend. - -0.17.3 ------- -2019-02-08 - -- Obey object permissions. - -0.17.2 ------- -2019-01-07 - -- Add nested ordering. - -0.17.1 ------- -2018-12-12 - -- Skipping the new context suggester tests for Elasticsearch 2.x and a number - of other 2.x related fixes in tests. -- A number of 5.x fixes in tests. - -0.17 ----- -2018-12-12 - -.. note:: - - Release supported by `whythawk `_. - -- Added support for context suggesters (`category` and `geo`). Note, that - this functionality is available for Elasticsearch 5.x and 6.x (thus, not - for Elasticsearch 2.x). -- Added support for `size` attribute on suggesters. - -0.16.3 ------- -2018-10-31 - -.. note:: - - Release dedicated to Charles Aznavour. - -- Make it possible to ignore certain Elastic exceptions by providing the - appropriate ``ignore`` argument (on the view level). Default behaviour is - intact. Set it to a list of integers (error codes) if you need it so. - -0.16.2 ------- -2018-09-21 - -- Tested yet untested ``pip_helpers`` module. -- More tests. - -0.16.1 ------- -2018-09-18 - -- Make it possible to control the size of the functional suggester queries. - -0.16 ----- -2018-09-10 - -.. note:: - - This release contains minor backwards incompatible changes. You might - need to update your code if you have been making use of nested search. - -*Old way of declaring nested search fields* - -.. code-block:: python - - search_nested_fields = { - 'country': ['name'], - 'country.city': ['name'], - } - -*New way of declaring nested search fields* - -.. code-block:: python - - search_nested_fields = { - 'country': { - 'path': 'country', - 'fields': ['name'], - }, - 'city': { - 'path': 'country.city', - 'fields': ['name'], - }, - } - -- Changes in nested search. This affects usage of both historical - ``SearchFilterBackend`` and ``CompoundSearchFilterBackend``. Update your code - accordingly. -- Take meta property ``using`` of the document ``Meta`` into consideration. - -0.15.1 ------- -2018-08-22 - -- More tests. -- Fixes in docs. - -0.15 ----- -2018-08-10 - -- Global aggregations. - -0.14 ----- -2018-08-06 - -- More like this support through detail action. - -0.13.2 ------- -2018-08-03 - -- Successfully tested against Python 3.7 and Django 2.1. -- Unified the base ``BaseSearchFilterBackend`` class. -- Minor clean up and fixes in docs. -- Upgrading test suite to modern versions (``pytest``, ``tox``, - ``factory_boy``, ``Faker``). Removing unused dependencies from - requirements (``drf-extensions``). -- Fixed missing PDF generation in offline documentation (non ReadTheDocs). - The ``rst2pdf`` package (which does not support Python 3) has been replaced - with ``rinohtype`` package (which does support Python 3). - -0.13.1 ------- -2018-07-26 - -- Minor fix in suggesters on Elasticsearch 6.x. - -0.13 ----- -2018-07-23 - -.. note:: - - Release dedicated to Guido van Rossum, the former Python BDFL, who - resigned from his BDFL position recently. Guido knew it better than we all - do. His charisma, talent and leadership will be certainly missed a lot by - the community. Thumbs up again for the best BDFL ever. - -- The ``SimpleQueryStringSearchFilterBackend`` backend has been implemented. -- Minor fixes in the ``MultiMatchSearchFilterBackend`` backend. - -0.12 ----- -2018-07-21 - -- New-style Search Filter Backends. Old style ``SearchFilterBackend`` is - still supported (until at least version 0.16), but is deprecated. Migrate to - ``CompoundSearchFilterBackend``. ``MultiMatchSearchFilterBackend`` - introduced (the name speaks for itself). -- From now on, your views would also work with model- and object-level - permissions of the Django REST Framework (such as ``DjangoModelPermissions``, - ``DjangoModelPermissionsOrAnonReadOnly`` and ``DjangoObjectPermissions``). - Correspondent model or object would be used for that. If you find it - incorrect in your case, write custom permissions and declare the explicitly - in your view-sets. -- Fixed geo-spatial ``geo_distance`` ordering for Elastic 5.x. and 6.x. -- Fixes occasionally failing tests. - -0.11 ----- -2018-07-15 - -.. note:: - - This release contains backwards incompatible changes. - You should update your Django code and front-end parts of your applications - that were relying on the complex queries using ``|`` and ``:`` chars in the - GET params. - -.. note:: - - If you have used custom filter backends using ``SEPARATOR_LOOKUP_VALUE``, - ``SEPARATOR_LOOKUP_COMPLEX_VALUE`` or - ``SEPARATOR_LOOKUP_COMPLEX_MULTIPLE_VALUE`` constants or - ``split_lookup_complex_value`` helper method of the ``FilterBackendMixin``, - you most likely want to run your functional tests to see if everything - still works. - -.. note:: - - Do not keep things as they were in your own fork, since new search backends - will use the ``|`` and ``:`` symbols differently. - -**Examples of old API requests vs new API requests** - -.. note:: - - Note, that ``|`` and ``:`` chars were mostly replaced with ``__`` and ``,``. - -*Old API requests* - -.. code-block:: text - - http://127.0.0.1:8080/search/publisher/?search=name|reilly&search=city|london - http://127.0.0.1:8000/search/publishers/?location__geo_distance=100000km|12.04|-63.93 - http://localhost:8000/api/articles/?id__terms=1|2|3 - http://localhost:8000/api/users/?age__range=16|67|2.0 - http://localhost:8000/api/articles/?id__in=1|2|3 - http://localhost:8000/api/articles/?location__geo_polygon=40,-70|30,-80|20,-90|_name:myname|validation_method:IGNORE_MALFORMED - -*New API requests* - -.. code-block:: text - - http://127.0.0.1:8080/search/publisher/?search=name:reilly&search=city:london - http://127.0.0.1:8000/search/publishers/?location__geo_distance=100000km__12.04__-63.93 - http://localhost:8000/api/articles/?id__terms=1__2__3 - http://localhost:8000/api/users/?age__range=16__67__2.0 - http://localhost:8000/api/articles/?id__in=1__2__3 - http://localhost:8000/api/articles/?location__geo_polygon=40,-70__30,-80__20,-90___name,myname__validation_method,IGNORE_MALFORMED - -- ``SEPARATOR_LOOKUP_VALUE`` has been removed. Use - ``SEPARATOR_LOOKUP_COMPLEX_VALUE`` and - ``SEPARATOR_LOOKUP_COMPLEX_MULTIPLE_VALUE`` instead. -- ``SEPARATOR_LOOKUP_NAME`` has been added. -- The method ``split_lookup_complex_value`` has been removed. Use - ``split_lookup_complex_value`` instead. -- Default filter lookup option is added. In past, if no specific lookup was - provided and there were multiple values for a single field to filter on, by - default ``terms`` filter was used. The ``term`` lookup was used by default - in similar situation for a single value to filter on. It's now possible to - declare default lookup which will be used when no lookup is given. -- Removed deprecated ``views`` module. Import from ``viewsets`` instead. -- Removed undocumented ``get_count`` helper from ``helpers`` module. - -0.10 ----- -2018-07-06 - -- Elasticsearch 6.x support. -- Minor fixes. - -0.9 ---- -2018-07-04 - -- Introduced ``post_filter`` support. -- Generalised the ``FilteringFilterBackend`` backend. Both - ``PostFilterFilteringFilterBackend`` and ``NestedFilteringFilterBackend`` - backends are now primarily based on it. -- Reduced Elastic queries from 3 to 2 when using ``LimitOffsetPagination``. - -0.8.4 ------ -2018-06-27 - -.. note:: - - Release supported by `Goldmund, Wyldebeast & Wunderliebe - `_. - -- Added ``NestedFilteringFilterBackend`` backend. -- Documentation updated with examples of implementing a nested - aggregations/facets. - -0.8.3 ------ -2018-06-25 - -- It's possible to retrieve original dictionary from ``DictionaryProxy`` - object. -- Added helper wrappers and helper functions as a temporary fix for issues - in the ``django-elasticsearch-dsl``. - -0.8.2 ------ -2018-06-05 - -- Minor fixes. - -0.8.1 ------ -2018-06-05 - -- Fixed wrong filter name in functional suggesters results into an error on - Django 1.10 (and prior). -- Documentation improvements. - -0.8 ---- -2018-06-01 - -.. note:: - - Release supported by `Goldmund, Wyldebeast & Wunderliebe - `_. - -.. note:: - - This release contain minor backwards incompatible changes. You should - update your code. - - - (1) ``BaseDocumentViewSet`` (which from now on does not contain - ``suggest`` functionality) has been renamed to ``DocumentViewSet`` - (which does contain ``suggest`` functionality). - - (2) You should no longer import from - ``django_elasticsearch_dsl_drf.views``. Instead, import from - ``django_elasticsearch_dsl_drf.viewsets``. - -- Deprecated ``django_elasticsearch_dsl_drf.views`` in favour - of ``django_elasticsearch_dsl_drf.viewsets``. -- Suggest action/method has been moved to ``SuggestMixin`` class. -- ``FunctionalSuggestMixin`` class introduced which resembled functionality - of the ``SuggestMixin`` with several improvements/additions, such as - advanced filtering and context-aware suggestions. -- You can now define a default suggester in ``suggester_fields`` which will - be used if you do not provide suffix for the filter name. - -0.7.2 ------ -2018-05-09 - -.. note:: - - Release dedicated to the Victory Day, the victims of the Second World War - and Liberation of Shushi. - -- Django REST framework 3.8.x support. - -0.7.1 ------ -2018-04-04 - -.. note:: - - Release supported by `Goldmund, Wyldebeast & Wunderliebe - `_. - -- Add query `boost` support for search fields. - -0.7 ---- -2018-03-08 - -.. note:: - - Dear ladies, congratulations on `International Women's Day - `_ - -- CoreAPI/CoreSchema support. - -0.6.4 ------ -2018-03-05 - -- Minor fix: explicitly use DocType in the ViewSets. - -0.6.3 ------ -2018-01-03 - -- Minor fix in the search backend. -- Update the year in the license and code. - -0.6.2 ------ -2017-12-29 - -- Update example project (and the tests that are dependant on the example - project) to work with Django 2.0. -- Set minimal requirement for ``django-elasticsearch-dsl`` to 3.0. - -0.6.1 ------ -2017-11-28 - -- Documentation fixes. - -0.6 ---- -2017-11-28 - -- Added highlight backend. -- Added nested search functionality. - -0.5.1 ------ -2017-10-18 - -- Fixed serialization of complex nested structures (lists of nested objects). -- Documentation fixes. - -0.5 ---- -2017-10-05 - -.. note:: - - This release contains changes that might be backwards incompatible - for your project. If you have used dynamic document serializer - ``django_elasticsearch_dsl_drf.serializers.DocumentSerializer`` - with customisations (with use of ``serializers.SerializerMethodField``, - having the value parsed to JSON), just remove the custom parts. - -- Support for ``ObjectField``, ``NestedField``, ``GeoPointField``, - ``ListField``, ``GeoShapeField`` (and in general, nesting fields either - as a dictionary or list should not be a problem at all). -- Dynamic serializer has been made less strict. -- Added ``get_paginated_response_context`` methods to both - ``PageNumberPagination`` and ``LimitOffsetPagination`` pagination classes - to simplify customisations. - -0.4.4 ------ -2017-10-02 - -- Documentation improvements (Elasticsearch suggestions). -- More tests (term and phrase suggestions). -- Code style fixes. - -0.4.3 ------ -2017-09-28 - -- Documentation fixes. -- Fixes in tests. -- Improved factories. - -0.4.2 ------ -2017-09-28 - -- Added ``geo_bounding_box`` query support to the geo-spatial features. - -0.4.1 ------ -2017-09-26 - -- Fixes in docs. - -0.4 ---- -2017-09-26 - -.. note:: - - This release contains changes that might be backwards incompatible - for your project. Make sure to add the ``DefaultOrderingFilterBackend`` - everywhere you have used the ``OrderingFilterBackend``, right after the - latter. - -- ``GeoSpatialFilteringFilterBackend`` filtering backend, supporting - ``geo_distance`` and ``geo_polygon`` geo-spatial queries. -- ``GeoSpatialOrderingFilterBackend`` ordering backend, supporting - ordering of results for ``geo_distance`` filter. -- ``OrderingFilterBackend`` no longer provides defaults when no ordering is - given. In order to take care of the defaults include the - ``DefaultOrderingFilterBackend`` in the list of ``filter_backends`` (after - all other ordering backends). - -0.3.12 ------- -2017-09-21 - -- Added ``geo_distance`` filter. Note, that although functionally the filter - would not change its' behaviour, it is likely to be moved to a separate - backend (``geo_spatial``). For now use as is. -- Minor fixes. - -0.3.11 ------- -2017-09-21 - -- Added ``query`` argument to ``more_like_this`` helper. - -0.3.10 ------- -2017-09-20 - -- Minor fixes. -- Simplified Elasticsearch version check. - -0.3.9 ------ -2017-09-12 - -- Python 2.x compatibility fix. - -0.3.8 ------ -2017-09-12 - -- Fixes tests on some environments. - -0.3.7 ------ -2017-09-07 - -- Docs fixes. - -0.3.6 ------ -2017-09-07 - -- Fixed suggestions test for Elasticsearch 5.x. -- Added `compat` module for painless testing of Elastic 2.x to Elastic 5.x - transition. - -0.3.5 ------ -2017-08-24 - -- Minor fixes in the ordering backend. -- Improved tests and coverage. - -0.3.4 ------ -2017-08-23 - -- Minor fixes in the ordering backend. - -0.3.3 ------ -2017-07-13 - -- Minor fixes and improvements. - -0.3.2 ------ -2017-07-12 - -- Minor fixes and improvements. - -0.3.1 ------ -2017-07-12 - -- Minor Python2 fixes. -- Minor documentation fixes. - -0.3 ---- -2017-07-11 - -- Add suggestions support (``term``, ``phrase`` and ``completion``). - -0.2.6 ------ -2017-07-11 - -- Minor fixes. -- Fixes in documentation. - -0.2.5 ------ -2017-07-11 - -- Fixes in documentation. - -0.2.4 ------ -2017-07-11 - -- Fixes in documentation. - -0.2.3 ------ -2017-07-11 - -- Fixes in documentation. - -0.2.2 ------ -2017-07-11 - -- Fixes in documentation. - -0.2.1 ------ -2017-07-11 - -- Fixes in documentation. - -0.2 ---- -2017-07-11 - -- Initial faceted search support. -- Pagination support. - -0.1.8 ------ -2017-06-26 - -- Python2 fixes. -- Documentation and example project improvements. - -0.1.7 ------ -2017-06-25 - -- Dynamic serializer for Documents. -- Major improvements in documentation. - -0.1.6 ------ -2017-06-23 - -- Implemented ``gt``, ``gte``, ``lt`` and ``lte`` functional query lookups. -- Implemented ``ids`` native filter lookup. - -0.1.5 ------ -2017-06-22 - -- Implemented ``endswith`` and ``contains`` functional filters. -- Added tests for ``wildcard``, ``exists``, ``exclude`` and ``isnull`` filters. - Improved ``range`` filter tests. -- Improve ``more_like_this`` helper test. -- Improve ordering tests. -- Two additional arguments added to the ``more_like_this`` helper: - ``min_doc_freq`` and ``max_doc_freq``. -- Minor documentation improvements. - -0.1.4 ------ -2017-06-22 - -- Added tests for ``in``, ``term`` and ``terms`` filters. -- Minor documentation fixes. - -0.1.3 ------ -2017-06-21 - -- Added tests for ``more_like_this`` helper, ``range`` and ``prefix`` filters. -- Minor documentation improvements. - -0.1.2 ------ -2017-06-20 - -- Minor fixes in tests. - -0.1.1 ------ -2017-06-20 - -- Fixes in ``more_like_this`` helper. -- Tiny documentation improvements. - -0.1 ---- -2017-06-19 - -- Initial beta release. +.. include:: ../CHANGELOG.rst diff --git a/docs/documentation.rst b/docs/documentation.rst new file mode 100755 index 00000000..0261e4ed --- /dev/null +++ b/docs/documentation.rst @@ -0,0 +1,37 @@ + +Project documentation +===================== +Contents: + +.. contents:: Table of Contents + +.. toctree:: + :maxdepth: 20 + + index + dependencies + installing_elasticsearch + quick_start + filtering_usage_examples + search_backends + basic_usage_examples + advanced_usage_examples + nested_fields_usage_examples + more_like_this + global_aggregations + configuration_tweaks + source_backend + pagination + indexing_troubleshooting + faq + demo + frontend_demo + changelog + django_elasticsearch_dsl_drf + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/index.rst b/docs/index.rst index 6f1e8452..d00c3c7b 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,276 +1,2 @@ -============================ -django-elasticsearch-dsl-drf -============================ -Integrate `Elasticsearch DSL -`_ with -`Django REST framework `_ in -the shortest way possible, with least efforts possible. - -Package provides views, serializers, filter backends, pagination and other -handy add-ons. - -You are expected to use `django-elasticsearch-dsl -`_ for defining your -Elasticsearch documents. - -.. image:: https://img.shields.io/pypi/v/django-elasticsearch-dsl-drf.svg - :target: https://pypi.python.org/pypi/django-elasticsearch-dsl-drf - :alt: PyPI Version - -.. image:: https://img.shields.io/pypi/pyversions/django-elasticsearch-dsl-drf.svg - :target: https://pypi.python.org/pypi/django-elasticsearch-dsl-drf/ - :alt: Supported Python versions - -.. image:: https://github.com/barseghyanartur/django-elasticsearch-dsl-drf/workflows/test/badge.svg - :target: https://github.com/barseghyanartur/django-elasticsearch-dsl-drf/actions - :alt: Build Status - -.. image:: https://readthedocs.org/projects/django-elasticsearch-dsl-drf/badge/?version=latest - :target: http://django-elasticsearch-dsl-drf.readthedocs.io/en/latest/?badge=latest - :alt: Documentation Status - -.. image:: https://img.shields.io/badge/license-GPL--2.0--only%20OR%20LGPL--2.1--or--later-blue.svg - :target: https://github.com/barseghyanartur/django-elasticsearch-dsl-drf/#License - :alt: GPL-2.0-only OR LGPL-2.1-or-later - -.. image:: https://coveralls.io/repos/github/barseghyanartur/django-elasticsearch-dsl-drf/badge.svg?branch=master - :target: https://coveralls.io/github/barseghyanartur/django-elasticsearch-dsl-drf?branch=master - :alt: Coverage - -Documentation -============= -Documentation is available on `Read the Docs -`_. - -Make sure to read `FAQ `_. - -Prerequisites -============= -- Django 2.2, 3.1 and 3.2. -- Python 3.6, 3.7, 3.8 and 3.9. -- Elasticsearch 6.x, 7.x. For older versions use - ``django-elasticsearch-dsl-drf`` version 0.18. - -Main features and highlights -============================ - -- :doc:`Dynamic serializer for Documents `. -- :doc:`Search filter backend `. -- :doc:`Ordering filter backend `. -- :doc:`Filtering filter backend ` (big variety of - native- and functional- query lookups, such as ``gt``, ``gte``, ``lt``, - ``lte``, ``endswith``, ``contains``, ``wildcard``, ``exists``, ``exclude``, - ``isnull``, ``range``, ``in``, ``prefix`` (same as ``startswith``), ``term`` - and ``terms`` is implemented. -- :doc:`Geo-spatial filtering filter backend ` (the - following filters implemented: ``geo_distance``, ``geo_polygon`` and - ``geo_bounding_box``). -- :doc:`Geo-spatial ordering filter backend ` (the - following filters implemented: ``geo_distance``). -- :doc:`Faceted search filter backend `. -- :doc:`Post-filter filter backend `. -- :doc:`Nested filtering filter backend `. -- :doc:`Highlight backend `. -- :doc:`Suggester filter backend `. -- :doc:`Functional suggester filter backend `. -- :doc:`Pagination (Page number and limit/offset pagination) `. -- :doc:`Ids filter backend `. -- :doc:`Multi match search filter backend `. -- :doc:`Simple search query search filter backend `. -- :doc:`More-like-this support (detail action) `. -- :doc:`Global aggregations support `. -- :doc:`Source filter backend `. - -Do you need a similar tool for GraphQL? Check `graphene-elastic -`__. - -Demos -===== -Online demo ------------ -Check the `live demo app `__ -(Django 3.1 + Django REST Framework 3.12 + Elasticsearch 7.5) hosted on Heroku -and bonsai.io. - -Local demo ----------- -A frontend demo (React based) is available. See the `dedicated docs -`_ -for more information. - -To bootstrap evaluation, clone the repository locally and run `docker-compose`. - -.. code-block:: sh - - docker-compose up - -It will set up: - -- Elasticsearch on `http://localhost:9200 `_ -- Django REST framework on `http://localhost:8000 `_ -- React on `http://localhost:3000 `_ - -Installation -============ -(1) Install latest stable version from PyPI: - - .. code-block:: sh - - pip install django-elasticsearch-dsl-drf - - or latest stable version from GitHub: - - .. code-block:: sh - - pip install https://github.com/barseghyanartur/django-elasticsearch-dsl-drf/archive/stable.tar.gz - -(2) Add ``rest_framework``, ``django_elasticsearch_dsl`` and - ``django_elasticsearch_dsl_drf`` to ``INSTALLED_APPS``: - - .. code-block:: python - - INSTALLED_APPS = ( - # ... - # REST framework - 'rest_framework', - - # Django Elasticsearch integration - 'django_elasticsearch_dsl', - - # Django REST framework Elasticsearch integration (this package) - 'django_elasticsearch_dsl_drf', - # ... - ) - -Quick start -=========== -Perhaps the easiest way to get acquainted with ``django-elasticsearch-dsl-drf`` -is to read the :doc:`quick start tutorial `. - -See it as a guide of diving into integration of Elasticsearch with Django -with very low knowledge entry level. - -Testing -======= -Project is covered with tests. - -To test with all supported Python/Django versions type: - -.. code-block:: sh - - tox - -To test against specific environment, type: - -.. code-block:: sh - - tox -e py38-django30 - -To test just your working environment type: - -.. code-block:: sh - - ./runtests.py - -To run a single test in your working environment type: - -.. code-block:: sh - - ./runtests.py src/django_elasticsearch_dsl_drf/tests/test_filtering.py - -Or: - -.. code-block:: sh - - ./manage.py test django_elasticsearch_dsl_drf.tests.test_ordering - -To run a single test class in a given test module in your working environment -type: - -.. code-block:: sh - - ./runtests.py src/django_elasticsearch_dsl_drf/tests/test_suggesters.py::TestSuggesters - -It's assumed that you have all the requirements installed. If not, first -install the test requirements: - -.. code-block:: sh - - pip install -r examples/requirements/test.txt - -Writing documentation -===================== -Keep the following hierarchy. - -.. code-block:: text - - ===== - title - ===== - - header - ====== - - sub-header - ---------- - - sub-sub-header - ~~~~~~~~~~~~~~ - - sub-sub-sub-header - ^^^^^^^^^^^^^^^^^^ - - sub-sub-sub-sub-header - ++++++++++++++++++++++ - - sub-sub-sub-sub-sub-header - ************************** - -License -======= -GPL-2.0-only OR LGPL-2.1-or-later - -Support -======= -For any issues contact me at the e-mail given in the `Author`_ section. - -Author -====== -Artur Barseghyan - -Project documentation -===================== -Contents: - -.. contents:: Table of Contents - -.. toctree:: - :maxdepth: 20 - - index - dependencies - installing_elasticsearch - quick_start - filtering_usage_examples - search_backends - basic_usage_examples - advanced_usage_examples - nested_fields_usage_examples - more_like_this - global_aggregations - configuration_tweaks - source_backend - pagination - indexing_troubleshooting - faq - demo - frontend_demo - changelog - django_elasticsearch_dsl_drf - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` +.. include:: ../README.rst +.. include:: documentation.rst diff --git a/docs/index.rst.distrib b/docs/index.rst.distrib new file mode 100644 index 00000000..d00c3c7b --- /dev/null +++ b/docs/index.rst.distrib @@ -0,0 +1,2 @@ +.. include:: ../README.rst +.. include:: documentation.rst diff --git a/examples/requirements/base.txt b/examples/requirements/base.txt index 8b46fce2..ca3b452b 100644 --- a/examples/requirements/base.txt +++ b/examples/requirements/base.txt @@ -1,9 +1,11 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile base.in # +anysearch==0.2.2 + # via -r django_3_2.in asgiref==3.4.1 # via django django==3.2.5 diff --git a/examples/requirements/code_style.txt b/examples/requirements/code_style.txt index bae15e66..f58218c5 100644 --- a/examples/requirements/code_style.txt +++ b/examples/requirements/code_style.txt @@ -1,6 +1,6 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile code_style.in # diff --git a/examples/requirements/common.in b/examples/requirements/common.in index a56edc30..ae0bf9ef 100644 --- a/examples/requirements/common.in +++ b/examples/requirements/common.in @@ -1,5 +1,4 @@ -#-r elastic.txt - +anysearch>=0.1.3 python-memcached==1.58 pytz six>=1.9 diff --git a/examples/requirements/common.txt b/examples/requirements/common.txt index 21a69d44..df0ef3e9 100644 --- a/examples/requirements/common.txt +++ b/examples/requirements/common.txt @@ -1,9 +1,11 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile common.in # +anysearch==0.2.2 + # via -r common.in pillow==8.3.1 # via -r common.in python-memcached==1.58 diff --git a/examples/requirements/coreapi_coreschema.txt b/examples/requirements/coreapi_coreschema.txt index 3a2e7706..09b05684 100644 --- a/examples/requirements/coreapi_coreschema.txt +++ b/examples/requirements/coreapi_coreschema.txt @@ -1,6 +1,6 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile coreapi_coreschema.in # diff --git a/examples/requirements/deployment.txt b/examples/requirements/deployment.txt index ba16714d..1caa5039 100644 --- a/examples/requirements/deployment.txt +++ b/examples/requirements/deployment.txt @@ -1,6 +1,6 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile deployment.in # diff --git a/examples/requirements/django_2_2.in b/examples/requirements/django_2_2.in index 78f071d3..a1950980 100755 --- a/examples/requirements/django_2_2.in +++ b/examples/requirements/django_2_2.in @@ -1,6 +1,7 @@ --r common.in --r test.in +#-r common.in +#-r test.in +anysearch>=0.1.5 Django>=2.2,<2.3 django-cors-headers==2.5.2 django-debug-toolbar==1.9.1 diff --git a/examples/requirements/django_2_2.txt b/examples/requirements/django_2_2.txt index ac698290..405bc8df 100644 --- a/examples/requirements/django_2_2.txt +++ b/examples/requirements/django_2_2.txt @@ -1,25 +1,16 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile django_2_2.in # -attrs==21.2.0 - # via pytest -backports.entry-points-selectable==1.1.0 - # via virtualenv -coverage[toml]==5.5 - # via - # -r test.in - # pytest-cov -distlib==0.3.2 - # via virtualenv +anysearch==0.2.2 + # via -r django_2_2.in django==2.2.24 # via # -r django_2_2.in # django-cors-headers # django-debug-toolbar - # django-nine django-cors-headers==2.5.2 # via -r django_2_2.in django-debug-toolbar==1.9.1 @@ -36,88 +27,14 @@ django-ormex==0.2.1 # via -r django_2_2.in djangorestframework==3.9.3 # via -r django_2_2.in -factory_boy==2.11.1 - # via -r test.in -faker==8.1.4 - # via - # -r test.in - # factory-boy -filelock==3.0.12 - # via - # tox - # virtualenv -iniconfig==1.1.1 - # via pytest -mock==4.0.3 - # via -r test.in -packaging==21.0 - # via - # pytest - # tox -pillow==8.3.1 - # via -r common.in -platformdirs==2.0.2 - # via virtualenv -pluggy==0.13.1 - # via - # pytest - # tox -py==1.10.0 - # via - # -r test.in - # pytest - # tox -pyparsing==2.4.7 - # via packaging -pytest==6.2.4 - # via - # -r test.in - # pytest-cov - # pytest-django - # pytest-ordering - # pytest-pythonpath -pytest-cov==2.12.0 - # via -r test.in -pytest-django==4.3.0 - # via -r test.in -pytest-ordering==0.6 - # via -r test.in -pytest-pythonpath==0.7.3 - # via -r test.in -python-dateutil==2.8.2 - # via faker -python-memcached==1.58 - # via -r common.in pytz==2021.1 - # via - # -r common.in - # django -selenium==3.141.0 - # via -r test.in + # via django six==1.16.0 # via - # -r common.in # django-debug-toolbar-force # django-ormex - # python-dateutil - # python-memcached - # tox - # virtualenv sqlparse==0.4.1 # via # -r django_2_2.in # django # django-debug-toolbar -text-unidecode==1.3 - # via faker -toml==0.10.2 - # via - # coverage - # pytest - # tox -tox==3.23.1 - # via -r test.in -urllib3==1.26.6 - # via selenium -virtualenv==20.6.0 - # via tox diff --git a/examples/requirements/django_2_2_and_elastic_6x.txt b/examples/requirements/django_2_2_and_elastic_6x.txt index 01a91ca3..3a149b76 100644 --- a/examples/requirements/django_2_2_and_elastic_6x.txt +++ b/examples/requirements/django_2_2_and_elastic_6x.txt @@ -1,19 +1,11 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile django_2_2_and_elastic_6x.in # -attrs==21.2.0 - # via pytest -backports.entry-points-selectable==1.1.0 - # via virtualenv -coverage[toml]==5.5 - # via - # -r test.in - # pytest-cov -distlib==0.3.2 - # via virtualenv +anysearch==0.2.2 + # via -r django_2_2.in django==2.2.24 # via # -r django_2_2.in @@ -28,7 +20,7 @@ django-debug-toolbar-force==0.1.8 # via -r django_2_2.in django-elasticsearch-debug-toolbar==2.0.0 # via -r django_2_2.in -https://github.com/django-es/django-elasticsearch-dsl/archive/dbbbfac01e4ba85c5e991fb1c0522404f170bdc0.zip +django-elasticsearch-dsl==6.5.0 # via -r elastic_6x.in django-nine==0.2.4 # via @@ -46,94 +38,21 @@ elasticsearch-dsl==6.4.0 # via # -r elastic_6x.in # django-elasticsearch-dsl -factory_boy==2.11.1 - # via -r test.in -faker==8.1.4 - # via - # -r test.in - # factory-boy -filelock==3.0.12 - # via - # tox - # virtualenv -iniconfig==1.1.1 - # via pytest -mock==4.0.3 - # via -r test.in -packaging==21.0 - # via - # pytest - # tox -pillow==8.3.1 - # via -r common.in -platformdirs==2.1.0 - # via virtualenv -pluggy==0.13.1 - # via - # pytest - # tox -py==1.10.0 - # via - # -r test.in - # pytest - # tox -pyparsing==2.4.7 - # via packaging -pytest==6.2.4 - # via - # -r test.in - # pytest-cov - # pytest-django - # pytest-ordering - # pytest-pythonpath -pytest-cov==2.12.0 - # via -r test.in -pytest-django==4.3.0 - # via -r test.in -pytest-ordering==0.6 - # via -r test.in -pytest-pythonpath==0.7.3 - # via -r test.in python-dateutil==2.8.2 - # via - # elasticsearch-dsl - # faker -python-memcached==1.58 - # via -r common.in + # via elasticsearch-dsl pytz==2021.1 - # via - # -r common.in - # django -selenium==3.141.0 - # via -r test.in + # via django six==1.16.0 # via - # -r common.in # django-debug-toolbar-force # django-elasticsearch-dsl # django-ormex # elasticsearch-dsl # python-dateutil - # python-memcached - # tox - # virtualenv sqlparse==0.4.1 # via # -r django_2_2.in # django # django-debug-toolbar -text-unidecode==1.3 - # via faker -toml==0.10.2 - # via - # coverage - # pytest - # tox -tox==3.23.1 - # via -r test.in urllib3==1.26.6 - # via - # elasticsearch - # selenium -virtualenv==20.6.0 - # via tox + # via elasticsearch diff --git a/examples/requirements/django_2_2_and_elastic_7x.txt b/examples/requirements/django_2_2_and_elastic_7x.txt index 001969e2..f22f9285 100644 --- a/examples/requirements/django_2_2_and_elastic_7x.txt +++ b/examples/requirements/django_2_2_and_elastic_7x.txt @@ -1,27 +1,23 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile django_2_2_and_elastic_7x.in # -attrs==21.2.0 - # via pytest -backports.entry-points-selectable==1.1.0 - # via virtualenv +anysearch==0.2.2 + # via + # -r django_2_2.in + # django-anysearch-dsl certifi==2021.5.30 # via elasticsearch -coverage[toml]==5.5 - # via - # -r test.in - # pytest-cov -distlib==0.3.2 - # via virtualenv django==2.2.24 # via # -r django_2_2.in # django-cors-headers # django-debug-toolbar # django-nine +django-anysearch-dsl==7.2.2.1 + # via -r elastic_7x.in django-cors-headers==2.5.2 # via -r django_2_2.in django-debug-toolbar==1.9.1 @@ -30,8 +26,6 @@ django-debug-toolbar-force==0.1.8 # via -r django_2_2.in django-elasticsearch-debug-toolbar==2.0.0 # via -r django_2_2.in -django-elasticsearch-dsl==7.1.4 - # via -r elastic_7x.in django-nine==0.2.4 # via # django-debug-toolbar-force @@ -45,97 +39,22 @@ elasticsearch==7.10.1 # -r elastic_7x.in # elasticsearch-dsl elasticsearch-dsl==7.3.0 - # via - # -r elastic_7x.in - # django-elasticsearch-dsl -factory_boy==2.11.1 - # via -r test.in -faker==8.1.4 - # via - # -r test.in - # factory-boy -filelock==3.0.12 - # via - # tox - # virtualenv -iniconfig==1.1.1 - # via pytest -mock==4.0.3 - # via -r test.in -packaging==21.0 - # via - # pytest - # tox -pillow==8.3.1 - # via -r common.in -platformdirs==2.1.0 - # via virtualenv -pluggy==0.13.1 - # via - # pytest - # tox -py==1.10.0 - # via - # -r test.in - # pytest - # tox -pyparsing==2.4.7 - # via packaging -pytest==6.2.4 - # via - # -r test.in - # pytest-cov - # pytest-django - # pytest-ordering - # pytest-pythonpath -pytest-cov==2.12.0 - # via -r test.in -pytest-django==4.3.0 - # via -r test.in -pytest-ordering==0.6 - # via -r test.in -pytest-pythonpath==0.7.3 - # via -r test.in + # via -r elastic_7x.in python-dateutil==2.8.2 - # via - # elasticsearch-dsl - # faker -python-memcached==1.58 - # via -r common.in + # via elasticsearch-dsl pytz==2021.1 - # via - # -r common.in - # django -selenium==3.141.0 - # via -r test.in + # via django six==1.16.0 # via - # -r common.in + # django-anysearch-dsl # django-debug-toolbar-force - # django-elasticsearch-dsl # django-ormex # elasticsearch-dsl # python-dateutil - # python-memcached - # tox - # virtualenv sqlparse==0.4.1 # via # -r django_2_2.in # django # django-debug-toolbar -text-unidecode==1.3 - # via faker -toml==0.10.2 - # via - # coverage - # pytest - # tox -tox==3.23.1 - # via -r test.in urllib3==1.26.6 - # via - # elasticsearch - # selenium -virtualenv==20.6.0 - # via tox + # via elasticsearch diff --git a/examples/requirements/django_3_1.in b/examples/requirements/django_3_1.in index da76be43..e6f25087 100755 --- a/examples/requirements/django_3_1.in +++ b/examples/requirements/django_3_1.in @@ -1,6 +1,7 @@ --r common.in --r test.in +#-r common.in +#-r test.in +anysearch>=0.1.5 Django>=3.1,<3.2 django-cors-headers==3.6.0 django-debug-toolbar>=3.2 diff --git a/examples/requirements/django_3_1.txt b/examples/requirements/django_3_1.txt index e46a16a4..119519c0 100644 --- a/examples/requirements/django_3_1.txt +++ b/examples/requirements/django_3_1.txt @@ -1,27 +1,18 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile django_3_1.in # +anysearch==0.2.2 + # via -r django_3_1.in asgiref==3.4.1 # via django -attrs==21.2.0 - # via pytest -backports.entry-points-selectable==1.1.0 - # via virtualenv -coverage[toml]==5.5 - # via - # -r test.in - # pytest-cov -distlib==0.3.2 - # via virtualenv django==3.1.13 # via # -r django_3_1.in # django-cors-headers # django-debug-toolbar - # django-nine # djangorestframework django-cors-headers==3.6.0 # via -r django_3_1.in @@ -39,87 +30,13 @@ django-ormex==0.2.1 # via -r django_3_1.in djangorestframework==3.12.4 # via -r django_3_1.in -factory_boy==2.11.1 - # via -r test.in -faker==8.1.4 - # via - # -r test.in - # factory-boy -filelock==3.0.12 - # via - # tox - # virtualenv -iniconfig==1.1.1 - # via pytest -mock==4.0.3 - # via -r test.in -packaging==21.0 - # via - # pytest - # tox -pillow==8.3.1 - # via -r common.in -platformdirs==2.0.2 - # via virtualenv -pluggy==0.13.1 - # via - # pytest - # tox -py==1.10.0 - # via - # -r test.in - # pytest - # tox -pyparsing==2.4.7 - # via packaging -pytest==6.2.4 - # via - # -r test.in - # pytest-cov - # pytest-django - # pytest-ordering - # pytest-pythonpath -pytest-cov==2.12.0 - # via -r test.in -pytest-django==4.3.0 - # via -r test.in -pytest-ordering==0.6 - # via -r test.in -pytest-pythonpath==0.7.3 - # via -r test.in -python-dateutil==2.8.2 - # via faker -python-memcached==1.58 - # via -r common.in pytz==2021.1 - # via - # -r common.in - # django -selenium==3.141.0 - # via -r test.in + # via django six==1.16.0 # via - # -r common.in # django-debug-toolbar-force # django-ormex - # python-dateutil - # python-memcached - # tox - # virtualenv sqlparse==0.4.1 # via # django # django-debug-toolbar -text-unidecode==1.3 - # via faker -toml==0.10.2 - # via - # coverage - # pytest - # tox -tox==3.23.1 - # via -r test.in -urllib3==1.26.6 - # via selenium -virtualenv==20.6.0 - # via tox diff --git a/examples/requirements/django_3_1_and_elastic_6x.txt b/examples/requirements/django_3_1_and_elastic_6x.txt index f10d9c2f..fb88dba3 100644 --- a/examples/requirements/django_3_1_and_elastic_6x.txt +++ b/examples/requirements/django_3_1_and_elastic_6x.txt @@ -1,21 +1,13 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile django_3_1_and_elastic_6x.in # +anysearch==0.2.2 + # via -r django_3_1.in asgiref==3.4.1 # via django -attrs==21.2.0 - # via pytest -backports.entry-points-selectable==1.1.0 - # via virtualenv -coverage[toml]==5.5 - # via - # -r test.in - # pytest-cov -distlib==0.3.2 - # via virtualenv django==3.1.13 # via # -r django_3_1.in @@ -31,7 +23,7 @@ django-debug-toolbar-force==0.1.8 # via -r django_3_1.in django-elasticsearch-debug-toolbar==2.0.0 # via -r django_3_1.in -https://github.com/django-es/django-elasticsearch-dsl/archive/dbbbfac01e4ba85c5e991fb1c0522404f170bdc0.zip +django-elasticsearch-dsl==6.5.0 # via -r elastic_6x.in django-nine==0.2.4 # via @@ -49,93 +41,20 @@ elasticsearch-dsl==6.4.0 # via # -r elastic_6x.in # django-elasticsearch-dsl -factory_boy==2.11.1 - # via -r test.in -faker==8.1.4 - # via - # -r test.in - # factory-boy -filelock==3.0.12 - # via - # tox - # virtualenv -iniconfig==1.1.1 - # via pytest -mock==4.0.3 - # via -r test.in -packaging==21.0 - # via - # pytest - # tox -pillow==8.3.1 - # via -r common.in -platformdirs==2.1.0 - # via virtualenv -pluggy==0.13.1 - # via - # pytest - # tox -py==1.10.0 - # via - # -r test.in - # pytest - # tox -pyparsing==2.4.7 - # via packaging -pytest==6.2.4 - # via - # -r test.in - # pytest-cov - # pytest-django - # pytest-ordering - # pytest-pythonpath -pytest-cov==2.12.0 - # via -r test.in -pytest-django==4.3.0 - # via -r test.in -pytest-ordering==0.6 - # via -r test.in -pytest-pythonpath==0.7.3 - # via -r test.in python-dateutil==2.8.2 - # via - # elasticsearch-dsl - # faker -python-memcached==1.58 - # via -r common.in + # via elasticsearch-dsl pytz==2021.1 - # via - # -r common.in - # django -selenium==3.141.0 - # via -r test.in + # via django six==1.16.0 # via - # -r common.in # django-debug-toolbar-force # django-elasticsearch-dsl # django-ormex # elasticsearch-dsl # python-dateutil - # python-memcached - # tox - # virtualenv sqlparse==0.4.1 # via # django # django-debug-toolbar -text-unidecode==1.3 - # via faker -toml==0.10.2 - # via - # coverage - # pytest - # tox -tox==3.23.1 - # via -r test.in urllib3==1.26.6 - # via - # elasticsearch - # selenium -virtualenv==20.6.0 - # via tox + # via elasticsearch diff --git a/examples/requirements/django_3_1_and_elastic_7x.txt b/examples/requirements/django_3_1_and_elastic_7x.txt index fb7a971c..7b34841f 100644 --- a/examples/requirements/django_3_1_and_elastic_7x.txt +++ b/examples/requirements/django_3_1_and_elastic_7x.txt @@ -1,23 +1,17 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile django_3_1_and_elastic_7x.in # +anysearch==0.2.2 + # via + # -r django_3_1.in + # django-anysearch-dsl asgiref==3.4.1 # via django -attrs==21.2.0 - # via pytest -backports.entry-points-selectable==1.1.0 - # via virtualenv certifi==2021.5.30 # via elasticsearch -coverage[toml]==5.5 - # via - # -r test.in - # pytest-cov -distlib==0.3.2 - # via virtualenv django==3.1.13 # via # -r django_3_1.in @@ -25,6 +19,8 @@ django==3.1.13 # django-debug-toolbar # django-nine # djangorestframework +django-anysearch-dsl==7.2.2.1 + # via -r elastic_7x.in django-cors-headers==3.6.0 # via -r django_3_1.in django-debug-toolbar==3.2.1 @@ -33,8 +29,6 @@ django-debug-toolbar-force==0.1.8 # via -r django_3_1.in django-elasticsearch-debug-toolbar==2.0.0 # via -r django_3_1.in -django-elasticsearch-dsl==7.1.4 - # via -r elastic_7x.in django-nine==0.2.4 # via # django-debug-toolbar-force @@ -48,96 +42,21 @@ elasticsearch==7.10.1 # -r elastic_7x.in # elasticsearch-dsl elasticsearch-dsl==7.3.0 - # via - # -r elastic_7x.in - # django-elasticsearch-dsl -factory_boy==2.11.1 - # via -r test.in -faker==8.1.4 - # via - # -r test.in - # factory-boy -filelock==3.0.12 - # via - # tox - # virtualenv -iniconfig==1.1.1 - # via pytest -mock==4.0.3 - # via -r test.in -packaging==21.0 - # via - # pytest - # tox -pillow==8.3.1 - # via -r common.in -platformdirs==2.1.0 - # via virtualenv -pluggy==0.13.1 - # via - # pytest - # tox -py==1.10.0 - # via - # -r test.in - # pytest - # tox -pyparsing==2.4.7 - # via packaging -pytest==6.2.4 - # via - # -r test.in - # pytest-cov - # pytest-django - # pytest-ordering - # pytest-pythonpath -pytest-cov==2.12.0 - # via -r test.in -pytest-django==4.3.0 - # via -r test.in -pytest-ordering==0.6 - # via -r test.in -pytest-pythonpath==0.7.3 - # via -r test.in + # via -r elastic_7x.in python-dateutil==2.8.2 - # via - # elasticsearch-dsl - # faker -python-memcached==1.58 - # via -r common.in + # via elasticsearch-dsl pytz==2021.1 - # via - # -r common.in - # django -selenium==3.141.0 - # via -r test.in + # via django six==1.16.0 # via - # -r common.in + # django-anysearch-dsl # django-debug-toolbar-force - # django-elasticsearch-dsl # django-ormex # elasticsearch-dsl # python-dateutil - # python-memcached - # tox - # virtualenv sqlparse==0.4.1 # via # django # django-debug-toolbar -text-unidecode==1.3 - # via faker -toml==0.10.2 - # via - # coverage - # pytest - # tox -tox==3.23.1 - # via -r test.in urllib3==1.26.6 - # via - # elasticsearch - # selenium -virtualenv==20.6.0 - # via tox + # via elasticsearch diff --git a/examples/requirements/django_3_2.in b/examples/requirements/django_3_2.in index 5856a981..ee391aff 100644 --- a/examples/requirements/django_3_2.in +++ b/examples/requirements/django_3_2.in @@ -1,3 +1,7 @@ +#-r common.in +#-r test.in + +anysearch>=0.1.5 Django>=3.2,<3.3 django-cors-headers==3.7.0 django-debug-toolbar>=3.2 @@ -5,4 +9,3 @@ django-debug-toolbar-force>=0.1.7 django-elasticsearch-debug-toolbar>=2.0 django-ormex>=0.2.1 djangorestframework>=3.12.0,<3.13 - diff --git a/examples/requirements/django_3_2.txt b/examples/requirements/django_3_2.txt index 1ce87b70..1d8ddad0 100644 --- a/examples/requirements/django_3_2.txt +++ b/examples/requirements/django_3_2.txt @@ -1,9 +1,11 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile django_3_2.in # +anysearch==0.2.2 + # via -r django_3_2.in asgiref==3.4.1 # via django django==3.2.5 diff --git a/examples/requirements/django_3_2_and_elastic_6x.txt b/examples/requirements/django_3_2_and_elastic_6x.txt index 6386d622..60b26703 100644 --- a/examples/requirements/django_3_2_and_elastic_6x.txt +++ b/examples/requirements/django_3_2_and_elastic_6x.txt @@ -1,9 +1,11 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile django_3_2_and_elastic_6x.in # +anysearch==0.2.2 + # via -r django_3_2.in asgiref==3.4.1 # via django django==3.2.5 @@ -21,7 +23,7 @@ django-debug-toolbar-force==0.1.8 # via -r django_3_2.in django-elasticsearch-debug-toolbar==2.0.0 # via -r django_3_2.in -https://github.com/django-es/django-elasticsearch-dsl/archive/dbbbfac01e4ba85c5e991fb1c0522404f170bdc0.zip +django-elasticsearch-dsl==6.5.0 # via -r elastic_6x.in django-nine==0.2.4 # via diff --git a/examples/requirements/django_3_2_and_elastic_7x.txt b/examples/requirements/django_3_2_and_elastic_7x.txt index 7a5825f2..f214b47a 100644 --- a/examples/requirements/django_3_2_and_elastic_7x.txt +++ b/examples/requirements/django_3_2_and_elastic_7x.txt @@ -1,9 +1,13 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile django_3_2_and_elastic_7x.in # +anysearch==0.2.2 + # via + # -r django_3_2.in + # django-anysearch-dsl asgiref==3.4.1 # via django certifi==2021.5.30 @@ -15,6 +19,8 @@ django==3.2.5 # django-debug-toolbar # django-nine # djangorestframework +django-anysearch-dsl==7.2.2.1 + # via -r elastic_7x.in django-cors-headers==3.7.0 # via -r django_3_2.in django-debug-toolbar==3.2.1 @@ -23,8 +29,6 @@ django-debug-toolbar-force==0.1.8 # via -r django_3_2.in django-elasticsearch-debug-toolbar==2.0.0 # via -r django_3_2.in -django-elasticsearch-dsl==7.1.4 - # via -r elastic_7x.in django-nine==0.2.4 # via # django-debug-toolbar-force @@ -38,17 +42,15 @@ elasticsearch==7.10.1 # -r elastic_7x.in # elasticsearch-dsl elasticsearch-dsl==7.3.0 - # via - # -r elastic_7x.in - # django-elasticsearch-dsl + # via -r elastic_7x.in python-dateutil==2.8.2 # via elasticsearch-dsl pytz==2021.1 # via django six==1.16.0 # via + # django-anysearch-dsl # django-debug-toolbar-force - # django-elasticsearch-dsl # django-ormex # elasticsearch-dsl # python-dateutil diff --git a/examples/requirements/docs.txt b/examples/requirements/docs.txt index 415d279d..e5418497 100644 --- a/examples/requirements/docs.txt +++ b/examples/requirements/docs.txt @@ -1,6 +1,6 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile docs.in # @@ -55,7 +55,7 @@ rinoh-typeface-texgyreheros==0.1.1 # via rinohtype rinoh-typeface-texgyrepagella==0.1.1 # via rinohtype -https://github.com/barseghyanartur/rinohtype/archive/0.3.1.zip +rinohtype @ https://github.com/barseghyanartur/rinohtype/archive/0.3.1.zip # via # -r docs.in # rinoh-typeface-dejavuserif diff --git a/examples/requirements/documentation.txt b/examples/requirements/documentation.txt index 9222e182..41608fd1 100644 --- a/examples/requirements/documentation.txt +++ b/examples/requirements/documentation.txt @@ -1,11 +1,13 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile documentation.in # alabaster==0.7.12 # via sphinx +anysearch==0.2.2 + # via -r django_3_2.in asgiref==3.4.1 # via django babel==2.9.1 @@ -82,7 +84,7 @@ rinoh-typeface-texgyreheros==0.1.1 # via rinohtype rinoh-typeface-texgyrepagella==0.1.1 # via rinohtype -https://github.com/barseghyanartur/rinohtype/archive/0.3.1.zip +rinohtype @ https://github.com/barseghyanartur/rinohtype/archive/0.3.1.zip # via # -r docs.in # rinoh-typeface-dejavuserif diff --git a/examples/requirements/elastic.txt b/examples/requirements/elastic.txt index 89857eef..2e7c336a 100644 --- a/examples/requirements/elastic.txt +++ b/examples/requirements/elastic.txt @@ -1,26 +1,26 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile elastic.in # +anysearch==0.2.2 + # via django-anysearch-dsl certifi==2021.5.30 # via elasticsearch -django-elasticsearch-dsl==7.1.4 +django-anysearch-dsl==7.2.2.1 # via -r elastic_7x.in elasticsearch==7.10.1 # via # -r elastic_7x.in # elasticsearch-dsl elasticsearch-dsl==7.3.0 - # via - # -r elastic_7x.in - # django-elasticsearch-dsl + # via -r elastic_7x.in python-dateutil==2.8.2 # via elasticsearch-dsl six==1.16.0 # via - # django-elasticsearch-dsl + # django-anysearch-dsl # elasticsearch-dsl # python-dateutil urllib3==1.26.6 diff --git a/examples/requirements/elastic_6x.in b/examples/requirements/elastic_6x.in index f3b3c6fd..a7ce7807 100644 --- a/examples/requirements/elastic_6x.in +++ b/examples/requirements/elastic_6x.in @@ -1,6 +1,6 @@ elasticsearch==6.3.0 elasticsearch-dsl==6.4.0 -#django-elasticsearch-dsl==6.4.2 +django-elasticsearch-dsl==6.5.0 # Pinned to the latest commit (as of 2021-02-02) of the # branch https://github.com/django-es/django-elasticsearch-dsl/tree/6.x -https://github.com/django-es/django-elasticsearch-dsl/archive/dbbbfac01e4ba85c5e991fb1c0522404f170bdc0.zip +# https://github.com/django-es/django-elasticsearch-dsl/archive/dbbbfac01e4ba85c5e991fb1c0522404f170bdc0.zip diff --git a/examples/requirements/elastic_6x.txt b/examples/requirements/elastic_6x.txt index dcfec071..f7eb2e72 100644 --- a/examples/requirements/elastic_6x.txt +++ b/examples/requirements/elastic_6x.txt @@ -1,10 +1,10 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile elastic_6x.in # -https://github.com/django-es/django-elasticsearch-dsl/archive/dbbbfac01e4ba85c5e991fb1c0522404f170bdc0.zip +django-elasticsearch-dsl==6.5.0 # via -r elastic_6x.in elasticsearch==6.3.0 # via diff --git a/examples/requirements/elastic_7x.in b/examples/requirements/elastic_7x.in index b512b51a..be2379ce 100644 --- a/examples/requirements/elastic_7x.in +++ b/examples/requirements/elastic_7x.in @@ -1,3 +1,3 @@ elasticsearch==7.10.1 #7.0.2 elasticsearch-dsl==7.3.0 #7.0.0 -django-elasticsearch-dsl==7.1.4 +django-anysearch-dsl diff --git a/examples/requirements/elastic_7x.txt b/examples/requirements/elastic_7x.txt index a1c2f5ed..68291433 100644 --- a/examples/requirements/elastic_7x.txt +++ b/examples/requirements/elastic_7x.txt @@ -1,26 +1,26 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile elastic_7x.in # +anysearch==0.2.2 + # via django-anysearch-dsl certifi==2021.5.30 # via elasticsearch -django-elasticsearch-dsl==7.1.4 +django-anysearch-dsl==7.2.2.1 # via -r elastic_7x.in elasticsearch==7.10.1 # via # -r elastic_7x.in # elasticsearch-dsl elasticsearch-dsl==7.3.0 - # via - # -r elastic_7x.in - # django-elasticsearch-dsl + # via -r elastic_7x.in python-dateutil==2.8.2 # via elasticsearch-dsl six==1.16.0 # via - # django-elasticsearch-dsl + # django-anysearch-dsl # elasticsearch-dsl # python-dateutil urllib3==1.26.6 diff --git a/examples/requirements/elastic_docker.txt b/examples/requirements/elastic_docker.txt index f90331c3..05d80195 100644 --- a/examples/requirements/elastic_docker.txt +++ b/examples/requirements/elastic_docker.txt @@ -1,6 +1,6 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile elastic_docker.in # diff --git a/examples/requirements/opensearch_1x.in b/examples/requirements/opensearch_1x.in new file mode 100644 index 00000000..df4cf54b --- /dev/null +++ b/examples/requirements/opensearch_1x.in @@ -0,0 +1,4 @@ +opensearch-py>=1.0.0,<2.0 +opensearch-dsl>=1.0.0,<2.0 +django-anysearch-dsl +requests diff --git a/examples/requirements/opensearch_1x.txt b/examples/requirements/opensearch_1x.txt new file mode 100644 index 00000000..8c296635 --- /dev/null +++ b/examples/requirements/opensearch_1x.txt @@ -0,0 +1,37 @@ +# +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: +# +# pip-compile opensearch_1x.in +# +anysearch==0.2.2 + # via django-anysearch-dsl +certifi==2022.12.7 + # via + # opensearch-py + # requests +charset-normalizer==2.1.1 + # via requests +django-anysearch-dsl==7.2.2.1 + # via -r opensearch_1x.in +idna==3.4 + # via requests +opensearch-dsl==1.0.0 + # via -r opensearch_1x.in +opensearch-py==1.1.0 + # via + # -r opensearch_1x.in + # opensearch-dsl +python-dateutil==2.8.2 + # via opensearch-dsl +requests==2.28.1 + # via -r opensearch_1x.in +six==1.16.0 + # via + # django-anysearch-dsl + # opensearch-dsl + # python-dateutil +urllib3==1.26.13 + # via + # opensearch-py + # requests diff --git a/examples/requirements/opensearch_2x.in b/examples/requirements/opensearch_2x.in new file mode 100644 index 00000000..b5765e19 --- /dev/null +++ b/examples/requirements/opensearch_2x.in @@ -0,0 +1,4 @@ +opensearch-py>=2.0.0,<3.0.0 +opensearch-dsl>=2.0.0,<3.0.0 +django-anysearch-dsl +requests diff --git a/examples/requirements/opensearch_2x.txt b/examples/requirements/opensearch_2x.txt new file mode 100644 index 00000000..bb72b439 --- /dev/null +++ b/examples/requirements/opensearch_2x.txt @@ -0,0 +1,39 @@ +# +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: +# +# pip-compile opensearch_2x.in +# +anysearch==0.2.2 + # via django-anysearch-dsl +certifi==2022.12.7 + # via + # opensearch-py + # requests +charset-normalizer==2.1.1 + # via requests +django-anysearch-dsl==7.2.2.1 + # via -r opensearch_2x.in +idna==3.4 + # via requests +opensearch-dsl==2.0.1 + # via -r opensearch_2x.in +opensearch-py==2.0.1 + # via + # -r opensearch_2x.in + # opensearch-dsl +python-dateutil==2.8.2 + # via opensearch-dsl +requests==2.28.1 + # via + # -r opensearch_2x.in + # opensearch-py +six==1.16.0 + # via + # django-anysearch-dsl + # opensearch-dsl + # python-dateutil +urllib3==1.26.13 + # via + # opensearch-py + # requests diff --git a/examples/requirements/test.txt b/examples/requirements/test.txt index 2861f4c9..14d5f5de 100644 --- a/examples/requirements/test.txt +++ b/examples/requirements/test.txt @@ -1,12 +1,12 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile test.in # attrs==21.2.0 # via pytest -backports.entry-points-selectable==1.1.0 +backports-entry-points-selectable==1.1.0 # via virtualenv coverage[toml]==5.5 # via @@ -14,7 +14,7 @@ coverage[toml]==5.5 # pytest-cov distlib==0.3.2 # via virtualenv -factory_boy==2.11.1 +factory-boy==2.11.1 # via -r test.in faker==8.1.4 # via diff --git a/examples/requirements/testing.txt b/examples/requirements/testing.txt index 6efef11d..6e07eacf 100644 --- a/examples/requirements/testing.txt +++ b/examples/requirements/testing.txt @@ -1,14 +1,16 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile testing.in # +anysearch==0.2.2 + # via -r django_3_2.in asgiref==3.4.1 # via django attrs==21.2.0 # via pytest -backports.entry-points-selectable==1.1.0 +backports-entry-points-selectable==1.1.0 # via virtualenv coverage[toml]==5.5 # via @@ -39,7 +41,7 @@ django-ormex==0.2.1 # via -r django_3_2.in djangorestframework==3.12.4 # via -r django_3_2.in -factory_boy==2.11.1 +factory-boy==2.11.1 # via -r test.in faker==8.1.4 # via diff --git a/examples/simple/manage.py b/examples/simple/manage.py index f9726f9e..071a549a 100755 --- a/examples/simple/manage.py +++ b/examples/simple/manage.py @@ -4,6 +4,8 @@ if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") + # os.environ.setdefault("ANYSEARCH_PREFERRED_BACKEND", "OpenSearch") + os.environ.setdefault("ANYSEARCH_PREFERRED_BACKEND", "Elasticsearch") from django.core.management import execute_from_command_line diff --git a/examples/simple/search_indexes/documents/address.py b/examples/simple/search_indexes/documents/address.py index 19dc1d00..2e8ec0ee 100644 --- a/examples/simple/search_indexes/documents/address.py +++ b/examples/simple/search_indexes/documents/address.py @@ -1,6 +1,7 @@ +from anysearch import OPENSEARCH, SEARCH_BACKEND +from django_elasticsearch_dsl import Document, fields +from django_elasticsearch_dsl.registries import registry from django.conf import settings - -from django_elasticsearch_dsl import Document, Index, fields from django_elasticsearch_dsl_drf.compat import KeywordField, StringField from django_elasticsearch_dsl_drf.versions import ELASTICSEARCH_GTE_5_0 @@ -11,18 +12,8 @@ __all__ = ('AddressDocument',) -INDEX = Index(settings.ELASTICSEARCH_INDEX_NAMES[__name__]) - -# See Elasticsearch Indices API reference for available settings -INDEX.settings( - number_of_shards=1, - number_of_replicas=1, - blocks={'read_only_allow_delete': False}, - # read_only_allow_delete=False -) - -@INDEX.doc_type +@registry.register_document class AddressDocument(Document): """Address Elasticsearch document.""" @@ -43,7 +34,7 @@ class AddressDocument(Document): } - if ELASTICSEARCH_GTE_5_0: + if ELASTICSEARCH_GTE_5_0 or SEARCH_BACKEND == OPENSEARCH: __street_fields.update( { 'suggest_context': fields.CompletionField( @@ -200,6 +191,15 @@ class AddressDocument(Document): attr='location_field_indexing', ) + # See Elasticsearch Indices API reference for available settings + class Index: + name = settings.ELASTICSEARCH_INDEX_NAMES[__name__] + settings = { + "number_of_shards": 1, + "number_of_replicas": 1, + "blocks": {"read_only_allow_delete": False}, + } + class Django(object): model = Address # The model associate with this Document diff --git a/examples/simple/search_indexes/documents/analyzers.py b/examples/simple/search_indexes/documents/analyzers.py index 2a108561..59bbdf3a 100644 --- a/examples/simple/search_indexes/documents/analyzers.py +++ b/examples/simple/search_indexes/documents/analyzers.py @@ -1,4 +1,5 @@ -from elasticsearch_dsl import analyzer +from anysearch import OPENSEARCH, SEARCH_BACKEND +from anysearch.search_dsl import analyzer from django_elasticsearch_dsl_drf.versions import ELASTICSEARCH_GTE_7_0 __all__ = ( @@ -6,7 +7,7 @@ ) # The ``standard`` filter has been removed in Elasticsearch 7.x. -if ELASTICSEARCH_GTE_7_0: +if ELASTICSEARCH_GTE_7_0 or SEARCH_BACKEND == OPENSEARCH: _filters = ["lowercase", "stop", "snowball"] else: _filters = ["standard", "lowercase", "stop", "snowball"] diff --git a/examples/simple/search_indexes/documents/author.py b/examples/simple/search_indexes/documents/author.py index 0b26e7b4..404b0889 100644 --- a/examples/simple/search_indexes/documents/author.py +++ b/examples/simple/search_indexes/documents/author.py @@ -1,6 +1,7 @@ from django.conf import settings -from django_elasticsearch_dsl import Document, Index, fields +from django_elasticsearch_dsl import Document, fields +from django_elasticsearch_dsl.registries import registry from django_elasticsearch_dsl_drf.compat import KeywordField, StringField from django_elasticsearch_dsl_drf.analyzers import edge_ngram_completion @@ -8,18 +9,8 @@ __all__ = ('AuthorDocument',) -INDEX = Index(settings.ELASTICSEARCH_INDEX_NAMES[__name__]) -# See Elasticsearch Indices API reference for available settings -INDEX.settings( - number_of_shards=1, - number_of_replicas=1, - blocks={'read_only_allow_delete': False}, - # read_only_allow_delete=False -) - - -@INDEX.doc_type +@registry.register_document class AuthorDocument(Document): """Author Elasticsearch document.""" @@ -61,6 +52,15 @@ class AuthorDocument(Document): headshot = StringField(attr='headshot_indexing') + # See Elasticsearch Indices API reference for available settings + class Index: + name = settings.ELASTICSEARCH_INDEX_NAMES[__name__] + settings = { + "number_of_shards": 1, + "number_of_replicas": 1, + "blocks": {"read_only_allow_delete": False}, + } + class Django(object): model = Author # The model associate with this Document diff --git a/examples/simple/search_indexes/documents/book.py b/examples/simple/search_indexes/documents/book.py index 68d7b6c8..6edb37d1 100644 --- a/examples/simple/search_indexes/documents/book.py +++ b/examples/simple/search_indexes/documents/book.py @@ -1,6 +1,7 @@ +from anysearch import OPENSEARCH, SEARCH_BACKEND +from django_elasticsearch_dsl import Document, fields +from django_elasticsearch_dsl.registries import registry from django.conf import settings - -from django_elasticsearch_dsl import Document, Index, fields from django_elasticsearch_dsl_drf.compat import KeywordField, StringField from django_elasticsearch_dsl_drf.analyzers import edge_ngram_completion from django_elasticsearch_dsl_drf.versions import ELASTICSEARCH_GTE_5_0 @@ -12,18 +13,8 @@ __all__ = ('BookDocument',) -INDEX = Index(settings.ELASTICSEARCH_INDEX_NAMES[__name__]) - -# See Elasticsearch Indices API reference for available settings -INDEX.settings( - number_of_shards=1, - number_of_replicas=1, - blocks={'read_only_allow_delete': None}, - # read_only_allow_delete=False -) - -@INDEX.doc_type +@registry.register_document class BookDocument(Document): """Book Elasticsearch document.""" @@ -47,7 +38,7 @@ class BookDocument(Document): 'mlt': StringField(analyzer='english'), } - if ELASTICSEARCH_GTE_5_0: + if ELASTICSEARCH_GTE_5_0 or SEARCH_BACKEND == OPENSEARCH: __title_fields.update( { 'suggest_context': fields.CompletionField( @@ -160,6 +151,15 @@ class BookDocument(Document): null_field = StringField(attr='null_field_indexing') + # See Elasticsearch Indices API reference for available settings + class Index: + name = settings.ELASTICSEARCH_INDEX_NAMES[__name__] + settings = { + "number_of_shards": 1, + "number_of_replicas": 1, + "blocks": {"read_only_allow_delete": False}, + } + class Django(object): model = Book # The model associate with this Document diff --git a/examples/simple/search_indexes/documents/city.py b/examples/simple/search_indexes/documents/city.py index c1885a38..193c37b0 100644 --- a/examples/simple/search_indexes/documents/city.py +++ b/examples/simple/search_indexes/documents/city.py @@ -1,6 +1,7 @@ from django.conf import settings -from django_elasticsearch_dsl import Document, Index, fields +from django_elasticsearch_dsl import Document, fields +from django_elasticsearch_dsl.registries import registry from django_elasticsearch_dsl_drf.compat import KeywordField, StringField from books.models import City @@ -10,18 +11,7 @@ __all__ = ('CityDocument',) -INDEX = Index(settings.ELASTICSEARCH_INDEX_NAMES[__name__]) - -# See Elasticsearch Indices API reference for available settings -INDEX.settings( - number_of_shards=1, - number_of_replicas=1, - blocks={'read_only_allow_delete': False}, - # read_only_allow_delete=False -) - - -@INDEX.doc_type +@registry.register_document class CityDocument(Document): """City Elasticsearch document. @@ -97,6 +87,15 @@ class CityDocument(Document): ) # integer_dict_indexing + # See Elasticsearch Indices API reference for available settings + class Index: + name = settings.ELASTICSEARCH_INDEX_NAMES[__name__] + settings = { + "number_of_shards": 1, + "number_of_replicas": 1, + "blocks": {"read_only_allow_delete": False}, + } + class Django(object): model = City # The model associate with this Document diff --git a/examples/simple/search_indexes/documents/journal.py b/examples/simple/search_indexes/documents/journal.py index 3cf79991..3b4f2827 100644 --- a/examples/simple/search_indexes/documents/journal.py +++ b/examples/simple/search_indexes/documents/journal.py @@ -1,9 +1,8 @@ +from django_elasticsearch_dsl import Document, fields +from django_elasticsearch_dsl.registries import registry from django.conf import settings - -from django_elasticsearch_dsl import Document, Index, fields from django_elasticsearch_dsl_drf.compat import KeywordField, StringField from django_elasticsearch_dsl_drf.analyzers import edge_ngram_completion -from django_elasticsearch_dsl_drf.versions import ELASTICSEARCH_GTE_5_0 from books.models import Journal @@ -12,18 +11,8 @@ __all__ = ('JournalDocument',) -INDEX = Index(settings.ELASTICSEARCH_INDEX_NAMES[__name__]) - -# See Elasticsearch Indices API reference for available settings -INDEX.settings( - number_of_shards=1, - number_of_replicas=1, - blocks={'read_only_allow_delete': None}, - # read_only_allow_delete=False -) - -@INDEX.doc_type +@registry.register_document class JournalDocument(Document): """Journal Elasticsearch document.""" @@ -91,6 +80,15 @@ class JournalDocument(Document): # Date created created = fields.DateField(attr='created_indexing') + # See Elasticsearch Indices API reference for available settings + class Index: + name = settings.ELASTICSEARCH_INDEX_NAMES[__name__] + settings = { + "number_of_shards": 1, + "number_of_replicas": 1, + "blocks": {"read_only_allow_delete": False}, + } + class Django(object): model = Journal # The model associate with this Document diff --git a/examples/simple/search_indexes/documents/location.py b/examples/simple/search_indexes/documents/location.py index 80ed7793..49ee302e 100644 --- a/examples/simple/search_indexes/documents/location.py +++ b/examples/simple/search_indexes/documents/location.py @@ -1,26 +1,17 @@ +from anysearch import SEARCH_BACKEND, OPENSEARCH +from django_elasticsearch_dsl import Document, fields +from django_elasticsearch_dsl.registries import registry from django.conf import settings -from django_elasticsearch_dsl import Document, Index, fields from django_elasticsearch_dsl_drf.compat import KeywordField, StringField from django_elasticsearch_dsl_drf.analyzers import edge_ngram_completion from django_elasticsearch_dsl_drf.versions import ELASTICSEARCH_GTE_5_0 -from elasticsearch_dsl import analyzer from books.models import Location from .analyzers import html_strip -# Name of the Elasticsearch index -INDEX = Index(settings.ELASTICSEARCH_INDEX_NAMES[__name__]) -# See Elasticsearch Indices API reference for available settings -INDEX.settings( - number_of_shards=1, - number_of_replicas=1, - blocks={'read_only_allow_delete': False}, -) - - -@INDEX.doc_type +@registry.register_document class LocationDocument(Document): """ Location document. @@ -34,7 +25,7 @@ class LocationDocument(Document): ), } - if ELASTICSEARCH_GTE_5_0: + if ELASTICSEARCH_GTE_5_0 or SEARCH_BACKEND == OPENSEARCH: __full_fields.update( { "suggest": fields.CompletionField(), @@ -69,7 +60,7 @@ class LocationDocument(Document): analyzer=edge_ngram_completion ), } - if ELASTICSEARCH_GTE_5_0: + if ELASTICSEARCH_GTE_5_0 or SEARCH_BACKEND == OPENSEARCH: __partial_fields.update( { "suggest": fields.CompletionField(), @@ -98,7 +89,7 @@ class LocationDocument(Document): __postcode_fields = { "raw": KeywordField(), } - if ELASTICSEARCH_GTE_5_0: + if ELASTICSEARCH_GTE_5_0 or SEARCH_BACKEND == OPENSEARCH: __postcode_fields.update( { "suggest": fields.CompletionField(), @@ -199,6 +190,15 @@ class LocationDocument(Document): revenue = fields.FloatField(attr="revenue") coordinates = fields.GeoPointField(attr="location_field_indexing") + # See Elasticsearch Indices API reference for available settings + class Index: + name = settings.ELASTICSEARCH_INDEX_NAMES[__name__] + settings = { + "number_of_shards": 1, + "number_of_replicas": 1, + "blocks": {"read_only_allow_delete": False}, + } + class Django(object): model = Location # The model associate with this Document diff --git a/examples/simple/search_indexes/documents/publisher.py b/examples/simple/search_indexes/documents/publisher.py index e7237837..b82cd44c 100644 --- a/examples/simple/search_indexes/documents/publisher.py +++ b/examples/simple/search_indexes/documents/publisher.py @@ -1,6 +1,7 @@ from django.conf import settings -from django_elasticsearch_dsl import Document, Index, fields +from django_elasticsearch_dsl import Document, fields +from django_elasticsearch_dsl.registries import registry from django_elasticsearch_dsl_drf.compat import KeywordField, StringField from django_elasticsearch_dsl_drf.analyzers import edge_ngram_completion @@ -8,18 +9,8 @@ __all__ = ('PublisherDocument',) -INDEX = Index(settings.ELASTICSEARCH_INDEX_NAMES[__name__]) -# See Elasticsearch Indices API reference for available settings -INDEX.settings( - number_of_shards=1, - number_of_replicas=1, - blocks={'read_only_allow_delete': False}, - # read_only_allow_delete=False -) - - -@INDEX.doc_type +@registry.register_document class PublisherDocument(Document): """Publisher Elasticsearch document.""" @@ -84,6 +75,15 @@ class PublisherDocument(Document): location_circle = fields.GeoShapeField(strategy='recursive', attr='location_circle_indexing') + # See Elasticsearch Indices API reference for available settings + class Index: + name = settings.ELASTICSEARCH_INDEX_NAMES[__name__] + settings = { + "number_of_shards": 1, + "number_of_replicas": 1, + "blocks": {"read_only_allow_delete": False}, + } + class Django(object): model = Publisher # The model associate with this Document diff --git a/examples/simple/search_indexes/documents/tag.py b/examples/simple/search_indexes/documents/tag.py index 806a4caa..a5508755 100644 --- a/examples/simple/search_indexes/documents/tag.py +++ b/examples/simple/search_indexes/documents/tag.py @@ -1,22 +1,14 @@ from django.conf import settings -from django_elasticsearch_dsl import Document, Index, fields +from django_elasticsearch_dsl import Document, fields +from django_elasticsearch_dsl.registries import registry from books.models import Tag -from .analyzers import html_strip __all__ = ('TagDocument',) -INDEX = Index(settings.ELASTICSEARCH_INDEX_NAMES[__name__]) -INDEX.settings( - number_of_shards=1, - number_of_replicas=1, - blocks={'read_only_allow_delete': None} -) - - -@INDEX.doc_type +@registry.register_document class TagDocument(Document): """Elasticsearch document for a Tag.""" @@ -24,6 +16,15 @@ class TagDocument(Document): id = fields.KeywordField(attr='title') title = fields.KeywordField() + # See Elasticsearch Indices API reference for available settings + class Index: + name = settings.ELASTICSEARCH_INDEX_NAMES[__name__] + settings = { + "number_of_shards": 1, + "number_of_replicas": 1, + "blocks": {"read_only_allow_delete": False}, + } + class Django(object): """Django Elasticsearch DSL ORM Meta.""" diff --git a/examples/simple/search_indexes/viewsets/book/base.py b/examples/simple/search_indexes/viewsets/book/base.py index 2ea999c5..188e4988 100644 --- a/examples/simple/search_indexes/viewsets/book/base.py +++ b/examples/simple/search_indexes/viewsets/book/base.py @@ -25,7 +25,7 @@ BaseDocumentViewSet, ) -from elasticsearch_dsl import DateHistogramFacet, RangeFacet, A +from anysearch.search_dsl import DateHistogramFacet, RangeFacet, A from ...documents import BookDocument from ...serializers import BookDocumentSimpleSerializer diff --git a/examples/simple/search_indexes/viewsets/book/frontend.py b/examples/simple/search_indexes/viewsets/book/frontend.py index 7e072d37..73d9e344 100644 --- a/examples/simple/search_indexes/viewsets/book/frontend.py +++ b/examples/simple/search_indexes/viewsets/book/frontend.py @@ -32,7 +32,7 @@ ) from django_elasticsearch_dsl_drf.pagination import PageNumberPagination -from elasticsearch_dsl import DateHistogramFacet, RangeFacet +from anysearch.search_dsl import DateHistogramFacet, RangeFacet from rest_framework.decorators import action diff --git a/examples/simple/search_indexes/viewsets/book/permissions.py b/examples/simple/search_indexes/viewsets/book/permissions.py index 826797d1..1b9edba6 100644 --- a/examples/simple/search_indexes/viewsets/book/permissions.py +++ b/examples/simple/search_indexes/viewsets/book/permissions.py @@ -33,7 +33,7 @@ from django_elasticsearch_dsl_drf.pagination import PageNumberPagination from django_elasticsearch_dsl_drf.utils import EmptySearch -from elasticsearch_dsl import DateHistogramFacet, RangeFacet +from anysearch.search_dsl import DateHistogramFacet, RangeFacet from rest_framework.decorators import action from rest_framework.permissions import IsAuthenticated diff --git a/examples/simple/search_indexes/viewsets/journal.py b/examples/simple/search_indexes/viewsets/journal.py index 6ced36e0..a03c4515 100644 --- a/examples/simple/search_indexes/viewsets/journal.py +++ b/examples/simple/search_indexes/viewsets/journal.py @@ -24,7 +24,7 @@ BaseDocumentViewSet, ) -from elasticsearch_dsl import DateHistogramFacet, RangeFacet, A +from anysearch.search_dsl import DateHistogramFacet, RangeFacet, A from ..documents import JournalDocument from ..serializers import JournalDocumentSerializer diff --git a/examples/simple/settings/base.py b/examples/simple/settings/base.py index dfd72ff1..37ea4ff8 100644 --- a/examples/simple/settings/base.py +++ b/examples/simple/settings/base.py @@ -2,6 +2,7 @@ import os import sys +from anysearch import OPENSEARCH, SEARCH_BACKEND from django_nine import versions from .core import PROJECT_DIR, gettext @@ -240,10 +241,12 @@ # Third party apps 'rest_framework', # REST framework - 'django_elasticsearch_dsl', # Elasticsearch integration + 'corsheaders', # For React demo # This app + # 'anysearch.django_search_dsl.DjangoAnySearchConfig', + 'django_elasticsearch_dsl', 'django_elasticsearch_dsl_drf', # Other project specific apps @@ -252,6 +255,11 @@ 'search_indexes', # Search app ] +# if SEARCH_BACKEND == OPENSEARCH: +# INSTALLED_APPS.append('django_opensearch_dsl') # OpenSearch integration +# else: +# INSTALLED_APPS.append('django_elasticsearch_dsl') # Elasticsearch integration + REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.BasicAuthentication', @@ -270,6 +278,10 @@ 'timeout': 30, }, } +OPENSEARCH_DSL = ELASTICSEARCH_DSL + +# ELASTICSEARCH_DSL_SIGNAL_PROCESSOR = "anysearch.django_search_dsl.RealTimeSignalProcessor" +# OPENSEARCH_DSL_SIGNAL_PROCESSOR = ELASTICSEARCH_DSL_SIGNAL_PROCESSOR # CORS headers config CORS_ORIGIN_ALLOW_ALL = True diff --git a/examples/simple/settings/docker.py b/examples/simple/settings/docker.py index 21efe135..dfacc2e9 100644 --- a/examples/simple/settings/docker.py +++ b/examples/simple/settings/docker.py @@ -36,3 +36,4 @@ 'timeout': 30, }, } +OPENSEARCH_DSL = ELASTICSEARCH_DSL diff --git a/runtests.py b/runtests.py index 98d5da49..94b04bb8 100755 --- a/runtests.py +++ b/runtests.py @@ -7,6 +7,8 @@ def main(): os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.testing") + # os.environ.setdefault("ANYSEARCH_PREFERRED_BACKEND", "OpenSearch") + os.environ.setdefault("ANYSEARCH_PREFERRED_BACKEND", "Elasticsearch") sys.path.insert(0, "src") sys.path.insert(0, "examples/simple") return pytest.main() diff --git a/scripts/compile_requirements.sh b/scripts/compile_requirements.sh index 34a771a4..ca6a158d 100755 --- a/scripts/compile_requirements.sh +++ b/scripts/compile_requirements.sh @@ -22,5 +22,7 @@ pip-compile elastic.in "$@" pip-compile elastic_6x.in "$@" pip-compile elastic_7x.in "$@" pip-compile elastic_docker.in "$@" +pip-compile opensearch_1x.in "$@" +pip-compile opensearch_2x.in "$@" pip-compile test.in "$@" pip-compile testing.in "$@" diff --git a/scripts/rebuild_index.sh b/scripts/rebuild_index.sh index 64074a57..50123aa9 100755 --- a/scripts/rebuild_index.sh +++ b/scripts/rebuild_index.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash cd examples/simple/ ./manage.py search_index --rebuild -f --settings=settings.dev "$@" - +./manage.py opensearch --settings=settings.dev "$@" index rebuild --force diff --git a/setup.py b/setup.py index dd059962..a86d6e37 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import find_packages, setup -version = '0.22.5' +version = '0.23' DOCS_TRANSFORMATIONS = ( ( @@ -158,10 +158,8 @@ install_requires = [ 'six>=1.9', 'django-nine>=0.2', - 'django-elasticsearch-dsl>=6.4.1', - 'elasticsearch-dsl', - 'elasticsearch', 'djangorestframework', + 'anysearch>=0.1.7', ] extras_require = [] @@ -204,15 +202,29 @@ "Changelog": "https://django-elasticsearch-dsl-drf.readthedocs.io/" "en/latest/changelog.html", }, - keywords="django, elasticsearch, elasticsearch-dsl, django rest framework", + keywords="django, elasticsearch, elasticsearch-dsl, " + "django-elasticsearch-dsl, opensearch, opensearch-dsl, " + "django-opensearch-dsl, django-rest-framework", author='Artur Barseghyan', author_email='artur.barseghyan@gmail.com', url='https://github.com/barseghyanartur/django-elasticsearch-dsl-drf/', package_dir={'': 'src'}, packages=find_packages(where='./src'), license='GPL-2.0-only OR LGPL-2.1-or-later', - python_requires=">=2.7", + python_requires=">=3.6", install_requires=(install_requires + extras_require), + extras_require={ + "elasticsearch": [ + "elasticsearch", + "elasticsearch-dsl", + "django-elasticsearch-dsl>=6.4.1", + ], + "opensearch": [ + "opensearch", + "opensearch-dsl", + "django-opensearch-dsl", + ], + }, tests_require=tests_require, include_package_data=True, ) diff --git a/src/django_elasticsearch_dsl_drf/analyzers.py b/src/django_elasticsearch_dsl_drf/analyzers.py index 32f58f7c..5f8ac8b6 100644 --- a/src/django_elasticsearch_dsl_drf/analyzers.py +++ b/src/django_elasticsearch_dsl_drf/analyzers.py @@ -1,12 +1,12 @@ """ Analyzers. """ -from elasticsearch_dsl import analyzer -from elasticsearch_dsl.analysis import token_filter +from anysearch.search_dsl import analyzer +from anysearch.search_dsl.analysis import token_filter __title__ = 'django_elasticsearch_dsl_drf.analyzers' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'edge_ngram_completion_filter', diff --git a/src/django_elasticsearch_dsl_drf/apps.py b/src/django_elasticsearch_dsl_drf/apps.py index 434623d9..e398ff92 100644 --- a/src/django_elasticsearch_dsl_drf/apps.py +++ b/src/django_elasticsearch_dsl_drf/apps.py @@ -6,7 +6,7 @@ __title__ = 'django_elasticsearch_dsl_drf.apps' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('Config',) diff --git a/src/django_elasticsearch_dsl_drf/compat.py b/src/django_elasticsearch_dsl_drf/compat.py index f5e9211b..6467b05d 100644 --- a/src/django_elasticsearch_dsl_drf/compat.py +++ b/src/django_elasticsearch_dsl_drf/compat.py @@ -5,10 +5,11 @@ Elastic 5.x as soon as possible. """ +from anysearch import IS_OPENSEARCH from django_elasticsearch_dsl import fields # For compatibility reasons -from .versions import get_elasticsearch_version +from .versions import ELASTICSEARCH_LTE_6_0 #, get_elasticsearch_version try: import coreapi @@ -27,7 +28,7 @@ __title__ = 'django_elasticsearch_dsl_drf.compat' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'coreapi', @@ -35,6 +36,7 @@ # 'get_count', 'KeywordField', 'StringField', + 'nested_sort_entry', ) @@ -76,8 +78,9 @@ def nested_sort_entry(path, split_path=True): :return: Dictionary of full nested path :rtype: dict """ - version = get_elasticsearch_version() - if version[0] < 6 or (version[0] == 6 and version[1] < 1): + # version = get_elasticsearch_version() + # if version[0] < 6 or (version[0] == 6 and version[1] < 1): + if ELASTICSEARCH_LTE_6_0 and not IS_OPENSEARCH: return {'nested_path': path} nested_path = {} path_list = path.split('.') if split_path else [path] diff --git a/src/django_elasticsearch_dsl_drf/constants.py b/src/django_elasticsearch_dsl_drf/constants.py index fde6d387..f78c6aae 100644 --- a/src/django_elasticsearch_dsl_drf/constants.py +++ b/src/django_elasticsearch_dsl_drf/constants.py @@ -5,7 +5,7 @@ __title__ = 'django_elasticsearch_dsl_drf.constants' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'ALL_FUNCTIONAL_SUGGESTERS', diff --git a/src/django_elasticsearch_dsl_drf/elasticsearch_helpers.py b/src/django_elasticsearch_dsl_drf/elasticsearch_helpers.py index 3f3e3ac8..be5f1ffc 100644 --- a/src/django_elasticsearch_dsl_drf/elasticsearch_helpers.py +++ b/src/django_elasticsearch_dsl_drf/elasticsearch_helpers.py @@ -1,6 +1,10 @@ +from anysearch.search import AnySearch from django.conf import settings -from elasticsearch import Elasticsearch +__title__ = 'django_elasticsearch_dsl_drf.elasticsearch_helpers' +__author__ = 'Artur Barseghyan ' +__copyright__ = '2017-2022 Artur Barseghyan' +__license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( "get_all_indices", "delete_all_indices", @@ -14,7 +18,7 @@ def get_all_indices(with_protected=False): Returns: list: List of indices. """ - es = Elasticsearch(**settings.ELASTICSEARCH_DSL["default"]) + es = AnySearch(**settings.ELASTICSEARCH_DSL["default"]) _indices = es.indices.get_alias("*").items() if with_protected: return [_i for _i, _o in _indices] @@ -29,7 +33,7 @@ def delete_all_indices(with_protected=False): Returns: tuple: Tuple of two lists with removed and errored indices. """ - es = Elasticsearch(**settings.ELASTICSEARCH_DSL["default"]) + es = AnySearch(**settings.ELASTICSEARCH_DSL["default"]) _indices = get_all_indices(with_protected=with_protected) _ok = [] _fail = [] diff --git a/src/django_elasticsearch_dsl_drf/fields/__init__.py b/src/django_elasticsearch_dsl_drf/fields/__init__.py index 4f52c4f8..fc88c168 100644 --- a/src/django_elasticsearch_dsl_drf/fields/__init__.py +++ b/src/django_elasticsearch_dsl_drf/fields/__init__.py @@ -20,7 +20,7 @@ __title__ = 'django_elasticsearch_dsl_drf.fields' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'BooleanField', diff --git a/src/django_elasticsearch_dsl_drf/fields/common.py b/src/django_elasticsearch_dsl_drf/fields/common.py index 5ffb0746..e025c25f 100644 --- a/src/django_elasticsearch_dsl_drf/fields/common.py +++ b/src/django_elasticsearch_dsl_drf/fields/common.py @@ -7,7 +7,7 @@ __title__ = 'django_elasticsearch_dsl_drf.fields.nested_fields' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'BooleanField', diff --git a/src/django_elasticsearch_dsl_drf/fields/helpers.py b/src/django_elasticsearch_dsl_drf/fields/helpers.py index 4d33ed51..94ab22a3 100644 --- a/src/django_elasticsearch_dsl_drf/fields/helpers.py +++ b/src/django_elasticsearch_dsl_drf/fields/helpers.py @@ -1,11 +1,11 @@ """ Helpers. """ -from elasticsearch_dsl.utils import AttrDict, AttrList +from anysearch.search_dsl.utils import AttrDict, AttrList __title__ = 'django_elasticsearch_dsl_drf.fields.helpers' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('to_representation',) diff --git a/src/django_elasticsearch_dsl_drf/fields/nested_fields.py b/src/django_elasticsearch_dsl_drf/fields/nested_fields.py index 55369fe9..2073d063 100644 --- a/src/django_elasticsearch_dsl_drf/fields/nested_fields.py +++ b/src/django_elasticsearch_dsl_drf/fields/nested_fields.py @@ -7,7 +7,7 @@ __title__ = 'django_elasticsearch_dsl_drf.fields.nested_fields' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'GeoPointField', diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/faceted_search.py b/src/django_elasticsearch_dsl_drf/filter_backends/faceted_search.py index 9eb471e2..ed4a6e3d 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/faceted_search.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/faceted_search.py @@ -4,21 +4,20 @@ import copy from collections import defaultdict -from elasticsearch_dsl import TermsFacet -from elasticsearch_dsl.query import Q +from anysearch.search_dsl import TermsFacet +from anysearch.search_dsl.query import Q from rest_framework.filters import BaseFilterBackend - from six import string_types, iteritems +from .filtering import FilteringFilterBackend + __title__ = 'django_elasticsearch_dsl_drf.faceted_search' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('FacetedSearchFilterBackend', 'FacetedFilterSearchFilterBackend') -from django_elasticsearch_dsl_drf.filter_backends.filtering import FilteringFilterBackend - class FacetedSearchFilterBackend(BaseFilterBackend): """Faceted search backend. diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/filtering/__init__.py b/src/django_elasticsearch_dsl_drf/filter_backends/filtering/__init__.py index 04ec352b..b0f07b39 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/filtering/__init__.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/filtering/__init__.py @@ -10,7 +10,7 @@ __title__ = 'django_elasticsearch_dsl_drf.filter_backends.filtering' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'FilteringFilterBackend', diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/filtering/common.py b/src/django_elasticsearch_dsl_drf/filter_backends/filtering/common.py index 8b200803..27b3f022 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/filtering/common.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/filtering/common.py @@ -4,9 +4,9 @@ import operator -from elasticsearch_dsl.query import Q -from rest_framework.filters import BaseFilterBackend +from anysearch.search_dsl.query import Q from django_elasticsearch_dsl import fields +from rest_framework.filters import BaseFilterBackend import six from six import string_types @@ -39,7 +39,7 @@ __title__ = 'django_elasticsearch_dsl_drf.filter_backends.filtering.common' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('FilteringFilterBackend',) diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/filtering/geo_spatial.py b/src/django_elasticsearch_dsl_drf/filter_backends/filtering/geo_spatial.py index 1362286b..10619e00 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/filtering/geo_spatial.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/filtering/geo_spatial.py @@ -22,9 +22,9 @@ polygon. """ import logging -from elasticsearch_dsl.query import Q -from rest_framework.filters import BaseFilterBackend +from anysearch.search_dsl.query import Q +from rest_framework.filters import BaseFilterBackend from six import string_types from ...constants import ( @@ -40,7 +40,7 @@ __title__ = 'django_elasticsearch_dsl_drf.filter_backends.filtering.common' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('GeoSpatialFilteringFilterBackend',) diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/filtering/ids.py b/src/django_elasticsearch_dsl_drf/filter_backends/filtering/ids.py index 96871cdc..f7c81807 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/filtering/ids.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/filtering/ids.py @@ -26,6 +26,7 @@ query-dsl-ids-query.html """ +from anysearch import IS_OPENSEARCH from rest_framework.filters import BaseFilterBackend from ...versions import ELASTICSEARCH_LTE_6_0 @@ -114,7 +115,7 @@ def filter_queryset(self, request, queryset, view): # Prior 7.x ``type`` argument was accepted. Starting from 7.x # it has been deprecated. As long as 6.x is supported, this # should stay. - if ELASTICSEARCH_LTE_6_0: + if ELASTICSEARCH_LTE_6_0 and not IS_OPENSEARCH: _qs_kwargs.update({'type': view.mapping}) queryset = queryset.query( diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/filtering/nested.py b/src/django_elasticsearch_dsl_drf/filter_backends/filtering/nested.py index 18897268..27fa14ae 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/filtering/nested.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/filtering/nested.py @@ -2,24 +2,18 @@ Nested filtering backend. """ -from elasticsearch_dsl.query import Q -from django.core.exceptions import ImproperlyConfigured +from anysearch.search_dsl.query import Q from django_elasticsearch_dsl import fields - +from django.core.exceptions import ImproperlyConfigured from six import string_types -from ...constants import ( - ALL_LOOKUP_FILTERS_AND_QUERIES, - LOOKUP_FILTER_TERMS, -) - -from ...compat import coreapi -from ...compat import coreschema +from ...constants import ALL_LOOKUP_FILTERS_AND_QUERIES, LOOKUP_FILTER_TERMS +from ...compat import coreapi, coreschema from .common import FilteringFilterBackend __title__ = 'django_elasticsearch_dsl_drf.filter_backends.filtering.nested' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('NestedFilteringFilterBackend',) diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/filtering/post_filter.py b/src/django_elasticsearch_dsl_drf/filter_backends/filtering/post_filter.py index 3dd8d71d..4c667015 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/filtering/post_filter.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/filtering/post_filter.py @@ -3,7 +3,6 @@ """ from django_elasticsearch_dsl import fields - from six import string_types from ...compat import coreapi @@ -15,7 +14,7 @@ __title__ = 'django_elasticsearch_dsl_drf.filter_backends.filtering.' \ 'post_filter.common' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('PostFilterFilteringFilterBackend',) diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/highlight.py b/src/django_elasticsearch_dsl_drf/filter_backends/highlight.py index d40a05db..bc8f6512 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/highlight.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/highlight.py @@ -5,7 +5,7 @@ __title__ = 'django_elasticsearch_dsl_drf.highlight' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('HighlightBackend',) diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/mixins.py b/src/django_elasticsearch_dsl_drf/filter_backends/mixins.py index 1bb975f9..9b31fd35 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/mixins.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/mixins.py @@ -11,7 +11,7 @@ __title__ = 'django_elasticsearch_dsl_drf.filter_backends.mixins' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('FilterBackendMixin',) diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/ordering/__init__.py b/src/django_elasticsearch_dsl_drf/filter_backends/ordering/__init__.py index 6170cf22..9e278cbc 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/ordering/__init__.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/ordering/__init__.py @@ -7,7 +7,7 @@ __title__ = 'django_elasticsearch_dsl_drf.filter_backends.ordering' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'DefaultOrderingFilterBackend', diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/ordering/common.py b/src/django_elasticsearch_dsl_drf/filter_backends/ordering/common.py index 91ce2ee5..107a8ee1 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/ordering/common.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/ordering/common.py @@ -1,19 +1,15 @@ """ Ordering backend. """ - -from six import string_types - from rest_framework.filters import BaseFilterBackend from rest_framework.settings import api_settings +from six import string_types -from ...compat import coreapi -from ...compat import coreschema -from ...compat import nested_sort_entry +from ...compat import coreapi, coreschema, nested_sort_entry __title__ = 'django_elasticsearch_dsl_drf.filter_backends.ordering.common' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'DefaultOrderingFilterBackend', diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/ordering/geo_spatial.py b/src/django_elasticsearch_dsl_drf/filter_backends/ordering/geo_spatial.py index 4e00e50e..0ccccfbc 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/ordering/geo_spatial.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/ordering/geo_spatial.py @@ -11,7 +11,7 @@ __title__ = 'django_elasticsearch_dsl_drf.filter_backends.ordering.common' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('GeoSpatialOrderingFilterBackend',) diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/search/__init__.py b/src/django_elasticsearch_dsl_drf/filter_backends/search/__init__.py index f8268c70..764d09c2 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/search/__init__.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/search/__init__.py @@ -10,7 +10,7 @@ __title__ = 'django_elasticsearch_dsl_drf.filter_backends.search' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'BaseSearchFilterBackend', diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/search/base.py b/src/django_elasticsearch_dsl_drf/filter_backends/search/base.py index 41c77efc..6e99c2fd 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/search/base.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/search/base.py @@ -1,8 +1,7 @@ """Base search backend.""" -from django.core.exceptions import ImproperlyConfigured - from django_elasticsearch_dsl import fields +from django.core.exceptions import ImproperlyConfigured from rest_framework.filters import BaseFilterBackend from rest_framework.settings import api_settings @@ -12,7 +11,7 @@ __title__ = 'django_elasticsearch_dsl_drf.filter_backends.search.common' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'BaseSearchFilterBackend', diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/search/compound.py b/src/django_elasticsearch_dsl_drf/filter_backends/search/compound.py index 11a1fd24..42c87c92 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/search/compound.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/search/compound.py @@ -8,7 +8,7 @@ __title__ = 'django_elasticsearch_dsl_drf.filter_backends.search.compound' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'CompoundSearchFilterBackend', diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/search/historical.py b/src/django_elasticsearch_dsl_drf/filter_backends/search/historical.py index 838206cf..1c52faad 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/search/historical.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/search/historical.py @@ -6,7 +6,7 @@ import warnings from django_elasticsearch_dsl import fields -from elasticsearch_dsl.query import Q +from anysearch.search_dsl.query import Q from rest_framework.filters import BaseFilterBackend from rest_framework.settings import api_settings import six @@ -16,7 +16,7 @@ __title__ = 'django_elasticsearch_dsl_drf.filter_backends.search.historical' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('SearchFilterBackend',) diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/search/multi_match.py b/src/django_elasticsearch_dsl_drf/filter_backends/search/multi_match.py index cf920828..bacc5346 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/search/multi_match.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/search/multi_match.py @@ -12,7 +12,7 @@ __title__ = 'django_elasticsearch_dsl_drf.filter_backends.search.multi_match' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'MultiMatchSearchFilterBackend', diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/__init__.py b/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/__init__.py index 47457e7a..ceca0902 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/__init__.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/__init__.py @@ -13,7 +13,7 @@ __title__ = 'django_elasticsearch_dsl_drf.filter_backends.search.' \ 'query_backends' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'BaseSearchQueryBackend', diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/base.py b/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/base.py index 0e7822a1..1f07a440 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/base.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/base.py @@ -1,7 +1,7 @@ __title__ = 'django_elasticsearch_dsl_drf.filter_backends.search.' \ 'query_backends.base' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('BaseSearchQueryBackend',) diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/match.py b/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/match.py index 6f415507..4c3594c3 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/match.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/match.py @@ -1,11 +1,11 @@ -from elasticsearch_dsl.query import Q +from anysearch.search_dsl.query import Q from .base import BaseSearchQueryBackend __title__ = 'django_elasticsearch_dsl_drf.filter_backends.search.' \ 'query_backends.match' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('MatchQueryBackend',) diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/match_phrase.py b/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/match_phrase.py index ed81ae71..f52c9664 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/match_phrase.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/match_phrase.py @@ -1,11 +1,11 @@ -from elasticsearch_dsl.query import Q +from anysearch.search_dsl.query import Q from .base import BaseSearchQueryBackend __title__ = 'django_elasticsearch_dsl_drf.filter_backends.search.' \ 'query_backends.match_phrase' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('MatchPhraseQueryBackend',) diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/match_phrase_prefix.py b/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/match_phrase_prefix.py index e43d8e14..8319d9c1 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/match_phrase_prefix.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/match_phrase_prefix.py @@ -1,11 +1,11 @@ -from elasticsearch_dsl.query import Q +from anysearch.search_dsl.query import Q from .base import BaseSearchQueryBackend __title__ = 'django_elasticsearch_dsl_drf.filter_backends.search.' \ 'query_backends.match_phrase_prefix' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('MatchPhrasePrefixQueryBackend',) diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/multi_match.py b/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/multi_match.py index 4406a12f..e5464c62 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/multi_match.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/multi_match.py @@ -1,13 +1,13 @@ import copy -from elasticsearch_dsl.query import Q +from anysearch.search_dsl.query import Q from .base import BaseSearchQueryBackend __title__ = 'django_elasticsearch_dsl_drf.filter_backends.search.' \ 'query_backends.multi_match' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('MultiMatchQueryBackend',) diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/nested.py b/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/nested.py index fa594d29..571eb935 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/nested.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/nested.py @@ -1,14 +1,15 @@ import operator + import six -from elasticsearch_dsl.query import Q +from anysearch.search_dsl.query import Q from .base import BaseSearchQueryBackend __title__ = 'django_elasticsearch_dsl_drf.filter_backends.search.' \ 'query_backends.nested' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('NestedQueryBackend',) diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/simple_query_string.py b/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/simple_query_string.py index a61d0ab5..78145432 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/simple_query_string.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/search/query_backends/simple_query_string.py @@ -1,13 +1,13 @@ import copy -from elasticsearch_dsl.query import Q +from anysearch.search_dsl.query import Q from .base import BaseSearchQueryBackend __title__ = 'django_elasticsearch_dsl_drf.filter_backends.search.' \ 'query_backends.simple_query_string' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('SimpleQueryStringQueryBackend',) diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/search/simple_query_string.py b/src/django_elasticsearch_dsl_drf/filter_backends/search/simple_query_string.py index c5fb1aad..9ac132ae 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/search/simple_query_string.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/search/simple_query_string.py @@ -3,9 +3,7 @@ from ...constants import MATCHING_OPTION_MUST from .base import BaseSearchFilterBackend -from .query_backends import ( - SimpleQueryStringQueryBackend, -) +from .query_backends import SimpleQueryStringQueryBackend LOGGER = logging.getLogger(__name__) @@ -13,7 +11,7 @@ __title__ = 'django_elasticsearch_dsl_drf.filter_backends.search.' \ 'simple_query_string' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'SimpleQueryStringSearchFilterBackend', diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/source.py b/src/django_elasticsearch_dsl_drf/filter_backends/source.py index 921eaa01..fd5a5fa7 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/source.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/source.py @@ -5,7 +5,7 @@ __title__ = 'django_elasticsearch_dsl_drf.source' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('SourceBackend',) diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/suggester/__init__.py b/src/django_elasticsearch_dsl_drf/filter_backends/suggester/__init__.py index 12603d22..26a146ee 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/suggester/__init__.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/suggester/__init__.py @@ -7,7 +7,7 @@ __title__ = 'django_elasticsearch_dsl_drf.filter_backends.suggester' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'SuggesterFilterBackend', diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/suggester/functional.py b/src/django_elasticsearch_dsl_drf/filter_backends/suggester/functional.py index 909f0d26..c392ba36 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/suggester/functional.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/suggester/functional.py @@ -67,28 +67,26 @@ >>> >>> model = Publisher # The model associate with this Document """ -from elasticsearch_dsl.search import AggsProxy +from anysearch.search_dsl import AggsProxy +from rest_framework.exceptions import ValidationError +from rest_framework.filters import BaseFilterBackend +from six import string_types -from django_elasticsearch_dsl_drf.constants import ( +from ...constants import ( FUNCTIONAL_SUGGESTER_TERM_MATCH, FUNCTIONAL_SUGGESTER_PHRASE_MATCH, FUNCTIONAL_SUGGESTER_COMPLETION_PREFIX, FUNCTIONAL_SUGGESTER_COMPLETION_MATCH, ALL_FUNCTIONAL_SUGGESTERS, ) -from django_elasticsearch_dsl_drf.utils import EmptySearch - -from rest_framework.exceptions import ValidationError -from rest_framework.filters import BaseFilterBackend - -from six import string_types - from ..mixins import FilterBackendMixin +# from ...utils import EmptySearch + __title__ = 'django_elasticsearch_dsl_drf.filter_backends.suggester.' \ 'functional' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('FunctionalSuggesterFilterBackend',) diff --git a/src/django_elasticsearch_dsl_drf/filter_backends/suggester/native.py b/src/django_elasticsearch_dsl_drf/filter_backends/suggester/native.py index a3a372c8..1c6f7280 100644 --- a/src/django_elasticsearch_dsl_drf/filter_backends/suggester/native.py +++ b/src/django_elasticsearch_dsl_drf/filter_backends/suggester/native.py @@ -69,22 +69,20 @@ """ from collections import defaultdict -from django_elasticsearch_dsl_drf.constants import ( +from rest_framework.filters import BaseFilterBackend +from six import string_types + +from ...constants import ( SUGGESTER_TERM, SUGGESTER_PHRASE, SUGGESTER_COMPLETION, ALL_SUGGESTERS, ) - -from rest_framework.filters import BaseFilterBackend - -from six import string_types - from ..mixins import FilterBackendMixin __title__ = 'django_elasticsearch_dsl_drf.filter_backends.suggester' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('SuggesterFilterBackend',) diff --git a/src/django_elasticsearch_dsl_drf/helpers.py b/src/django_elasticsearch_dsl_drf/helpers.py index 7904f643..368ed278 100644 --- a/src/django_elasticsearch_dsl_drf/helpers.py +++ b/src/django_elasticsearch_dsl_drf/helpers.py @@ -3,19 +3,18 @@ """ from collections import OrderedDict +from anysearch import IS_ELASTICSEARCH +from anysearch.search_dsl import Search, MoreLikeThis +from anysearch.search_dsl.connections import connections from django_elasticsearch_dsl.registries import registry -from elasticsearch_dsl import Search -from elasticsearch_dsl.connections import connections -from elasticsearch_dsl.query import MoreLikeThis - from six import PY3 from .versions import ELASTICSEARCH_GTE_7_0 __title__ = 'django_elasticsearch_dsl_drf.helpers' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'get_document_for_model', @@ -151,7 +150,7 @@ def more_like_this(obj, '_id': "{}".format(obj.pk), '_index': "{}".format(_index), } - if not ELASTICSEARCH_GTE_7_0: + if IS_ELASTICSEARCH and not ELASTICSEARCH_GTE_7_0: _like_options.update({'_type': "{}".format(_mapping)}) return _search.query( diff --git a/src/django_elasticsearch_dsl_drf/pagination.py b/src/django_elasticsearch_dsl_drf/pagination.py index 9b08c4c8..97ef49e7 100644 --- a/src/django_elasticsearch_dsl_drf/pagination.py +++ b/src/django_elasticsearch_dsl_drf/pagination.py @@ -7,21 +7,20 @@ from collections import OrderedDict -from django.core import paginator as django_paginator - -from elasticsearch_dsl.utils import AttrDict +import six +from anysearch import IS_OPENSEARCH +from anysearch.search_dsl.utils import AttrDict +from django.core import paginator as django_paginator from rest_framework import pagination from rest_framework.exceptions import NotFound from rest_framework.response import Response -import six - from .versions import ELASTICSEARCH_GTE_6_0 __title__ = 'django_elasticsearch_dsl_drf.pagination' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'LimitOffsetPagination', @@ -163,7 +162,7 @@ def paginate_queryset(self, queryset, request, view=None): # saves us unnecessary queries. is_suggest = getattr(queryset, '_suggest', False) if is_suggest: - if ELASTICSEARCH_GTE_6_0: + if ELASTICSEARCH_GTE_6_0 or IS_OPENSEARCH: return queryset.execute().to_dict().get('suggest') return queryset.execute_suggest().to_dict() @@ -272,7 +271,7 @@ def paginate_queryset(self, queryset, request, view=None): # saves us unnecessary queries. is_suggest = getattr(queryset, '_suggest', False) if is_suggest: - if ELASTICSEARCH_GTE_6_0: + if ELASTICSEARCH_GTE_6_0 or IS_OPENSEARCH: return queryset.execute().to_dict().get('suggest') return queryset.execute_suggest().to_dict() @@ -351,7 +350,7 @@ def paginate_queryset(self, queryset, request, view=None): # saves us unnecessary queries. is_suggest = getattr(queryset, '_suggest', False) if is_suggest: - if ELASTICSEARCH_GTE_6_0: + if ELASTICSEARCH_GTE_6_0 or IS_OPENSEARCH: return queryset.execute().to_dict().get('suggest') return queryset.execute_suggest().to_dict() diff --git a/src/django_elasticsearch_dsl_drf/pip_helpers.py b/src/django_elasticsearch_dsl_drf/pip_helpers.py index fcbe397c..000f7b4d 100644 --- a/src/django_elasticsearch_dsl_drf/pip_helpers.py +++ b/src/django_elasticsearch_dsl_drf/pip_helpers.py @@ -6,7 +6,7 @@ __title__ = 'django_elasticsearch_dsl_drf.tests.pip_helpers' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'check_if_installed', diff --git a/src/django_elasticsearch_dsl_drf/serializers.py b/src/django_elasticsearch_dsl_drf/serializers.py index b8e19f1f..42fcc114 100644 --- a/src/django_elasticsearch_dsl_drf/serializers.py +++ b/src/django_elasticsearch_dsl_drf/serializers.py @@ -3,7 +3,7 @@ Serializers. """ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import copy from collections import OrderedDict @@ -18,7 +18,6 @@ import six - from .fields import ( BooleanField, CharField, @@ -37,7 +36,7 @@ __title__ = 'django_elasticsearch_dsl_drf.serializers' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'DocumentSerializer', diff --git a/src/django_elasticsearch_dsl_drf/tests/base.py b/src/django_elasticsearch_dsl_drf/tests/base.py index 519bf3fa..85f494bd 100644 --- a/src/django_elasticsearch_dsl_drf/tests/base.py +++ b/src/django_elasticsearch_dsl_drf/tests/base.py @@ -1,12 +1,12 @@ """ Base tests. """ +import logging from time import sleep -import logging -from django.test import TransactionTestCase import pytest +from django.test import TransactionTestCase from rest_framework.test import APIClient import factories diff --git a/src/django_elasticsearch_dsl_drf/tests/data_mixins.py b/src/django_elasticsearch_dsl_drf/tests/data_mixins.py index 7457a3f1..f82459ad 100644 --- a/src/django_elasticsearch_dsl_drf/tests/data_mixins.py +++ b/src/django_elasticsearch_dsl_drf/tests/data_mixins.py @@ -1,9 +1,6 @@ """ Data mixins. """ - -from __future__ import absolute_import - import uuid from django.urls import reverse @@ -13,7 +10,7 @@ __title__ = 'django_elasticsearch_dsl_drf.tests.data_mixins' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'AddressesMixin', diff --git a/src/django_elasticsearch_dsl_drf/tests/test_elasticsearch_helpers.py b/src/django_elasticsearch_dsl_drf/tests/test_elasticsearch_helpers.py index 7bba88df..ea2d9e96 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_elasticsearch_helpers.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_elasticsearch_helpers.py @@ -3,21 +3,20 @@ Test helpers. """ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals -import unittest +import pytest +from anysearch import IS_OPENSEARCH from django.core.management import call_command -import pytest - from ..elasticsearch_helpers import delete_all_indices, get_all_indices from .base import BaseTestCase __title__ = 'django_elasticsearch_dsl_drf.tests.test_elasticsearch_helpers' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestElasticsearchHelpers', @@ -63,7 +62,3 @@ def test_all(self): """Filter by field.""" self._get_all_indices() self._delete_all_indices() - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_faceted_filtered_search.py b/src/django_elasticsearch_dsl_drf/tests/test_faceted_filtered_search.py index bcce7efd..11b590b5 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_faceted_filtered_search.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_faceted_filtered_search.py @@ -1,16 +1,11 @@ """ Test faceted search backend. """ +import pytest -from __future__ import absolute_import - -import unittest - +from anysearch import IS_OPENSEARCH from django.core.management import call_command from django.urls import reverse - -import pytest - from rest_framework import status from books import constants @@ -20,7 +15,7 @@ __title__ = 'django_elasticsearch_dsl_drf.tests.test_faceted_search' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestFacetedFilteredSearch', @@ -158,7 +153,3 @@ def test_list_results_facet_and_filter_only_on_non_faceted_field(self): "doc_count": 1, "key": "published" }]) - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_faceted_search.py b/src/django_elasticsearch_dsl_drf/tests/test_faceted_search.py index a7f61bc0..3b896226 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_faceted_search.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_faceted_search.py @@ -1,16 +1,11 @@ """ Test faceted search backend. """ +import pytest -from __future__ import absolute_import - -import unittest - +from anysearch import IS_OPENSEARCH from django.core.management import call_command from django.urls import reverse - -import pytest - from rest_framework import status from books import constants @@ -20,7 +15,7 @@ __title__ = 'django_elasticsearch_dsl_drf.tests.test_faceted_search' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestFacetedSearch', @@ -157,7 +152,3 @@ def _list_results_with_facets(self): def test_list_results_with_facets(self): """Test list results with facets.""" return self._list_results_with_facets() - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_filtering_common.py b/src/django_elasticsearch_dsl_drf/tests/test_filtering_common.py index ff4b61c1..5628b4c0 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_filtering_common.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_filtering_common.py @@ -1,16 +1,13 @@ """ Test filtering backend. """ - -from __future__ import absolute_import - import unittest -from django.core.management import call_command -from django.urls import reverse - import pytest +from anysearch import OPENSEARCH, SEARCH_BACKEND +from django.core.management import call_command +from django.urls import reverse from rest_framework import status from books import constants @@ -33,7 +30,7 @@ __title__ = 'django_elasticsearch_dsl_drf.tests.test_filtering_common' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestFilteringCommon', @@ -574,8 +571,10 @@ def test_default_filter_lookup(self): self.published[0].authors.add(*authors) self.published[1].authors.add(*authors) self.published[2].authors.add(*authors) + # Update the Elasticsearch index call_command('search_index', '--rebuild', '-f') + # Test self._field_filter_multiple_values( self.books_default_filter_lookup_url, @@ -675,7 +674,3 @@ def test_schema_field_not_required(self): fields = [f.required for f in fields] for field in fields: self.assertFalse(field) - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_filtering_geo_spatial.py b/src/django_elasticsearch_dsl_drf/tests/test_filtering_geo_spatial.py index 8c17dcb5..04be403c 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_filtering_geo_spatial.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_filtering_geo_spatial.py @@ -1,18 +1,12 @@ """ Test geo-spatial filtering backend. """ +import pytest -from __future__ import absolute_import - -import unittest - +from anysearch import IS_OPENSEARCH +from anysearch.search import TransportError from django.core.management import call_command from django.urls import reverse - -from elasticsearch.connection.base import TransportError - -import pytest - from rest_framework import status import factories @@ -22,7 +16,7 @@ __title__ = 'django_elasticsearch_dsl_drf.tests.test_filtering_geo_spatial' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestFilteringGeoSpatial', @@ -74,6 +68,7 @@ def _test_field_filter_geo_distance(self, distance_type=None): ) call_command('search_index', '--rebuild', '-f') + self.sleep() __params = '{distance}{separator}{lat}{separator}{lon}{d_type}'.format( @@ -150,6 +145,7 @@ def test_field_filter_geo_distance_not_enough_args_fail(self): ) call_command('search_index', '--rebuild', '-f') + self.sleep() __params = '{distance}{separator}{lat}'.format( @@ -210,6 +206,7 @@ def _test_field_filter_geo_polygon(self, field_name, points, count): ) call_command('search_index', '--rebuild', '-f') + self.sleep() response = self.client.get(url, data) @@ -340,6 +337,7 @@ def _test_field_filter_geo_bounding_box(self, points, count): ) call_command('search_index', '--rebuild', '-f') + self.sleep() response = self.client.get(url, data) @@ -459,6 +457,7 @@ def _test_field_filter_geo_shape(self, points, count, gs_data): ) call_command('search_index', '--rebuild', '-f') + self.sleep() response = self.client.get(url, {}) @@ -542,7 +541,3 @@ def test_field_filter_geo_shape_circle_intersects(self): 'extra': 'radius,10km', } ) - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_filtering_global_aggregations.py b/src/django_elasticsearch_dsl_drf/tests/test_filtering_global_aggregations.py index ad2c4634..1db9c007 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_filtering_global_aggregations.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_filtering_global_aggregations.py @@ -1,16 +1,11 @@ """ Test filtering `post_filter` backend. """ +import pytest -from __future__ import absolute_import - -import unittest - +from anysearch import IS_OPENSEARCH from django.core.management import call_command from django.urls import reverse - -import pytest - from rest_framework import status from search_indexes.viewsets import BookDocumentViewSet @@ -21,7 +16,7 @@ __title__ = 'django_elasticsearch_dsl_drf.tests.test_filtering_post' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestFilteringGlobalAggregations', @@ -217,7 +212,3 @@ def _list_results_with_facets(self): def test_list_results_with_facets(self): """Test list results with facets.""" return self._list_results_with_facets() - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_filtering_nested.py b/src/django_elasticsearch_dsl_drf/tests/test_filtering_nested.py index ab9c7582..bf355f16 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_filtering_nested.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_filtering_nested.py @@ -1,16 +1,12 @@ """ Test nested filtering backend. """ - -from __future__ import absolute_import - -import copy import unittest -from django.core.management import call_command - import pytest +from anysearch import IS_OPENSEARCH +from django.core.management import call_command from rest_framework import status from search_indexes.viewsets import AddressDocumentViewSet @@ -26,7 +22,7 @@ __title__ = 'django_elasticsearch_dsl_drf.tests.test_filtering_nested' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestFilteringNested', @@ -83,6 +79,7 @@ def setUpClass(cls): } cls.sleep() + # Update the Elasticsearch index call_command('search_index', '--rebuild', '-f') @@ -580,7 +577,3 @@ def test_schema_field_not_required(self): fields = [f.required for f in fields] for field in fields: self.assertFalse(field) - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_filtering_post_filter.py b/src/django_elasticsearch_dsl_drf/tests/test_filtering_post_filter.py index 9e4bc749..a27fad24 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_filtering_post_filter.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_filtering_post_filter.py @@ -1,16 +1,13 @@ """ Test filtering `post_filter` backend. """ - -from __future__ import absolute_import - import unittest -from django.core.management import call_command -from django.urls import reverse - import pytest +from anysearch import IS_OPENSEARCH +from django.core.management import call_command +from django.urls import reverse from rest_framework import status from books import constants @@ -27,7 +24,7 @@ __title__ = 'django_elasticsearch_dsl_drf.tests.test_filtering_post' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestFilteringPostFilter', @@ -53,6 +50,7 @@ def setUpClass(cls): cls.created_addresses() cls.sleep() + # Update the Elasticsearch index call_command('search_index', '--rebuild', '-f') @@ -691,7 +689,3 @@ def test_schema_field_not_required(self): fields = [f.required for f in fields] for field in fields: self.assertFalse(field) - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_functional_suggesters.py b/src/django_elasticsearch_dsl_drf/tests/test_functional_suggesters.py index 84abb18b..f6f064aa 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_functional_suggesters.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_functional_suggesters.py @@ -2,16 +2,11 @@ """ Test functional suggestions backend. """ +import pytest -from __future__ import absolute_import, unicode_literals - -import unittest - +from anysearch import IS_OPENSEARCH from django.core.management import call_command from django.urls import reverse - -import pytest - from rest_framework import status import factories @@ -21,7 +16,7 @@ __title__ = 'django_elasticsearch_dsl_drf.tests.test_suggesters' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestFunctionalSuggesters', @@ -196,6 +191,7 @@ def setUpClass(cls): cls.created_addresses() cls.sleep() + call_command('search_index', '--rebuild', '-f') def _test_suggesters(self, test_data, url): @@ -358,7 +354,3 @@ def test_suggesters_completion_no_args_provided(self): # } # } # self._test_suggesters(test_data, self.addresses_suggest_url) - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_helpers.py b/src/django_elasticsearch_dsl_drf/tests/test_helpers.py index 74121ca3..c1f71028 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_helpers.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_helpers.py @@ -3,23 +3,21 @@ Test helpers. """ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals -import unittest +import pytest +from anysearch import IS_OPENSEARCH from django.core.management import call_command -import pytest - import factories from ..helpers import more_like_this - from .base import BaseTestCase __title__ = 'django_elasticsearch_dsl_drf.tests.test_helpers' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestHelpers', @@ -110,7 +108,3 @@ def test_filter_by_field(self): """Filter by field.""" obj = self.books[0] return self._more_like_this(obj, ['title', 'description']) - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_highlight.py b/src/django_elasticsearch_dsl_drf/tests/test_highlight.py index 9cf4950b..08a9f268 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_highlight.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_highlight.py @@ -1,16 +1,11 @@ """ Test highlight backend. """ +import pytest -from __future__ import absolute_import - -import unittest - +from anysearch import IS_OPENSEARCH from django.core.management import call_command from django.urls import reverse - -import pytest - from rest_framework import status import factories @@ -19,7 +14,7 @@ __title__ = 'django_elasticsearch_dsl_drf.tests.test_highlight' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestHighlight', @@ -94,7 +89,3 @@ def _list_results_with_highlights(self): def test_list_results_with_highlights(self): """Test list results with facets.""" return self._list_results_with_highlights() - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_management_commands.py b/src/django_elasticsearch_dsl_drf/tests/test_management_commands.py index 22e465a4..43fa8ad9 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_management_commands.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_management_commands.py @@ -3,21 +3,20 @@ Test helpers. """ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals -import unittest +import pytest +from anysearch import IS_OPENSEARCH from django.core.management import call_command -import pytest - from ..elasticsearch_helpers import delete_all_indices, get_all_indices from .base import BaseTestCase __title__ = 'django_elasticsearch_dsl_drf.tests.test_management_commands' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestManagementCommands', @@ -35,6 +34,7 @@ def _get_all_indices(self): delete_all_indices(with_protected=True) self.sleep() + call_command('search_index', '--rebuild', '-f') res = set(get_all_indices()) @@ -63,7 +63,3 @@ def test_all(self): """Filter by field.""" self._get_all_indices() self._delete_all_indices() - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_more_like_this.py b/src/django_elasticsearch_dsl_drf/tests/test_more_like_this.py index 9a739b7e..23d73bc2 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_more_like_this.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_more_like_this.py @@ -3,16 +3,15 @@ Test more-like-this functionality. """ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals -import unittest import logging -from django.core.management import call_command -from django.urls import reverse - import pytest +from anysearch import IS_OPENSEARCH +from django.core.management import call_command +from django.urls import reverse from rest_framework import status import factories @@ -21,7 +20,7 @@ __title__ = 'django_elasticsearch_dsl_drf.tests.test_suggesters' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestMoreLikeThis', @@ -94,6 +93,7 @@ def setUpClass(cls): ) cls.sleep() + call_command('search_index', '--rebuild', '-f') def _test_more_like_this(self, test_data_ids, url, strict=True): @@ -149,7 +149,3 @@ def test_more_like_this(self): self.books_url_2_no_options, strict=False ) - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_ordering_common.py b/src/django_elasticsearch_dsl_drf/tests/test_ordering_common.py index cccf8fc2..9bc77552 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_ordering_common.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_ordering_common.py @@ -1,25 +1,20 @@ """ Test ordering backend. """ - -from __future__ import absolute_import - -from six.moves import reduce - import unittest -from django.core.management import call_command -from django.urls import reverse - import pytest +from anysearch import IS_OPENSEARCH +from django.core.management import call_command +from django.urls import reverse from rest_framework import status - -from django_elasticsearch_dsl_drf.filter_backends import OrderingFilterBackend +from six.moves import reduce import factories from search_indexes.viewsets import BookDocumentViewSet +from ..filter_backends import OrderingFilterBackend from .base import ( BaseRestFrameworkTestCase, CORE_API_AND_CORE_SCHEMA_ARE_INSTALLED, @@ -28,7 +23,7 @@ __title__ = 'django_elasticsearch_dsl_drf.tests.test_ordering' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestOrdering', @@ -100,6 +95,7 @@ def setUpClass(cls): cls.authors_url = reverse('authordocument-list', kwargs={}) cls.sleep() + call_command('search_index', '--rebuild', '-f') # Testing coreapi and coreschema @@ -315,7 +311,3 @@ def test_schema_field_not_required(self): fields = [f.required for f in fields] for field in fields: self.assertFalse(field) - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_ordering_geo_spatial.py b/src/django_elasticsearch_dsl_drf/tests/test_ordering_geo_spatial.py index 4e95ad1b..95a60d2c 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_ordering_geo_spatial.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_ordering_geo_spatial.py @@ -1,16 +1,11 @@ """ Test geo-spatial ordering filter backend. """ +import pytest -from __future__ import absolute_import - -import unittest - +from anysearch import IS_OPENSEARCH from django.core.management import call_command from django.urls import reverse - -import pytest - from rest_framework import status import factories @@ -23,7 +18,7 @@ __title__ = 'django_elasticsearch_dsl_drf.tests.test_filtering' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestOrderingGeoSpatial', @@ -64,6 +59,7 @@ def setUpClass(cls): cls.base_publisher_url = reverse('publisherdocument-list', kwargs={}) cls.sleep() + call_command('search_index', '--rebuild', '-f') @pytest.mark.webtest @@ -103,7 +99,3 @@ def test_field_filter_geo_distance(self): response.data['results'][counter-1]['location']['lat'], response.data['results'][counter]['location']['lat'] ) - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_pagination.py b/src/django_elasticsearch_dsl_drf/tests/test_pagination.py index fae8a3e6..4727d285 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_pagination.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_pagination.py @@ -1,16 +1,12 @@ """ Test pagination. """ +import pytest -from __future__ import absolute_import - -import unittest - +from anysearch import IS_OPENSEARCH from django.core.management import call_command from django.urls import reverse -import pytest - from rest_framework import status import factories @@ -19,7 +15,7 @@ __title__ = 'django_elasticsearch_dsl_drf.tests.test_pagination' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestPagination', @@ -70,7 +66,3 @@ def _test_pagination(self): def test_pagination(self): """Test pagination.""" return self._test_pagination() - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_pip_helpers.py b/src/django_elasticsearch_dsl_drf/tests/test_pip_helpers.py index 15166e0e..069b94d3 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_pip_helpers.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_pip_helpers.py @@ -3,13 +3,15 @@ Test pip_helpers. """ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import unittest import django import pytest +from anysearch import IS_ELASTICSEARCH + from ..pip_helpers import check_if_installed, get_installed_packages __title__ = 'django_elasticsearch_dsl_drf.tests.test_pip_helpers' @@ -46,8 +48,12 @@ def test_get_installed_packages(self): """ installed_packages = get_installed_packages() self.assertIn('Django', installed_packages) - self.assertIn('elasticsearch', installed_packages) - self.assertIn('elasticsearch-dsl', installed_packages) + if IS_ELASTICSEARCH: + self.assertIn('elasticsearch', installed_packages) + self.assertIn('elasticsearch-dsl', installed_packages) + else: + self.assertIn('opensearch-py', installed_packages) + self.assertIn('opensearch-dsl', installed_packages) def test_get_installed_packages_with_versions(self): """Test `get_installed_packages`. @@ -64,6 +70,10 @@ def test_check_if_installed(self): :return: """ self.assertTrue(check_if_installed('Django')) - self.assertTrue(check_if_installed('elasticsearch')) - self.assertTrue(check_if_installed('elasticsearch-dsl')) + if IS_ELASTICSEARCH: + self.assertTrue(check_if_installed('elasticsearch')) + self.assertTrue(check_if_installed('elasticsearch-dsl')) + else: + self.assertTrue(check_if_installed('opensearch-py')) + self.assertTrue(check_if_installed('opensearch-dsl')) self.assertFalse(check_if_installed('django-fobi')) diff --git a/src/django_elasticsearch_dsl_drf/tests/test_query_friendly_pagination.py b/src/django_elasticsearch_dsl_drf/tests/test_query_friendly_pagination.py index 23d8065e..60a1bbaa 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_query_friendly_pagination.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_query_friendly_pagination.py @@ -1,18 +1,12 @@ """ Test pagination. """ +import pytest -from __future__ import absolute_import - -import unittest - +from anysearch import IS_OPENSEARCH +from anysearch.search import Connection from django.core.management import call_command from django.urls import reverse - -from elasticsearch.connection.base import Connection - -import pytest - from rest_framework import status import factories @@ -21,7 +15,7 @@ __title__ = 'django_elasticsearch_dsl_drf.tests.test_query_friendly_pagination' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestQueryFriendlyPagination', @@ -132,7 +126,3 @@ def test_pagination(self): last_es_call_count = es_call_count self._test_pagination_offset() self.assertEqual(es_call_count - last_es_call_count, 1) - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_search.py b/src/django_elasticsearch_dsl_drf/tests/test_search.py index 50a2abce..8d2cfac3 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_search.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_search.py @@ -1,25 +1,23 @@ """ Test search backend. """ - -from __future__ import absolute_import - -from time import sleep import unittest +from time import sleep +import pytest + +from anysearch import IS_OPENSEARCH from django.core.management import call_command from django.urls import reverse -import pytest - from rest_framework import status -from books import constants import factories +from books import constants from search_indexes.viewsets import BookDocumentViewSet + from ..constants import SEPARATOR_LOOKUP_NAME from ..filter_backends import SearchFilterBackend - from .base import ( BaseRestFrameworkTestCase, CORE_API_AND_CORE_SCHEMA_ARE_INSTALLED, @@ -28,7 +26,7 @@ __title__ = 'django_elasticsearch_dsl_drf.tests.test_search' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestSearch', @@ -109,6 +107,7 @@ def setUpClass(cls): cls.all_cities_count = cls.cities_count + cls.switz_cities_count cls.sleep() + call_command('search_index', '--rebuild', '-f') # Testing coreapi and coreschema @@ -423,7 +422,3 @@ def test_search_any_word_in_indexed_fields(self): title_match=book.title, create_factory=False ) - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_search_multi_match.py b/src/django_elasticsearch_dsl_drf/tests/test_search_multi_match.py index b41aafa2..09ea0209 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_search_multi_match.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_search_multi_match.py @@ -1,16 +1,13 @@ """ Test multi match search filter backend. """ - -from __future__ import absolute_import - import unittest -from django.core.management import call_command -from django.urls import reverse - import pytest +from anysearch import IS_OPENSEARCH +from django.core.management import call_command +from django.urls import reverse from rest_framework import status from books import constants @@ -28,7 +25,7 @@ __title__ = 'django_elasticsearch_dsl_drf.tests.test_search_multi_match' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestMultiMatchSearch', @@ -115,6 +112,7 @@ def setUpClass(cls): cls.all_cities_count = cls.cities_count + cls.switz_cities_count cls.sleep() + call_command('search_index', '--rebuild', '-f') # Testing coreapi and coreschema @@ -308,7 +306,3 @@ def test_schema_field_not_required(self): fields = [f.required for f in fields] for field in fields: self.assertFalse(field) - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_search_simple_query_string.py b/src/django_elasticsearch_dsl_drf/tests/test_search_simple_query_string.py index 24979801..3c81aaa7 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_search_simple_query_string.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_search_simple_query_string.py @@ -1,16 +1,13 @@ """ Test multi match search filter backend. """ - -from __future__ import absolute_import - import unittest -from django.core.management import call_command -from django.urls import reverse - import pytest +from anysearch import IS_OPENSEARCH +from django.core.management import call_command +from django.urls import reverse from rest_framework import status from books import constants @@ -18,9 +15,9 @@ from search_indexes.viewsets import ( BookSimpleQueryStringSearchFilterBackendDocumentViewSet ) + from ..filter_backends import SimpleQueryStringSearchFilterBackend from ..versions import ELASTICSEARCH_GTE_6_0 - from .base import ( BaseRestFrameworkTestCase, CORE_API_AND_CORE_SCHEMA_ARE_INSTALLED, @@ -116,6 +113,7 @@ def setUpClass(cls): cls.all_cities_count = cls.cities_count + cls.switz_cities_count cls.sleep(4) + call_command('search_index', '--rebuild', '-f') # Testing coreapi and coreschema @@ -239,7 +237,10 @@ def test_search_with_quotes(self, url=None): url=url ) - @unittest.skipIf(condition=ELASTICSEARCH_GTE_6_0, reason="") + @unittest.skipIf( + condition=(ELASTICSEARCH_GTE_6_0 or IS_OPENSEARCH), + reason="", + ) def test_search_without_quotes(self, url=None): """Test search without quotes. This does not work on Elasticsearch 6.x. @@ -317,7 +318,10 @@ def test_search_with_quotes_boost(self, url=None): url=url ) - @unittest.skipIf(condition=ELASTICSEARCH_GTE_6_0, reason="") + @unittest.skipIf( + condition=ELASTICSEARCH_GTE_6_0 or IS_OPENSEARCH, + reason="", + ) def test_search_without_quotes_boost(self, url=None): """Search boost without quotes. Does not work on Elasticsearch 6.x. @@ -400,7 +404,3 @@ def test_schema_field_not_required(self): fields = [f.required for f in fields] for field in fields: self.assertFalse(field) - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_serializers.py b/src/django_elasticsearch_dsl_drf/tests/test_serializers.py index 46f82cbe..9c7bee0c 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_serializers.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_serializers.py @@ -1,25 +1,19 @@ """ Test serializers. """ - -from __future__ import absolute_import - -import unittest +import pytest from django.contrib.auth.models import User from django.core.exceptions import ImproperlyConfigured - from django_elasticsearch_dsl import Document, Index, fields -from django_elasticsearch_dsl_drf.compat import KeywordField, StringField - -import pytest +from ..compat import KeywordField, StringField from ..serializers import DocumentSerializer from .base import BaseRestFrameworkTestCase __title__ = 'django_elasticsearch_dsl_drf.tests.test_serializers' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestSerializers', @@ -213,7 +207,3 @@ def test_serializer_meta_del_attr(self): AttributeError, self._test_serializer_meta_del_attr ) - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_source.py b/src/django_elasticsearch_dsl_drf/tests/test_source.py index f3ab502c..24705db3 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_source.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_source.py @@ -1,16 +1,11 @@ """ Test source backend. """ +import pytest -from __future__ import absolute_import - -import unittest - +from anysearch import IS_OPENSEARCH from django.core.management import call_command from django.urls import reverse - -import pytest - from rest_framework import status import factories @@ -19,7 +14,7 @@ __title__ = 'django_elasticsearch_dsl_drf.tests.test_source' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestSource', @@ -58,6 +53,7 @@ def setUpClass(cls): cls.all_books_count = cls.special_books_count + cls.books_count cls.sleep() + call_command('search_index', '--rebuild', '-f') def _list_results(self): @@ -90,7 +86,3 @@ def _list_results(self): def test_list_results(self): """Test list results.""" return self._list_results() - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_suggesters.py b/src/django_elasticsearch_dsl_drf/tests/test_suggesters.py index 86a8a339..45d91b22 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_suggesters.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_suggesters.py @@ -3,15 +3,15 @@ Test suggestions backend. """ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import unittest -from django.core.management import call_command -from django.urls import reverse - import pytest +from anysearch import IS_OPENSEARCH +from django.core.management import call_command +from django.urls import reverse from rest_framework import status import factories @@ -350,11 +350,11 @@ def test_suggesters_on_empty_index(self): {} ) self.assertEqual(response.status_code, status.HTTP_200_OK) - if ELASTICSEARCH_GTE_7_0: + if ELASTICSEARCH_GTE_7_0 or IS_OPENSEARCH: self.assertTrue( bool(response.data.get('name_suggest__completion')) ) - elif ELASTICSEARCH_GTE_6_0: + elif ELASTICSEARCH_GTE_6_0 or IS_OPENSEARCH: self.assertFalse(bool(response.data)) else: self.assertFalse( @@ -362,7 +362,10 @@ def test_suggesters_on_empty_index(self): ) -@unittest.skipIf(not ELASTICSEARCH_GTE_5_0, 'ES >=5.x only') +@unittest.skipIf( + not (ELASTICSEARCH_GTE_5_0 or IS_OPENSEARCH), + 'ES >=5.x or OpenSearch only' +) @pytest.mark.django_db class TestContextSuggesters(BaseRestFrameworkTestCase, AddressesMixin): """Test context suggesters.""" @@ -570,7 +573,7 @@ def test_suggesters_completion_context(self): 'filters': { 'title_suggest_loc': ( '40__44__1000km' - if ELASTICSEARCH_GTE_6_0 + if ELASTICSEARCH_GTE_6_0 or IS_OPENSEARCH else '40__44' ), } @@ -581,7 +584,3 @@ def test_suggesters_completion_context(self): test_data, self.addresses_suggest_context_url ) - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_utils.py b/src/django_elasticsearch_dsl_drf/tests/test_utils.py index 274eb2b3..77e84db4 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_utils.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_utils.py @@ -1,11 +1,7 @@ """ Test utils. """ - -from __future__ import absolute_import - -import unittest - +from anysearch import IS_OPENSEARCH from django.urls import reverse from django.core.management import call_command @@ -17,7 +13,7 @@ __title__ = 'django_elasticsearch_dsl_drf.tests.test_utils' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestUtils', @@ -35,6 +31,7 @@ def setUpClass(cls): super(TestUtils, cls).setUpClass() cls.sleep() + call_command('search_index', '--rebuild', '-f') def _list_results(self): @@ -59,7 +56,3 @@ def _list_results(self): def test_list_results(self): """Test list results.""" return self._list_results() - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_versions.py b/src/django_elasticsearch_dsl_drf/tests/test_versions.py index e623d6c0..0c402cba 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_versions.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_versions.py @@ -1,5 +1,7 @@ import unittest import mock +from unittest import skipIf +from anysearch import IS_ELASTICSEARCH # For Python3 >= 3.4 try: from importlib import reload @@ -12,7 +14,7 @@ __title__ = 'django_elasticsearch_dsl_drf.tests.test_versions' __author__ = 'Artur Barseghyan' -__copyright__ = 'Copyright (c) 2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL-2.0-only OR LGPL-2.1-or-later' __all__ = ('VersionsTest',) @@ -24,6 +26,7 @@ class VersionsTest(unittest.TestCase): def setUp(self): pass + @skipIf(not IS_ELASTICSEARCH, "Not elasticsearch, skipping") @mock.patch('elasticsearch_dsl.__version__', [6, 3, 0]) def test_elasticsearch_dsl_6_3_0(self): """ @@ -60,6 +63,7 @@ def test_elasticsearch_dsl_6_3_0(self): self.assertFalse(versions.ELASTICSEARCH_GTE_7_0) self.assertFalse(versions.ELASTICSEARCH_GTE_8_0) + @skipIf(not IS_ELASTICSEARCH, "Not elasticsearch, skipping") @mock.patch('elasticsearch_dsl.__version__', [7, 0, 0]) def test_elasticsearch_dsl_7_0_0(self): """ @@ -95,7 +99,3 @@ def test_elasticsearch_dsl_7_0_0(self): self.assertTrue(versions.ELASTICSEARCH_GTE_6_3) self.assertTrue(versions.ELASTICSEARCH_GTE_7_0) self.assertFalse(versions.ELASTICSEARCH_GTE_8_0) - - -if __name__ == "__main__": - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_views.py b/src/django_elasticsearch_dsl_drf/tests/test_views.py index 0ed48b4d..cac0c4d0 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_views.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_views.py @@ -1,16 +1,11 @@ """ Test views. """ +import pytest -from __future__ import absolute_import - -import unittest - +from anysearch import IS_OPENSEARCH from django.core.management import call_command from django.urls import reverse - -import pytest - from rest_framework import status import factories @@ -19,7 +14,7 @@ __title__ = 'django_elasticsearch_dsl_drf.tests.test_views' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestViews', @@ -41,6 +36,7 @@ def setUpClass(cls): cls.tags = factories.TagGenreFactory.create_batch(20) cls.sleep() + call_command('search_index', '--rebuild', '-f') def test_listing_view(self): @@ -77,7 +73,3 @@ def test_detail_view_with_custom_lookup(self): response = self.client.get(url, data) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.data['id'], __obj.title) - - -if __name__ == '__main__': - unittest.main() diff --git a/src/django_elasticsearch_dsl_drf/tests/test_wrappers.py b/src/django_elasticsearch_dsl_drf/tests/test_wrappers.py index d0c9a272..4570749e 100644 --- a/src/django_elasticsearch_dsl_drf/tests/test_wrappers.py +++ b/src/django_elasticsearch_dsl_drf/tests/test_wrappers.py @@ -3,7 +3,7 @@ Test wrappers. """ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import json import unittest @@ -14,7 +14,7 @@ __title__ = 'django_elasticsearch_dsl_drf.tests.test_wrappers' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'TestWrappers', diff --git a/src/django_elasticsearch_dsl_drf/utils.py b/src/django_elasticsearch_dsl_drf/utils.py index 3487565a..465e85d9 100644 --- a/src/django_elasticsearch_dsl_drf/utils.py +++ b/src/django_elasticsearch_dsl_drf/utils.py @@ -3,12 +3,11 @@ """ import datetime -from elasticsearch_dsl.search import AggsProxy - +from anysearch.search_dsl import AggsProxy __title__ = 'django_elasticsearch_dsl_drf.utils' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'DictionaryProxy', diff --git a/src/django_elasticsearch_dsl_drf/versions.py b/src/django_elasticsearch_dsl_drf/versions.py index a1c94d06..ac59ac60 100644 --- a/src/django_elasticsearch_dsl_drf/versions.py +++ b/src/django_elasticsearch_dsl_drf/versions.py @@ -7,7 +7,7 @@ __title__ = 'django_elasticsearch_dsl_drf.versions' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = [ 'get_elasticsearch_version', diff --git a/src/django_elasticsearch_dsl_drf/viewsets.py b/src/django_elasticsearch_dsl_drf/viewsets.py index 2980e9cc..6c9b7204 100644 --- a/src/django_elasticsearch_dsl_drf/viewsets.py +++ b/src/django_elasticsearch_dsl_drf/viewsets.py @@ -3,16 +3,16 @@ """ Base ViewSets. """ -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals import copy from django.http import Http404 from django.core.exceptions import ImproperlyConfigured -from elasticsearch_dsl import Search -from elasticsearch_dsl.connections import connections -from elasticsearch_dsl.query import MoreLikeThis +from anysearch import IS_OPENSEARCH +from anysearch.search_dsl import MoreLikeThis, Search +from anysearch.search_dsl.connections import connections from rest_framework import status from rest_framework.decorators import action @@ -86,6 +86,15 @@ def functional_suggest(self, request): class MoreLikeThisMixin(object): """More-like-this mixin.""" + def _get_like_options(self, id_): + like_opts = { + '_id': "{}".format(id_), + '_index': "{}".format(self.index), + } + if not ELASTICSEARCH_GTE_7_0: + like_opts['_type'] = "{}".format(self.mapping) + return like_opts + @action(detail=True) def more_like_this(self, request, pk=None, id=None): """More-like-this functionality detail view. @@ -113,22 +122,14 @@ def more_like_this(self, request, pk=None, id=None): queryset = queryset.query( MoreLikeThis( fields=fields, - like={ - '_id': "{}".format(id_), - '_index': "{}".format(self.index), - '_type': "{}".format(self.mapping) - }, + like=self._get_like_options(id_), **kwargs ) ).sort('_score') else: queryset = queryset.query( MoreLikeThis( - like={ - '_id': "{}".format(id_), - '_index': "{}".format(self.index), - '_type': "{}".format(self.mapping) - }, + like=self._get_like_options(id_), **kwargs ) ).sort('_score') @@ -246,7 +247,7 @@ def get_object(self): # Remark 2: Unlike code in `Remark 1`, here we do need the # conditional treatment. - if ELASTICSEARCH_GTE_7_0: + if ELASTICSEARCH_GTE_7_0 or IS_OPENSEARCH: dictionary_proxy = self.dictionary_proxy( obj.to_dict(), getattr(obj, 'meta', None) diff --git a/src/django_elasticsearch_dsl_drf/wrappers.py b/src/django_elasticsearch_dsl_drf/wrappers.py index 8a39b94f..ef84f2f9 100644 --- a/src/django_elasticsearch_dsl_drf/wrappers.py +++ b/src/django_elasticsearch_dsl_drf/wrappers.py @@ -2,7 +2,7 @@ __title__ = 'django_elasticsearch_dsl_drf.wrappers' __author__ = 'Artur Barseghyan ' -__copyright__ = '2017-2020 Artur Barseghyan' +__copyright__ = '2017-2022 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'dict_to_obj', diff --git a/tox.ini b/tox.ini index 1fae0786..c0ce9bae 100755 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py{36,37,38,39}-django{22,31,32}-elasticsearch{6,7} + py{36,37,38,39,310}-django{22,31,32}-elasticsearch{6,7} [testenv] envlogdir= diff --git a/tox_opensearch.ini b/tox_opensearch.ini new file mode 100755 index 00000000..4ef9373e --- /dev/null +++ b/tox_opensearch.ini @@ -0,0 +1,23 @@ +[tox] +envlist = + py{36,37,38,39,310}-django{22,31,32}-opensearch{1,2} + +[testenv] +envlogdir= + examples/logs/ + examples/db/ + examples/tmp/ +passenv = * +deps = + django22: -r{toxinidir}/examples/requirements/django_2_2.txt + django31: -r{toxinidir}/examples/requirements/django_3_1.txt + django32: -r{toxinidir}/examples/requirements/django_3_2.txt + opensearch1: -r{toxinidir}/examples/requirements/opensearch_1x.txt + opensearch2: -r{toxinidir}/examples/requirements/opensearch_2x.txt +; coreapischema: -r{toxinidir}/examples/requirements/coreapi_coreschema.txt +; none: -r{toxinidir}/examples/requirements/none.txt +commands = + pip install -e . + pytest +; {envpython} runtests.py {posargs} +; {envpython} examples/simple/manage.py test {posargs:django_elasticsearch_dsl_drf} --settings=settings.testing --traceback -v 3