Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/support both opensearch and elasticsearch #305

Draft
wants to merge 26 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4e4f428
WIP making it compatible with opensearch
barseghyanartur Jul 21, 2022
be32e80
More on elasticsearch/opensearch compatibility
barseghyanartur Jul 22, 2022
dcbf96a
Tweaks
barseghyanartur Jul 22, 2022
4755e53
Uncomment previously commented out tests
barseghyanartur Jul 22, 2022
f4ac08f
Add docker-compose for opensearch
barseghyanartur Jul 22, 2022
c54ba75
Some more compat
barseghyanartur Jul 24, 2022
c5364dd
Fixes
barseghyanartur Jul 24, 2022
cc19fdf
Fixes
barseghyanartur Jul 24, 2022
bc51c1b
Try things out
barseghyanartur Jul 24, 2022
82a88ec
More
barseghyanartur Jul 24, 2022
857dd46
Fix attempt
barseghyanartur Jul 24, 2022
cf71b8a
Test with anysearch 0.1.5
barseghyanartur Jul 24, 2022
9c01747
Test with forked and patched with anysearch version of django-elastic…
barseghyanartur Jul 27, 2022
c5d7b65
Pin reqs to fork
barseghyanartur Jul 27, 2022
fae95c4
Testing against django-anysearch-dsl
barseghyanartur Jan 2, 2023
b24c5b5
Test against opensearch
barseghyanartur Jan 2, 2023
a910b7f
Proper names
barseghyanartur Jan 2, 2023
9239101
Fix opensearch workflow
barseghyanartur Jan 2, 2023
99c3b8c
Fix opensearch workflow attempt 2
barseghyanartur Jan 2, 2023
44ea7a8
Fix opensearch workflow attempt 3
barseghyanartur Jan 2, 2023
9feb517
Fix opensearch workflow attempt 4
barseghyanartur Jan 2, 2023
1d1ea15
Fixes in tests
barseghyanartur Jan 2, 2023
52b7d15
Fixes in tests attempt 2
barseghyanartur Jan 2, 2023
3d3473b
Fix tests and recompile reqs
barseghyanartur Jan 2, 2023
9fb5353
Fix issue with morelikethis
barseghyanartur Jan 3, 2023
6081519
Add online demo link
barseghyanartur Feb 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test
name: test elasticsearch

on: [push, pull_request]

Expand All @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down
158 changes: 158 additions & 0 deletions .github/workflows/test_opensearch.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 36 additions & 0 deletions COMPATIBILITY.rst
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Demos
=====
Online demo
-----------
Check the `live demo app <https://django-elasticsearch-dsl-drf.herokuapp.com>`__
Check the `live demo app <https://django-elasticsearch-dsl-drf.onrender.com/>`__
(Django 3.1 + Django REST Framework 3.12 + Elasticsearch 7.5) hosted on Heroku
and bonsai.io.

Expand Down
24 changes: 24 additions & 0 deletions docker-compose-opensearch-1.yml
Original file line number Diff line number Diff line change
@@ -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:
24 changes: 24 additions & 0 deletions docker-compose-opensearch-2.yml
Original file line number Diff line number Diff line change
@@ -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:
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -62,5 +62,5 @@ services:

volumes:
data:
esdata:
esdata1:
node_modules:
2 changes: 1 addition & 1 deletion docker/elasticsearch/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions docker/opensearch/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions docker/opensearch/Dockerfile_2
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions docker/opensearch/opensearch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
http.host: 0.0.0.0
transport.host: 127.0.0.1
discovery.type: single-node
plugins.security.disabled: true
Loading