Skip to content

Commit 14f3623

Browse files
max-moserntarocco
authored andcommitted
global: allow opensearch 2.x
1 parent 0c0317e commit 14f3623

File tree

8 files changed

+179
-13
lines changed

8 files changed

+179
-13
lines changed

.github/workflows/tests.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,28 @@ jobs:
3131
matrix:
3232
python-version: [3.7, 3.8, 3.9]
3333
requirements-level: [pypi]
34-
db-service: [postgresql10, postgresql13]
35-
search-service: [opensearch1,elasticsearch7]
34+
db-service: [postgresql10,postgresql13]
35+
search-service: [opensearch2,elasticsearch7]
3636
exclude:
3737
- python-version: 3.7
3838
db-service: postgresql13
39-
search-service: opensearch1
39+
search-service: opensearch2
4040

4141
- python-version: 3.7
4242
db-service: postgresql13
4343
search-service: elasticsearch7
4444

4545
- python-version: 3.8
4646
db-service: postgresql10
47-
search-service: opensearch1
47+
search-service: opensearch2
4848

4949
- python-version: 3.8
5050
db-service: postgresql10
5151
search-service: elasticsearch7
5252

5353
- python-version: 3.9
5454
db-service: postgresql10
55-
search-service: opensearch1
55+
search-service: opensearch2
5656

5757
- python-version: 3.9
5858
db-service: postgresql10
@@ -64,8 +64,8 @@ jobs:
6464
- db-service: postgresql13
6565
DB_EXTRAS: "postgresql"
6666

67-
- search-service: opensearch1
68-
SEARCH_EXTRAS: "opensearch1"
67+
- search-service: opensearch2
68+
SEARCH_EXTRAS: "opensearch2"
6969

7070
- search-service: elasticsearch7
7171
SEARCH_EXTRAS: "elasticsearch7"

INSTALL.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Invenio-Drafts-Resources is on PyPI so all you need is:
55

66
.. code-block:: console
77
8-
$ pip install invenio-drafts-resources[opensearch1,postgresql]
8+
$ pip install invenio-drafts-resources[opensearch2,postgresql]

setup.cfg

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,21 @@ packages = find:
2828
python_requires = >=3.7
2929
zip_safe = False
3030
install_requires =
31-
invenio-records-resources>=0.21.3,<0.22.0
31+
invenio-records-resources>=0.21.4,<0.22.0
3232

3333
[options.extras_require]
3434
tests =
3535
pytest-black>=0.3.0
36-
pytest-invenio>=2.0.0,<3.0.0
36+
pytest-invenio>=2.1.0,<3.0.0
3737
invenio-app>=1.3.1,<2.0.0
3838
Sphinx>=4.5.0
3939
invenio-db[mysql,postgresql]>=1.0.9,<2.0.0
4040
elasticsearch7 =
41-
invenio-search[elasticsearch7]>=2.0.0,<3.0.0
41+
invenio-search[elasticsearch7]>=2.1.0,<3.0.0
4242
opensearch1 =
43-
invenio-search[opensearch1]>=2.0.0,<3.0.0
43+
invenio-search[opensearch1]>=2.1.0,<3.0.0
44+
opensearch2 =
45+
invenio-search[opensearch2]>=2.1.0,<3.0.0
4446

4547
[options.entry_points]
4648
invenio_i18n.translations =
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# This file is part of Invenio.
4+
# Copyright (C) 2022 CERN.
5+
#
6+
# Invenio-Drafts-Resources is free software; you can redistribute it and/or
7+
# modify it under the terms of the MIT License; see LICENSE file for more
8+
# details.
9+
10+
"""OpenSearch version 2 mappings."""
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# This file is part of Invenio.
4+
# Copyright (C) 2022 CERN.
5+
#
6+
# Invenio-Drafts-Resources is free software; you can redistribute it and/or
7+
# modify it under the terms of the MIT License; see LICENSE file for more
8+
# details.
9+
10+
"""OpenSearch version 2 mappings."""
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"mappings": {
3+
"properties": {
4+
"id": {
5+
"type": "keyword"
6+
},
7+
"metadata": {
8+
"type": "object",
9+
"properties": {
10+
"title": {
11+
"type": "text"
12+
},
13+
"type": {
14+
"type": "object",
15+
"properties": {
16+
"type": {
17+
"type": "keyword"
18+
},
19+
"subtype": {
20+
"type": "keyword"
21+
}
22+
}
23+
}
24+
}
25+
},
26+
"parent": {
27+
"properties": {
28+
"id": {
29+
"type": "keyword"
30+
}
31+
}
32+
},
33+
"created": {
34+
"type": "date"
35+
},
36+
"updated": {
37+
"type": "date"
38+
},
39+
"expires_at": {
40+
"type": "date"
41+
},
42+
"uuid": {
43+
"type": "keyword"
44+
},
45+
"versions": {
46+
"properties": {
47+
"index": {
48+
"type": "integer"
49+
},
50+
"is_latest": {
51+
"type": "boolean"
52+
},
53+
"is_latest_draft": {
54+
"type": "boolean"
55+
},
56+
"latest_id": {
57+
"type": "keyword"
58+
},
59+
"latest_index": {
60+
"type": "integer"
61+
},
62+
"next_draft_id": {
63+
"type": "keyword"
64+
}
65+
}
66+
},
67+
"version_id": {
68+
"type": "integer"
69+
}
70+
}
71+
}
72+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"mappings": {
3+
"properties": {
4+
"id": {
5+
"type": "keyword"
6+
},
7+
"parent": {
8+
"properties": {
9+
"id": {
10+
"type": "keyword"
11+
}
12+
}
13+
},
14+
"metadata": {
15+
"type": "object",
16+
"properties": {
17+
"title": {
18+
"type": "text"
19+
},
20+
"type": {
21+
"type": "object",
22+
"properties": {
23+
"type": {
24+
"type": "keyword"
25+
},
26+
"subtype": {
27+
"type": "keyword"
28+
}
29+
}
30+
}
31+
}
32+
},
33+
"created": {
34+
"type": "date"
35+
},
36+
"updated": {
37+
"type": "date"
38+
},
39+
"expires_at": {
40+
"type": "date"
41+
},
42+
"uuid": {
43+
"type": "keyword"
44+
},
45+
"versions": {
46+
"properties": {
47+
"index": {
48+
"type": "integer"
49+
},
50+
"is_latest": {
51+
"type": "boolean"
52+
},
53+
"is_latest_draft": {
54+
"type": "boolean"
55+
},
56+
"latest_id": {
57+
"type": "keyword"
58+
},
59+
"latest_index": {
60+
"type": "integer"
61+
},
62+
"next_draft_id": {
63+
"type": "keyword"
64+
}
65+
}
66+
},
67+
"version_id": {
68+
"type": "integer"
69+
}
70+
}
71+
}
72+
}

tests/records/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def test_draft_indexing(app, db, search, example_draft, indexer):
263263
assert indexer.index(example_draft)["result"] == "created"
264264
# Retrieve document from search cluster
265265
data = current_search_client.get(
266-
"draftsresources-drafts-draft-v1.0.0", id=example_draft.id, doc_type="_doc"
266+
"draftsresources-drafts-draft-v1.0.0", id=example_draft.id
267267
)
268268

269269
# Loads the search cluster data and compare

0 commit comments

Comments
 (0)