Skip to content
This repository was archived by the owner on May 28, 2023. It is now read-only.

Commit 6ccd9cf

Browse files
author
tkostuch
committed
update var files and remove elastic7
1 parent bd480e7 commit 6ccd9cf

27 files changed

+9602
-7262
lines changed

README.md

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -111,22 +111,7 @@ Starting from [Elasitc 6 and 7](https://www.elastic.co/guide/en/elasticsearch/re
111111

112112
From now on, we're using the separate indexes per each entity type. The convention is: `${indexName}_${entityType}`. If your' **logical index name** is `vue_storefront_catalog` then it will be mapped to the **physical indexes** of: `vue_storefront_catalog_product`, `vue_storefront_catalog_category` ...
113113

114-
To take the advantage of this new logical->physical index distinction we've provided new Elastic tools: `db7`, `migrate7`, `dump7`, `restore7` tools. They can be used exactly the same way [like the old tools](https://docs.vuestorefront.io/guide/data/database-tool.html) were. The only distinction is that they work on separate indexes.
115-
116-
**Create new index**
117-
118-
Before restoreing or importing data you might want to create a new Elastic index with the proper data types/schema applied. You can run just the `yarn db7 new` command in order to do that.
119-
120-
**Restore the data**
121-
122-
After you ran the docker file and have Elastic7 up and running you might want to:
123-
124-
a) restore the demo data by running `yarn restore7` and `yarn restore7_it; yarn restore7_de` for default multistores. The data is restored from `var/catalog_product.json`, `var/catalog_category.json` and so on...
125-
126-
b) import the data from Magento to proper physical indexes. To do so, currently you can do this only with [mage2vuestorefront](https://github.com/DivanteLtd/mage2vuestorefront/pull/96).
127-
128-
**Note:** After 1.11 stable release (around November, 2019) we'll **replace** the standard tools: `db`, `migrate`, `dump`, `restore` with the Elastic 7 equivalents and it will become the default.
129-
114+
[Tools](https://docs.vuestorefront.io/guide/data/database-tool.html) are adjusted to ES7. You can use `yarn db new`, `yarn restore`, `yarn mage2vs import`. Just make sure that you have set up `config.elasticsearch.apiVersion` to `7.1`.
130115

131116
## API access
132117
Catalog API calls are compliant with ElasticSearch (it works like a filtering proxy to ES). More on ES queries: [ElasticSearch queries tutorial](http://okfnlabs.org/blog/2013/07/01/elasticsearch-query-tutorial.html)

config/elastic.schema.product.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@
8282
"id": {"type": "integer"},
8383
"attribute_id": {"type": "integer"},
8484
"default_frontend_label": {"type": "text"},
85-
"is_visible_on_front": {"type": "boolean"},
85+
"is_visible_on_front": {"type": "text"},
8686
"is_visible" : {"type": "boolean"},
8787
"frontend_input": {"type": "text"},
8888
"is_user_defined": {"type": "boolean"},
89-
"is_comparable": {"type": "boolean"},
89+
"is_comparable": {"type": "text"},
9090
"attribute_code": {"type": "text"},
9191
"options": {
9292
"properties": {

package.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,12 @@
1919
"cache": "node ./scripts/cache",
2020
"mage2vs": "node scripts/mage2vs.js",
2121
"restore": "node scripts/elastic.js restore && npm run db rebuild",
22-
"restore7": "node scripts/elastic7.js restore --output-index=vue_storefront_catalog && npm run db rebuild --indexName=vue_storefront_catalog",
23-
"restore7_it": "npm run restore7 -- --input-file=var/catalog_it.json --output-index=vue_storefront_catalog_it && npm run db rebuild -- --indexName=vue_storefront_catalog_it",
24-
"restore7_de": "npm run restore7 -- --input-file=var/catalog_de.json --output-index=vue_storefront_catalog_de && npm run db rebuild -- --indexName=vue_storefront_catalog_de",
2522
"restore_it": "npm run restore -- --input-file=var/catalog_it.json --output-index=vue_storefront_catalog_it && npm run db rebuild -- --indexName=vue_storefront_catalog_it",
2623
"restore_de": "npm run restore -- --input-file=var/catalog_de.json --output-index=vue_storefront_catalog_de && npm run db rebuild -- --indexName=vue_storefront_catalog_de",
2724
"restore2main": "npm run restore -- --output-index=vue_storefront_catalog",
2825
"dump": "node scripts/elastic.js dump",
29-
"dump_it": "npm run dump -- --input-index=vue_storefront_catalog_it --output-file=var/catalog_it.json",
30-
"dump_de": "npm run dump -- --input-index=vue_storefront_catalog_de --output-file=var/catalog_de.json",
31-
"dump7": "node scripts/elastic7.js dump",
32-
"dump7_it": "npm run dump7 -- --input-index=vue_storefront_catalog_it --output-file=var/catalog_it.json",
33-
"dump7_de": "npm run dump7 -- --input-index=vue_storefront_catalog_de --output-file=var/catalog_de.json",
26+
"dump_it": "npm run dump -- --input-index=vue_storefront_catalog --output-file=var/catalog_it.json",
27+
"dump_de": "npm run dump -- --input-index=vue_storefront_catalog --output-file=var/catalog_de.json",
3428
"kue": "node scripts/kue.js",
3529
"kue-dashboard": "npm run kue dashboard -- --port=3050",
3630
"o2m": "node src/worker/order_to_magento2.js start",

scripts/db.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const es7RebuildCommand = (cmd) => { // TODO: add parallel processing
5252
}
5353

5454
const es5RebuildCommand = (cmd) => { // TODO: add parallel processing
55+
console.warn(`es5 is deprecated and will be removed in 1.13`)
5556
if (!cmd.indexName) {
5657
console.error('error: indexName must be specified');
5758
process.exit(1);
@@ -140,6 +141,7 @@ const es7NewCommand = async (cmd) => { // TODO: add parallel processing
140141
}
141142

142143
const es5NewCommand = (cmd) => { // TODO: add parallel processing
144+
console.warn(`es5 is deprecated and will be removed in 1.13`)
143145
if (!cmd.indexName) {
144146
console.error('error: indexName must be specified');
145147
process.exit(1);

scripts/elastic.js

Lines changed: 76 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,98 @@ function stdOutErr (stdout, stderr) {
77
if (stderr.length > 0) { console.error(stderr.toString('utf8')) }
88
}
99

10+
/**
11+
* DUMP COMMAND
12+
*/
13+
const es5DumpCommand = (cmd) => {
14+
console.warn(`es5 is deprecated and will be removed in 1.13`)
15+
const input = `http://${config.host}:${config.port}/${cmd.inputIndex}`
16+
17+
const child = spawnSync('node', [
18+
'node_modules/elasticdump/bin/elasticdump',
19+
`--input=${input}`,
20+
`--output=${cmd.outputFile}`
21+
])
22+
stdOutErr(child.stdout, child.stderr)
23+
}
24+
25+
const es7DumpCommand = (cmd) => {
26+
if (!cmd.outputFile.indexOf('.json')) {
27+
console.error('Please provide the file name ending with .json ext.')
28+
}
29+
for (var indexTypeIterator in config.indexTypes) {
30+
var collectionName = config.indexTypes[indexTypeIterator]
31+
var inputIndex = `${cmd.inputIndex}_${collectionName}`
32+
var outputFile = cmd.outputFile.replace('.json', `_${collectionName}.json`)
33+
const input = `http://${config.host}:${config.port}/${inputIndex}`
34+
35+
const child = spawnSync('node', [
36+
'node_modules/elasticdump/bin/elasticdump',
37+
`--input=${input}`,
38+
`--output=${outputFile}`
39+
])
40+
stdOutErr(child.stdout, child.stderr)
41+
}
42+
}
43+
1044
program
1145
.command('dump')
1246
.option('--input-index <inputIndex>', 'index to dump', 'vue_storefront_catalog')
1347
.option('--output-file <outputFile>', 'path to the output file', 'var/catalog.json')
1448
.action((cmd) => {
15-
const input = `http://${config.host}:${config.port}/${cmd.inputIndex}`
49+
if (parseInt(config.apiVersion) < 6) {
50+
return es5DumpCommand(cmd)
51+
} else {
52+
return es7DumpCommand(cmd)
53+
}
54+
})
55+
56+
/**
57+
* RESTORE COMMAND
58+
*/
59+
60+
const es5RestoreCommand = (cmd) => {
61+
console.warn(`es5 is deprecated and will be removed in 1.13`)
62+
const output = `http://${config.host}:${config.port}/${cmd.outputIndex}`
63+
64+
const child = spawnSync('node', [
65+
'node_modules/elasticdump/bin/elasticdump',
66+
`--input=${cmd.inputFile}`,
67+
`--output=${output}`
68+
])
69+
stdOutErr(child.stdout, child.stderr)
70+
}
71+
72+
const es7RestoreCommand = (cmd) => {
73+
if (!cmd.inputFile.indexOf('.json')) {
74+
console.error('Please provide the file name ending with .json ext.')
75+
}
76+
for (var indexTypeIterator in config.indexTypes) {
77+
var collectionName = config.indexTypes[indexTypeIterator]
78+
var outputIndex = `${cmd.outputIndex}_${collectionName}`
79+
var inputFile = cmd.inputFile.replace('.json', `_${collectionName}.json`)
80+
81+
const output = `http://${config.host}:${config.port}/${outputIndex}`
1682

1783
const child = spawnSync('node', [
1884
'node_modules/elasticdump/bin/elasticdump',
19-
`--input=${input}`,
20-
`--output=${cmd.outputFile}`
85+
`--input=${inputFile}`,
86+
`--output=${output}`
2187
])
2288
stdOutErr(child.stdout, child.stderr)
23-
})
89+
}
90+
}
2491

2592
program
2693
.command('restore')
2794
.option('--output-index <outputIndex>', 'index to restore', 'vue_storefront_catalog')
2895
.option('--input-file <inputFile>', 'path to the input file', 'var/catalog.json')
2996
.action((cmd) => {
30-
const output = `http://${config.host}:${config.port}/${cmd.outputIndex}`
31-
32-
const child = spawnSync('node', [
33-
'node_modules/elasticdump/bin/elasticdump',
34-
`--input=${cmd.inputFile}`,
35-
`--output=${output}`
36-
])
37-
stdOutErr(child.stdout, child.stderr)
97+
if (parseInt(config.apiVersion) < 6) {
98+
return es5RestoreCommand(cmd)
99+
} else {
100+
return es7RestoreCommand(cmd)
101+
}
38102
})
39103

40104
program

scripts/elastic7.js

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)