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

Commit 40b5bcb

Browse files
authored
Merge pull request #342 from DivanteLtd/feature/es7
Elastic 7 Search support
2 parents 4034232 + 0052aad commit 40b5bcb

File tree

76 files changed

+7934
-7730
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+7934
-7730
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ src/config.json
1111
config/local.json
1212
config/certs/*.pem
1313
var/magento2-sample-data/
14+
var/*
1415
.migrate
1516
*.iml
1617
/docker/elasticsearch/data/
1718
!/docker/elasticsearch/data/.gitkeep
19+
/docker/elasticsearch7/data/
20+
!/docker/elasticsearch7/data/.gitkeep

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [1.11.0-rc.1] - UNRELEASED
88

99
### Added
10+
- Experimental Elastic 7 support - @pkarw (#342)
1011
- Output cache support with tagging and cache invalidate requests forwarding - @pkarw @resubaka (https://github.com/DivanteLtd/vue-storefront/issues/3367, #333)
1112
- Constant for Mailchimp subscription status - @KonstantinSoelch (#294)
1213
- mage2vs import now has optional `--generate-unique-url-keys` parameter which defaults to `false` to enable/disable the url key generation with name and id for categories - @rain2o (#232)
@@ -15,8 +16,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1516
- Added jest support - @resubaka (#321)
1617
- Added caching factory and action factory for the image endpoint. This gives the possibility to use other services for caching or image processing - @resubaka (#317, #315)
1718
- Added support for tax calculation where the values from customer_tax_class_ids is used - @resubaka (#307)
19+
- The `db` context object - passed to every api endpoint now has two usefull methods: `getElasticClient` and `getRedisClient` for accesing the data stores - @pkarw (#328)
20+
- The `lib/utils` got two new methods `getStoreCode(req: Express.Request)` and `getStoreView(code: string)` for getting the current multistore context from `vue-storefront` frontend requests - @pkarw
21+
22+
### Removed
23+
- The `scripts/seo.js` tool has been removed, the legacy `migrations` scripts have been removed, the unused legacy extensions (`gls-parcelshop-dk`, `postnord-parcelshop-dk`) - @pkarw (#342)
1824

1925
### Fixed
26+
- The way Elastic and Redis clients have been fixed and code duplication removed across the app - @pkarw (#327)
2027
- The `product.price_*` fields have been normalized with the backward compatibility support (see `config.tax.deprecatedPriceFieldsSupport` which is by default true) - @pkarw (#289)
2128
- The `product.final_price` field is now being taken into product price calcualtion. Moreover, we've added the `config.tax.finalPriceIncludesTax` - which is set to `true` by default. All the `price`, `original_price` and `special_price` fields are calculated accordingly. It was required as Magento2 uses `final_price` to set the catalog pricing rules after-prices - @pkarw (#289)
2229
- Force ES connections to use protocol config option - @cewald (#303, #304)

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,68 @@ A [Kibana](https://www.elastic.co/products/kibana) service is available to explo
6565

6666
At first access it will ask to specify an index pattern, insert `vue_storefront*`
6767

68+
**Note:** Kibana is not provided with the Elastic 7 docker file. Please install it on your own when needed or check the [`es-head`](https://chrome.google.com/webstore/detail/elasticsearch-head/ffmkiejjmecolpfloofpjologoblkegm) Chrome plugin.
69+
70+
## Elastic 7 support
71+
72+
By default, Vue Storefront API docker files and config are based on Elastic 5.6. We plan to change the default Elastic version to 7 with the 1.11 stable release. As for now, the [Elastic 7 support](https://github.com/DivanteLtd/vue-storefront-api/pull/342) is marked as **experimental**.
73+
74+
**How to use it?**
75+
76+
In order to use the new Elastic 7 please make sure your `vue-storefront-api` has been checked out from the [PR#342](https://github.com/DivanteLtd/vue-storefront-api/pull/342) branch.
77+
To start the Elastic 7 docker service please use the `docker-compose.elastic7.yml` file provided:
78+
79+
```bash
80+
docker-compose -f docker-compose.elastic7.yml up
81+
```
82+
83+
Then, please do change the `config/local.json` to start using the new Elastic API. Key properties in the `elasticsearch` section are: `indexTypes` and `apiVersion` (to be set to 7.1). If you're using the multistore configuration please make sure you adjusted the `storeViews.*.elasticsearch` section as well - per each separate store.
84+
85+
```json
86+
"elasticsearch": {
87+
"host": "localhost",
88+
"port": 9200,
89+
"protocol": "http",
90+
"min_score": 0.01,
91+
"indices": [
92+
"vue_storefront_catalog",
93+
"vue_storefront_catalog_de",
94+
"vue_storefront_catalog_it"
95+
],
96+
"indexTypes": [
97+
"product",
98+
"category",
99+
"cms_block",
100+
"cms_page",
101+
"attribute",
102+
"taxrule",
103+
"review"
104+
],
105+
"apiVersion": "7.1"
106+
}
107+
```
108+
109+
Starting from [Elasitc 6 and 7](https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking-changes-7.0.html) we can have **just single** document type per single index. Vue Storefront used to have `product`, `category` ... types defined in the `vue_storefront_catalog`.
110+
111+
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` ...
112+
113+
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.
114+
115+
**Create new index**
116+
117+
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.
118+
119+
**Restore the data**
120+
121+
After you ran the docker file and have Elastic7 up and running you might want to:
122+
123+
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...
124+
125+
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).
126+
127+
**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.
128+
129+
68130
## API access
69131
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)
70132

config/default.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
"host": "localhost",
2222
"port": 9200,
2323
"protocol": "http",
24-
"user": "elastic",
25-
"password": "changeme",
2624
"min_score": 0.01,
2725
"indices": [
2826
"vue_storefront_catalog",
@@ -32,7 +30,8 @@
3230
"indexTypes": [
3331
"product",
3432
"category",
35-
"cms",
33+
"cms_block",
34+
"cms_page",
3635
"attribute",
3736
"taxrule",
3837
"review"

config/elastic.schema.attribute.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
"options": {
1010
"properties": {
1111
"value": {
12-
"type": "text",
13-
"index": "not_analyzed"
12+
"type": "text"
1413
}
1514
}
1615
}

config/elastic.schema.block.extension.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

config/elastic.schema.category.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"is_active": {"type": "boolean"},
77
"product_count": {"type": "integer"},
88
"parent_id": {"type": "integer"},
9+
"position": {"type": "long"},
910
"created_at": {
1011
"type": "date",
1112
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
File renamed without changes.
File renamed without changes.

config/elastic.schema.page.extension.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)