Skip to content

Commit d3acbae

Browse files
author
Phil Varner
authored
add support for Elasticsearch 8, default to running that for local tests, and test both 7 and 8 in CI (#50)
* update client headers to support Elasticsearch 8.x
1 parent 053f130 commit d3acbae

File tree

8 files changed

+63
-17
lines changed

8 files changed

+63
-17
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: 28 additions & 6 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: 9200
35+
# ES_JAVA_OPTS: -Xms512m -Xmx512m
36+
# ports:
37+
# - 9200:9200
38+
2739
steps:
2840
- name: Check out repository code
2941
uses: actions/checkout@v2
@@ -44,13 +56,23 @@ jobs:
4456
- name: Install elasticsearch stac-fastapi
4557
run: |
4658
pip install ./stac_fastapi/elasticsearch[dev,server]
47-
48-
- name: Run test suite
59+
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
56-
ES_HOST: 172.17.0.1
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
78+
# ES_HOST: 172.17.0.1

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111

1212
### Added
1313

14+
- Support for Elasticsearch 7.x or 8.x
15+
1416
### Fixed
1517

1618
### Changed
@@ -19,4 +21,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1921

2022
### Removed
2123

24+
2225
[Unreleased]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/main>

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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ docker-compose build
3333
docker-compose up
3434
```
3535

36+
By default, docker-compose uses Elasticsearch 7.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.12.0
41+
```
42+
43+
TBD: how to run this with 8.x with a password enabled and TLS.
44+
3645
To create a new Collection:
3746

3847
```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:-7.17.1}
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)