Skip to content

Commit

Permalink
Merge pull request #345 from ror-community/staging
Browse files Browse the repository at this point in the history
Merge staging to main: Remove support for ES6
  • Loading branch information
lizkrznarich committed Jun 8, 2023
2 parents 4d93bd1 + 5b90953 commit fb049a9
Show file tree
Hide file tree
Showing 24 changed files with 190 additions and 2,740 deletions.
21 changes: 3 additions & 18 deletions .github/workflows/dev.yml
Expand Up @@ -9,28 +9,15 @@ jobs:
test:
runs-on: ubuntu-latest
env:
ELASTIC_HOST: "localhost"
ELASTIC_PORT: "9200"
ELASTIC7_HOST: "localhost"
ELASTIC7_PORT: "9201"
ELASTIC7_PORT: "9200"
ELASTIC_PASSWORD: "changeme"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
LAUNCH_DARKLY_KEY: ${{ secrets.LAUNCH_DARKLY_KEY_DEV }}
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.8.23
env:
discovery.type: single-node
ES_JAVA_OPTS: -Xms512m -Xmx512m
ELASTIC_PASSWORD: changeme
xpack.security.enabled: "false"
http.cors.enabled: "true"
http.cors.allow-origin: "*"
ports:
- 9200:9200
elasticsearch7:
image: docker.elastic.co/elasticsearch/elasticsearch:7.10.0
env:
Expand All @@ -40,9 +27,8 @@ jobs:
xpack.security.enabled: "false"
http.cors.enabled: "true"
http.cors.allow-origin: "*"
http.port: 9201
ports:
- 9201:9201
- 9200:9200
steps:
- name: Checkout ror-api code
uses: actions/checkout@v2
Expand Down Expand Up @@ -82,8 +68,7 @@ jobs:
- name: Setup
working-directory: ./ror-api
run: |
python manage.py setup $LATEST_DUMP_FILE 6
python manage.py setup $LATEST_DUMP_FILE 7
python manage.py setup $LATEST_DUMP_FILE
- name: Test
working-directory: ./ror-api
run: |
Expand Down
20 changes: 3 additions & 17 deletions .github/workflows/release.yml
Expand Up @@ -6,27 +6,15 @@ jobs:
test:
runs-on: ubuntu-latest
env:
ELASTIC_HOST: "localhost"
ELASTIC_PASSWORD: "changeme"
ELASTIC7_HOST: "localhost"
ELASTIC7_PORT: "9201"
ELASTIC7_PORT: "9200"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
LAUNCH_DARKLY_KEY: ${{ secrets.LAUNCH_DARKLY_KEY_PROD}}
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.8.23
env:
discovery.type: single-node
ES_JAVA_OPTS: -Xms512m -Xmx512m
ELASTIC_PASSWORD: changeme
xpack.security.enabled: "false"
http.cors.enabled: "true"
http.cors.allow-origin: "*"
ports:
- 9200:9200
elasticsearch7:
image: docker.elastic.co/elasticsearch/elasticsearch:7.10.0
env:
Expand All @@ -36,9 +24,8 @@ jobs:
xpack.security.enabled: "false"
http.cors.enabled: "true"
http.cors.allow-origin: "*"
http.port: 9201
ports:
- 9201:9201
- 9200:9200
steps:
- name: Checkout ror-api code
uses: actions/checkout@v2
Expand Down Expand Up @@ -78,8 +65,7 @@ jobs:
- name: Setup
working-directory: ./ror-api
run: |
python manage.py setup $LATEST_DUMP_FILE 6
python manage.py setup $LATEST_DUMP_FILE 7
python manage.py setup $LATEST_DUMP_FILE
- name: Test
working-directory: ./ror-api
run: |
Expand Down
20 changes: 3 additions & 17 deletions .github/workflows/staging.yml
Expand Up @@ -7,27 +7,15 @@ jobs:
test:
runs-on: ubuntu-latest
env:
ELASTIC_HOST: "localhost"
ELASTIC_PASSWORD: "changeme"
ELASTIC7_HOST: "localhost"
ELASTIC7_PORT: "9201"
ELASTIC7_PORT: "9200"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
LAUNCH_DARKLY_KEY: ${{ secrets.LAUNCH_DARKLY_KEY_STAGING }}
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.8.23
env:
discovery.type: single-node
ES_JAVA_OPTS: -Xms512m -Xmx512m
ELASTIC_PASSWORD: changeme
xpack.security.enabled: "false"
http.cors.enabled: "true"
http.cors.allow-origin: "*"
ports:
- 9200:9200
elasticsearch7:
image: docker.elastic.co/elasticsearch/elasticsearch:7.10.0
env:
Expand All @@ -37,9 +25,8 @@ jobs:
xpack.security.enabled: "false"
http.cors.enabled: "true"
http.cors.allow-origin: "*"
http.port: 9201
ports:
- 9201:9201
- 9200:9200
steps:
- name: Checkout ror-api code
uses: actions/checkout@v2
Expand Down Expand Up @@ -79,8 +66,7 @@ jobs:
- name: Setup
working-directory: ./ror-api
run: |
python manage.py setup $LATEST_DUMP_FILE 6
python manage.py setup $LATEST_DUMP_FILE 7
python manage.py setup $LATEST_DUMP_FILE
- name: Test
working-directory: ./ror-api
run: |
Expand Down
23 changes: 3 additions & 20 deletions docker-compose.yml
@@ -1,35 +1,18 @@
version: '3'

services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.8.23
ports:
- "9200:9200"
- "9300:9300"
environment:
discovery.type: single-node
ES_JAVA_OPTS: -Xmx256m -Xms256m
ELASTIC_PASSWORD: changeme
xpack.security.enabled: "false"
http.cors.enabled: "true"
http.cors.allow-origin: "*"
healthcheck:
test: curl -f http://elastic:changeme@elasticsearch:9200
interval: 10s
timeout: 1s
elasticsearch7:
image: docker.elastic.co/elasticsearch/elasticsearch:7.10.1
ports:
- "9201:9201"
- "9301:9301"
- "9200:9200"
- "9300:9300"
environment:
discovery.type: single-node
ES_JAVA_OPTS: -Xmx256m -Xms256m
ELASTIC_PASSWORD: changeme
xpack.security.enabled: "false"
http.cors.enabled: "true"
http.cors.allow-origin: "*"
http.port: 9201
healthcheck:
test: curl -f http://elastic:changeme@elasticsearch:8200
interval: 10s
Expand All @@ -45,4 +28,4 @@ services:
volumes:
- ./rorapi:/home/app/webapp/rorapi
depends_on:
- elasticsearch
- elasticsearch7
15 changes: 4 additions & 11 deletions rorapi/es_utils.py
@@ -1,22 +1,15 @@
from .settings import ES, ES7, ES_VARS
from .settings import ES7, ES_VARS

from elasticsearch_dsl import Search, Q


class ESQueryBuilder():
"""Elasticsearch query builder class"""
def __init__(self, enable_es_7):
if enable_es_7:
print("using ES7")
self.search = Search(using=ES7, index=ES_VARS['INDEX'])
self.search = self.search.extra(track_total_hits=True)
else:
print("using ES6")
self.search = Search(using=ES, index=ES_VARS['INDEX'])

def __init__(self):
self.search = Search(using=ES7, index=ES_VARS['INDEX'])
self.search = self.search.extra(track_total_hits=True)
self.search = self.search.params(search_type='dfs_query_then_fetch')


def add_id_query(self, id):
self.search = self.search.query('match',
id={
Expand Down

0 comments on commit fb049a9

Please sign in to comment.