Skip to content

Commit 7f26da1

Browse files
author
Phil Varner
committed
update to support Elasticsearch 8.x
1 parent 807bcf2 commit 7f26da1

File tree

7 files changed

+56
-15
lines changed

7 files changed

+56
-15
lines changed

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
- package-ecosystem: pip
8+
directory: "/.github/workflows"
9+
schedule:
10+
interval: daily
11+
- package-ecosystem: pip
12+
directory: "/stac_fastapi/elasticsearch"
13+
schedule:
14+
interval: daily

.github/workflows/cicd.yml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ jobs:
1212

1313
services:
1414

15-
elasticsearch_db_service:
16-
image: docker.elastic.co/elasticsearch/elasticsearch:7.14.2
15+
elasticsearch_7_svc:
16+
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.1
1717
env:
1818
node.name: es01
1919
cluster.name: stac-cluster
@@ -23,7 +23,19 @@ jobs:
2323
ES_JAVA_OPTS: -Xms512m -Xmx512m
2424
ports:
2525
- 9200:9200
26-
26+
27+
elasticsearch_8_svc:
28+
image: docker.elastic.co/elasticsearch/elasticsearch:8.1.0
29+
env:
30+
node.name: es01
31+
cluster.name: stac-cluster
32+
discovery.type: single-node
33+
network.host: 0.0.0.0
34+
http.port: 9400
35+
ES_JAVA_OPTS: -Xms512m -Xmx512m
36+
ports:
37+
- 9400:9400
38+
2739
steps:
2840
- name: Check out repository code
2941
uses: actions/checkout@v2
@@ -45,12 +57,22 @@ jobs:
4557
run: |
4658
pip install ./stac_fastapi/elasticsearch[dev,server]
4759
48-
- name: Run test suite
60+
- name: Run test suite against Elasticsearch 7.x
4961
run: |
5062
cd stac_fastapi/elasticsearch && pipenv run pytest -svvv
5163
env:
5264
ENVIRONMENT: testing
5365
ES_USER: dev
5466
ES_PASS: stac
5567
ES_PORT: 9200
68+
ES_HOST: 172.17.0.1
69+
70+
- name: Run test suite against Elasticsearch 8.x
71+
run: |
72+
cd stac_fastapi/elasticsearch && pipenv run pytest -svvv
73+
env:
74+
ENVIRONMENT: testing
75+
ES_USER: dev
76+
ES_PASS: stac
77+
ES_PORT: 9400
5678
ES_HOST: 172.17.0.1

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ docker-shell:
2626
.PHONY: test
2727
test:
2828
$(run_es) /bin/bash -c 'export && ./scripts/wait-for-it-es.sh elasticsearch:9200 && cd /app/stac_fastapi/elasticsearch/tests/ && pytest'
29+
#docker-compose down
2930

3031
.PHONY: run-database
3132
run-database:

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ docker-compose build
3333
docker-compose up
3434
```
3535

36+
By default, docker-compose uses Elasticsearch 8.x. If you wish to use a different version, put the following in a
37+
file named `.env` in the same directory you run docker-compose from:
38+
39+
```shell
40+
ELASTICSEARCH_VERSION=7.17.1
41+
```
42+
3643
To create a new Collection:
3744

3845
```shell

docker-compose.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ services:
3232

3333
elasticsearch:
3434
container_name: es-container
35-
image: docker.elastic.co/elasticsearch/elasticsearch:7.14.2
35+
image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-8.1.0}
3636
environment:
3737
node.name: es01
3838
cluster.name: stac-cluster
@@ -41,8 +41,4 @@ services:
4141
http.port: 9200
4242
ES_JAVA_OPTS: -Xms512m -Xmx512m
4343
ports:
44-
- 9200:9200
45-
46-
networks:
47-
default:
48-
name: stac-fastapi-es-network
44+
- "9200:9200"

stac_fastapi/elasticsearch/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"stac-fastapi.api==2.3.0",
1414
"stac-fastapi.extensions==2.3.0",
1515
"fastapi-utils",
16-
"elasticsearch[async]",
17-
"elasticsearch-dsl",
16+
"elasticsearch[async]==7.17.1",
17+
"elasticsearch-dsl==7.4.0",
1818
"pystac[validation]",
1919
"uvicorn",
2020
]

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/config.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class ElasticsearchSettings(ApiSettings):
2222
@property
2323
def create_client(self):
2424
"""Create es client."""
25-
# try:
26-
client = Elasticsearch([{"host": str(DOMAIN), "port": str(PORT)}])
27-
return client
25+
return Elasticsearch(
26+
[{"host": str(DOMAIN), "port": str(PORT)}],
27+
headers={"accept": "application/vnd.elasticsearch+json; compatible-with=7"},
28+
)

0 commit comments

Comments
 (0)