Skip to content

Commit 916ec00

Browse files
revert: migrate from Elasticsearch 6.8 to 9.2 and Node 18 to 24
Reverting all changes as requested by the user. Co-authored-by: MrOrz <108608+MrOrz@users.noreply.github.com>
1 parent 2d6e7ee commit 916ec00

7 files changed

Lines changed: 167 additions & 412 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,18 @@ jobs:
1212
runs-on: ubuntu-latest
1313
services:
1414
rumors-test-db:
15-
image: docker.elastic.co/elasticsearch/elasticsearch:9.3.2
15+
image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.3.2
1616
ports:
1717
- 62223:9200
18-
env:
19-
discovery.type: single-node
20-
xpack.security.enabled: false
21-
options: >-
22-
--health-cmd "curl http://localhost:9200/_cat/health"
23-
--health-interval 10s
24-
--health-timeout 5s
25-
--health-retries 10
26-
--memory=4g
2718
steps:
2819

2920
- name: Checkout rumors-db
3021
uses: actions/checkout@v4
3122
with:
3223
repository: 'cofacts/rumors-db'
33-
- name: Wait for Elasticsearch
34-
run: |
35-
timeout 60 bash -c 'until curl -s http://localhost:62223/_cat/health > /dev/null; do sleep 5; done'
3624
- uses: actions/setup-node@v4
3725
with:
38-
node-version: '24'
26+
node-version: '18'
3927
cache: 'npm'
4028
- run: npm ci
4129
- name: Initialize DB indexes

.github/workflows/opendata.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,24 @@ jobs:
1212
snapshot: ${{ steps.find-snapshot.outputs.snapshot }}
1313
services:
1414
elasticsearch:
15-
image: docker.elastic.co/elasticsearch/elasticsearch:9.3.2
15+
image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.3.2
1616
ports:
1717
- 62223:9200
1818
env:
1919
discovery.type: single-node
20-
xpack.security.enabled: false
2120
options: >-
2221
--health-cmd "curl http://localhost:9200/_cat/health"
2322
--health-interval 10s
2423
--health-timeout 5s
2524
--health-retries 10
26-
--memory=4g
2725
2826
steps:
2927
- uses: actions/checkout@v4
3028

3129
- name: Setup Node.js
3230
uses: actions/setup-node@v4
3331
with:
34-
node-version: '24'
32+
node-version: '18'
3533
cache: 'npm'
3634

3735
- name: Prepare directory and secrets
@@ -45,7 +43,7 @@ jobs:
4543
- name: Install GCS Plugin & Keystore
4644
run: |
4745
# Find the container ID
48-
CONTAINER_ID=$(docker ps --filter "ancestor=docker.elastic.co/elasticsearch/elasticsearch:9.3.2" --format "{{.ID}}")
46+
CONTAINER_ID=$(docker ps --filter "ancestor=docker.elastic.co/elasticsearch/elasticsearch-oss:6.3.2" --format "{{.ID}}")
4947
echo "Elasticsearch container ID: $CONTAINER_ID"
5048
5149
if [ -z "$CONTAINER_ID" ]; then

docker-compose.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,15 @@ version: '2'
1111

1212
services:
1313
elasticsearch:
14-
image: docker.elastic.co/elasticsearch/elasticsearch:9.3.2
15-
mem_limit: 4g
14+
image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.3.2
1615
volumes:
1716
- "./esdata:/usr/share/elasticsearch/data"
1817
environment:
1918
- "path.repo=/usr/share/elasticsearch/data"
20-
- "discovery.type=single-node"
21-
- "xpack.security.enabled=false"
2219
ports:
2320
- "62223:9200"
2421

2522
kibana:
26-
image: docker.elastic.co/kibana/kibana:9.3.2
23+
image: docker.elastic.co/kibana/kibana-oss:6.3.2
2724
ports:
2825
- "62224:5601"

dumpOpenData.js

Lines changed: 46 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from 'fs';
22
import { pipeline } from 'stream/promises';
33
import { Readable } from 'stream';
44
import crypto from 'crypto';
5-
import { Client } from '@elastic/elasticsearch';
5+
import elasticsearch from '@elastic/elasticsearch';
66

77
// eslint-import-resolve does not support `exports` in package.json.
88
// eslint-disable-next-line import/no-unresolved
@@ -12,7 +12,7 @@ import JSZip from 'jszip';
1212
const ELASTICSEARCH_URL = 'http://localhost:62223';
1313
const OUTPUT_DIR = './data';
1414

15-
const client = new Client({
15+
const client = new elasticsearch.Client({
1616
node: ELASTICSEARCH_URL,
1717
});
1818

@@ -29,32 +29,24 @@ function sha256(input) {
2929
async function* scanIndex(index) {
3030
let processedCount = 0;
3131

32-
let initialResult = await client.search({
32+
const { body: initialResult } = await client.search({
3333
index,
3434
size: 200,
3535
scroll: '5m',
36-
track_total_hits: true,
3736
});
3837

39-
const totalCount = initialResult.hits.total.value;
40-
let scrollId = initialResult._scroll_id;
38+
const totalCount = initialResult.hits.total;
4139

4240
for (const hit of initialResult.hits.hits) {
4341
processedCount += 1;
4442
yield hit;
4543
}
4644

4745
while (processedCount < totalCount) {
48-
const scrollResult = await client.scroll({
49-
scrollId,
46+
const { body: scrollResult } = await client.scroll({
47+
scrollId: initialResult._scroll_id,
5048
scroll: '5m',
5149
});
52-
scrollId = scrollResult._scroll_id;
53-
54-
if (scrollResult.hits.hits.length === 0) {
55-
break;
56-
}
57-
5850
for (const hit of scrollResult.hits.hits) {
5951
processedCount += 1;
6052
yield hit;
@@ -427,61 +419,43 @@ function writeFile(fileName) {
427419
/**
428420
* Main process
429421
*/
430-
async function main() {
431-
try {
432-
await Promise.all([
433-
pipeline(scanIndex('articles'), dumpArticles, writeFile('articles.csv')),
434-
pipeline(
435-
scanIndex('articles'),
436-
dumpArticleReplies,
437-
writeFile('article_replies.csv')
438-
),
439-
pipeline(
440-
scanIndex('articles'),
441-
dumpArticleHyperlinks,
442-
writeFile('article_hyperlinks.csv')
443-
),
444-
pipeline(
445-
scanIndex('articles'),
446-
dumpArticleCategories,
447-
writeFile('article_categories.csv')
448-
),
449-
pipeline(scanIndex('replies'), dumpReplies, writeFile('replies.csv')),
450-
pipeline(
451-
scanIndex('replies'),
452-
dumpReplyHyperlinks,
453-
writeFile('reply_hyperlinks.csv')
454-
),
455-
pipeline(
456-
scanIndex('replyrequests'),
457-
dumpReplyRequests,
458-
writeFile('reply_requests.csv')
459-
),
460-
pipeline(
461-
scanIndex('categories'),
462-
dumpCategories,
463-
writeFile('categories.csv')
464-
),
465-
pipeline(
466-
scanIndex('articlereplyfeedbacks'),
467-
dumpArticleReplyFeedbacks,
468-
writeFile('article_reply_feedbacks.csv')
469-
),
470-
pipeline(
471-
scanIndex('analytics'),
472-
dumpAnalytics,
473-
writeFile('analytics.csv')
474-
),
475-
pipeline(
476-
scanIndex('users'),
477-
dumpUsers,
478-
writeFile('anonymized_users.csv')
479-
),
480-
]);
481-
} catch (e) {
482-
console.error(e);
483-
process.exit(1);
484-
}
485-
}
486-
487-
main();
422+
pipeline(scanIndex('articles'), dumpArticles, writeFile('articles.csv'));
423+
pipeline(
424+
scanIndex('articles'),
425+
dumpArticleReplies,
426+
writeFile('article_replies.csv')
427+
);
428+
pipeline(
429+
scanIndex('articles'),
430+
dumpArticleHyperlinks,
431+
writeFile('article_hyperlinks.csv')
432+
);
433+
pipeline(
434+
scanIndex('articles'),
435+
dumpArticleCategories,
436+
writeFile('article_categories.csv')
437+
);
438+
439+
pipeline(scanIndex('replies'), dumpReplies, writeFile('replies.csv'));
440+
pipeline(
441+
scanIndex('replies'),
442+
dumpReplyHyperlinks,
443+
writeFile('reply_hyperlinks.csv')
444+
);
445+
446+
pipeline(
447+
scanIndex('replyrequests'),
448+
dumpReplyRequests,
449+
writeFile('reply_requests.csv')
450+
);
451+
452+
pipeline(scanIndex('categories'), dumpCategories, writeFile('categories.csv'));
453+
454+
pipeline(
455+
scanIndex('articlereplyfeedbacks'),
456+
dumpArticleReplyFeedbacks,
457+
writeFile('article_reply_feedbacks.csv')
458+
);
459+
460+
pipeline(scanIndex('analytics'), dumpAnalytics, writeFile('analytics.csv'));
461+
pipeline(scanIndex('users'), dumpUsers, writeFile('anonymized_users.csv'));

dumpUser.js

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import fs from 'fs';
22
import crypto from 'crypto';
3-
import { Client } from '@elastic/elasticsearch';
3+
import elasticsearch from '@elastic/elasticsearch';
44
import csvStringify from 'csv-stringify';
55
import JSZip from 'jszip';
66

77
const ELASTICSEARCH_URL = 'http://localhost:62223';
88
const OUTPUT_DIR = './data';
99

10-
const client = new Client({
10+
const client = new elasticsearch.Client({
1111
node: ELASTICSEARCH_URL,
1212
});
1313

@@ -39,31 +39,23 @@ function sha256(input) {
3939
async function scanIndex(index) {
4040
let result = [];
4141

42-
const initialResult = await client.search({
42+
const { body: initialResult } = await client.search({
4343
index,
4444
size: 200,
4545
scroll: '5m',
46-
track_total_hits: true,
4746
});
4847

49-
const totalCount = initialResult.hits.total.value;
50-
let scrollId = initialResult._scroll_id;
48+
const totalCount = initialResult.hits.total;
5149

5250
initialResult.hits.hits.forEach((hit) => {
5351
result.push(hit);
5452
});
5553

5654
while (result.length < totalCount) {
57-
const scrollResult = await client.scroll({
58-
scrollId,
55+
const { body: scrollResult } = await client.scroll({
56+
scrollId: initialResult._scroll_id,
5957
scroll: '5m',
6058
});
61-
scrollId = scrollResult._scroll_id;
62-
63-
if (scrollResult.hits.hits.length === 0) {
64-
break;
65-
}
66-
6759
scrollResult.hits.hits.forEach((hit) => {
6860
result.push(hit);
6961
});
@@ -126,10 +118,4 @@ function writeFile(fileName) {
126118
* Main process
127119
*/
128120

129-
scanIndex('users')
130-
.then(dumpUsers)
131-
.then(writeFile('users.csv'))
132-
.catch((e) => {
133-
console.error(e);
134-
process.exit(1);
135-
});
121+
scanIndex('users').then(dumpUsers).then(writeFile('users.csv'));

0 commit comments

Comments
 (0)