Skip to content

Commit

Permalink
chore: Fix deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Nov 4, 2021
1 parent a6957d1 commit 21f8a53
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions ocdsindex/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ def index(file, host):
for language_code, documents in data["documents"].items():
index = f"ocdsindex_{language_code}"

if not es.indices.exists(index):
if not es.indices.exists(index=index):
# https://www.elastic.co/guide/en/elasticsearch/reference/7.10/analysis-lang-analyzer.html
language = language_map.get(language_code, "standard")

# https://www.elastic.co/guide/en/elasticsearch/reference/7.10/indices-create-index.html
es.indices.create(
index,
index=index,
body={
# https://www.elastic.co/guide/en/elasticsearch/reference/7.10/mapping.html
"mappings": {
Expand All @@ -114,7 +114,7 @@ def index(file, host):
body.append({"index": {"_index": index, "_id": document["url"]}})
body.append(document)

es.bulk(body)
es.bulk(body=body)


@main.command()
Expand All @@ -141,7 +141,7 @@ def copy(host, source, destination):
body.append(document)

# raise Exception(repr(body))
es.bulk(body)
es.bulk(body=body)


@main.command()
Expand Down
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ def elasticsearch(host):


def search(es, index):
es.indices.refresh(index)
es.indices.refresh(index=index)

return es.search(index=index, size=10000)["hits"]
4 changes: 2 additions & 2 deletions tests/commands/test_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def test_copy(tmpdir):
assert result.exit_code == 0, traceback.print_exception(*result.exc_info)
assert result.output == ""

es.indices.refresh("ocdsindex_en")
es.indices.refresh("ocdsindex_es")
es.indices.refresh(index="ocdsindex_en")
es.indices.refresh(index="ocdsindex_es")

source = "https://standard.open-contracting.org/dev/"
destination = "https://standard.open-contracting.org/copy/"
Expand Down
8 changes: 4 additions & 4 deletions tests/commands/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ def test_index(tmpdir):
assert result.exit_code == 0, traceback.print_exception(*result.exc_info)
assert result.output == ""

assert es.indices.exists("ocdsindex_en")
assert es.indices.exists("ocdsindex_es")
assert es.indices.exists(index="ocdsindex_en")
assert es.indices.exists(index="ocdsindex_es")

assert es.indices.get("ocdsindex_en")["ocdsindex_en"]["mappings"] == {
assert es.indices.get(index="ocdsindex_en")["ocdsindex_en"]["mappings"] == {
"properties": {
"title": {"analyzer": "english", "type": "text"},
"text": {"analyzer": "english", "type": "text"},
Expand All @@ -36,7 +36,7 @@ def test_index(tmpdir):
"url": {"fields": {"keyword": {"ignore_above": 256, "type": "keyword"}}, "type": "text"},
}
}
assert es.indices.get("ocdsindex_es")["ocdsindex_es"]["mappings"] == {
assert es.indices.get(index="ocdsindex_es")["ocdsindex_es"]["mappings"] == {
"properties": {
"title": {"analyzer": "spanish", "type": "text"},
"text": {"analyzer": "spanish", "type": "text"},
Expand Down

0 comments on commit 21f8a53

Please sign in to comment.