Skip to content

Commit d70dd06

Browse files
authored
Merge pull request #154 from MITLibraries/timx-143-add-bulk-delete
Timx 143 add bulk delete
2 parents 2308c63 + fe73d48 commit d70dd06

17 files changed

+919
-124
lines changed

Pipfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ mypy = "*"
2222
pylama = {extras = ["all"], version = "*"}
2323
pytest = "*"
2424
vcrpy = "*"
25+
# pydocstyle added and pinned until pylama is updated to work with 6.2+, see
26+
# https://github.com/klen/pylama/issues/232
27+
pydocstyle = "==6.1.1"
2528

2629
[requires]
2730
python_version = "3.10"

Pipfile.lock

Lines changed: 234 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
content-type:
6+
- application/json
7+
user-agent:
8+
- opensearch-py/2.0.1 (Python 3.10.8)
9+
method: HEAD
10+
uri: http://localhost:9200/alma-2022-09-01t00-00-00
11+
response:
12+
body:
13+
string: ''
14+
headers:
15+
content-length:
16+
- '5009'
17+
content-type:
18+
- application/json; charset=UTF-8
19+
status:
20+
code: 200
21+
message: OK
22+
- request:
23+
body: '{"delete":{"_id":"mit:alma:990026671500206761","_index":"alma-2022-09-01t00-00-00"}}
24+
25+
{"delete":{"_id":"mit:alma:990027672770206761","_index":"alma-2022-09-01t00-00-00"}}
26+
27+
{"delete":{"_id":"mit:alma:9933052979806761","_index":"alma-2022-09-01t00-00-00"}}
28+
29+
'
30+
headers:
31+
Content-Length:
32+
- '253'
33+
content-type:
34+
- application/json
35+
user-agent:
36+
- opensearch-py/2.0.1 (Python 3.10.8)
37+
method: POST
38+
uri: http://localhost:9200/_bulk
39+
response:
40+
body:
41+
string: '{"took":29,"errors":false,"items":[{"delete":{"_index":"alma-2022-09-01t00-00-00","_type":"_doc","_id":"mit:alma:990026671500206761","_version":2,"result":"deleted","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":6,"_primary_term":1,"status":200}},{"delete":{"_index":"alma-2022-09-01t00-00-00","_type":"_doc","_id":"mit:alma:990027672770206761","_version":2,"result":"deleted","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":7,"_primary_term":1,"status":200}},{"delete":{"_index":"alma-2022-09-01t00-00-00","_type":"_doc","_id":"mit:alma:9933052979806761","_version":2,"result":"deleted","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":8,"_primary_term":1,"status":200}}]}'
42+
headers:
43+
content-length:
44+
- '703'
45+
content-type:
46+
- application/json; charset=UTF-8
47+
status:
48+
code: 200
49+
message: OK
50+
- request:
51+
body: null
52+
headers:
53+
Content-Length:
54+
- '0'
55+
content-type:
56+
- application/json
57+
user-agent:
58+
- opensearch-py/2.0.1 (Python 3.10.8)
59+
method: POST
60+
uri: http://localhost:9200/alma-2022-09-01t00-00-00/_refresh
61+
response:
62+
body:
63+
string: '{"_shards":{"total":2,"successful":1,"failed":0}}'
64+
headers:
65+
content-length:
66+
- '49'
67+
content-type:
68+
- application/json; charset=UTF-8
69+
status:
70+
code: 200
71+
message: OK
72+
version: 1
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
content-type:
6+
- application/json
7+
user-agent:
8+
- opensearch-py/2.0.1 (Python 3.10.8)
9+
method: GET
10+
uri: http://localhost:9200/_cat/aliases?format=json
11+
response:
12+
body:
13+
string: '[{"alias":"all-current","index":"alma-2022-09-01t00-00-00","filter":"-","routing.index":"-","routing.search":"-","is_write_index":"-"}]'
14+
headers:
15+
content-length:
16+
- '135'
17+
content-type:
18+
- application/json; charset=UTF-8
19+
status:
20+
code: 200
21+
message: OK
22+
- request:
23+
body: '{"delete":{"_id":"mit:alma:990026671500206761","_index":"alma-2022-09-01t00-00-00"}}
24+
25+
{"delete":{"_id":"mit:alma:990027672770206761","_index":"alma-2022-09-01t00-00-00"}}
26+
27+
{"delete":{"_id":"mit:alma:9933052979806761","_index":"alma-2022-09-01t00-00-00"}}
28+
29+
'
30+
headers:
31+
Content-Length:
32+
- '253'
33+
content-type:
34+
- application/json
35+
user-agent:
36+
- opensearch-py/2.0.1 (Python 3.10.8)
37+
method: POST
38+
uri: http://localhost:9200/_bulk
39+
response:
40+
body:
41+
string: '{"took":92,"errors":false,"items":[{"delete":{"_index":"alma-2022-09-01t00-00-00","_type":"_doc","_id":"mit:alma:990026671500206761","_version":2,"result":"deleted","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":15,"_primary_term":1,"status":200}},{"delete":{"_index":"alma-2022-09-01t00-00-00","_type":"_doc","_id":"mit:alma:990027672770206761","_version":2,"result":"deleted","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":16,"_primary_term":1,"status":200}},{"delete":{"_index":"alma-2022-09-01t00-00-00","_type":"_doc","_id":"mit:alma:9933052979806761","_version":2,"result":"deleted","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":17,"_primary_term":1,"status":200}}]}'
42+
headers:
43+
content-length:
44+
- '706'
45+
content-type:
46+
- application/json; charset=UTF-8
47+
status:
48+
code: 200
49+
message: OK
50+
- request:
51+
body: null
52+
headers:
53+
Content-Length:
54+
- '0'
55+
content-type:
56+
- application/json
57+
user-agent:
58+
- opensearch-py/2.0.1 (Python 3.10.8)
59+
method: POST
60+
uri: http://localhost:9200/alma-2022-09-01t00-00-00/_refresh
61+
response:
62+
body:
63+
string: '{"_shards":{"total":2,"successful":1,"failed":0}}'
64+
headers:
65+
content-length:
66+
- '49'
67+
content-type:
68+
- application/json; charset=UTF-8
69+
status:
70+
code: 200
71+
message: OK
72+
version: 1

tests/fixtures/cassettes/cli/bulk_index_no_primary_index_for_source.yaml renamed to tests/fixtures/cassettes/helpers/bulk_cli_no_primary_index_for_source.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ interactions:
55
content-type:
66
- application/json
77
user-agent:
8-
- opensearch-py/2.0.0 (Python 3.10.6)
8+
- opensearch-py/2.0.1 (Python 3.10.8)
99
method: GET
1010
uri: http://localhost:9200/_cat/aliases?format=json
1111
response:
1212
body:
13-
string: '[]'
13+
string: '[{"alias":"all-current","index":"alma-2022-09-01t00-00-00","filter":"-","routing.index":"-","routing.search":"-","is_write_index":"-"}]'
1414
headers:
1515
content-length:
16-
- '2'
16+
- '135'
1717
content-type:
1818
- application/json; charset=UTF-8
1919
status:
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
interactions:
2+
- request:
3+
body: '{"delete":{"_id":"no-record-here","_index":"alma-2022-09-01t00-00-00"}}
4+
5+
'
6+
headers:
7+
Content-Length:
8+
- '72'
9+
content-type:
10+
- application/json
11+
user-agent:
12+
- opensearch-py/2.0.1 (Python 3.10.8)
13+
method: POST
14+
uri: http://localhost:9200/_bulk
15+
response:
16+
body:
17+
string: '{"took":5,"errors":false,"items":[{"delete":{"_index":"alma-2022-09-01t00-00-00","_type":"_doc","_id":"no-record-here","_version":1,"result":"not_found","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":27,"_primary_term":1,"status":404}}]}'
18+
headers:
19+
content-length:
20+
- '248'
21+
content-type:
22+
- application/json; charset=UTF-8
23+
status:
24+
code: 200
25+
message: OK
26+
- request:
27+
body: null
28+
headers:
29+
Content-Length:
30+
- '0'
31+
content-type:
32+
- application/json
33+
user-agent:
34+
- opensearch-py/2.0.1 (Python 3.10.8)
35+
method: POST
36+
uri: http://localhost:9200/alma-2022-09-01t00-00-00/_refresh
37+
response:
38+
body:
39+
string: '{"_shards":{"total":2,"successful":1,"failed":0}}'
40+
headers:
41+
content-length:
42+
- '49'
43+
content-type:
44+
- application/json; charset=UTF-8
45+
status:
46+
code: 200
47+
message: OK
48+
version: 1
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
interactions:
2+
- request:
3+
body:
4+
'{"delete":{"_id":"no-record-here","_index":"alma-2022-09-01t00-00-00"}}
5+
6+
'
7+
headers:
8+
Content-Length:
9+
- "72"
10+
content-type:
11+
- application/json
12+
user-agent:
13+
- opensearch-py/2.0.1 (Python 3.10.8)
14+
method: POST
15+
uri: http://localhost:9200/_bulk
16+
response:
17+
body:
18+
string: '{"took":5,"errors":true,"items":[{"delete":{"_index":"alma-2022-09-01t00-00-00","_type":"_doc","_id":"no-record-here","_version":1,"result":"surprise!","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":27,"_primary_term":1,"status":404}}]}'
19+
headers:
20+
content-length:
21+
- "249"
22+
content-type:
23+
- application/json; charset=UTF-8
24+
status:
25+
code: 200
26+
message: OK
27+
- request:
28+
body: null
29+
headers:
30+
Content-Length:
31+
- "0"
32+
content-type:
33+
- application/json
34+
user-agent:
35+
- opensearch-py/2.0.1 (Python 3.10.8)
36+
method: POST
37+
uri: http://localhost:9200/alma-2022-09-01t00-00-00/_refresh
38+
response:
39+
body:
40+
string: '{"_shards":{"total":2,"successful":1,"failed":0}}'
41+
headers:
42+
content-length:
43+
- "49"
44+
content-type:
45+
- application/json; charset=UTF-8
46+
status:
47+
code: 200
48+
message: OK
49+
version: 1

0 commit comments

Comments
 (0)