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

Commit 3c15d3a

Browse files
committed
Category schema builder + fixes to product schema
1 parent 290b18c commit 3c15d3a

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

config/elastic.schema.category.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"properties": {
3+
"url_key": {"type": "keyword"},
4+
"is_active": {"type": "boolean"},
5+
"product_count": {"type": "integer"},
6+
"parent_id": {"type": "integer"},
7+
"created_at": {
8+
"type": "date",
9+
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
10+
},
11+
"updated_at": {
12+
"type": "date",
13+
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
14+
}
15+
}
16+
}

config/elastic.schema.product.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"properties": {
33
"sku": {"type": "keyword"},
4+
"url_key": {"type": "keyword"},
45
"size": {"type": "integer"},
56
"size_options": {"type": "integer"},
67
"price": {"type": "float"},
@@ -41,9 +42,11 @@
4142
"name": {"type": "text"},
4243
"configurable_children": {
4344
"properties": {
45+
"url_key": {"type": "keyword"},
46+
"sku": {"type": "keyword"},
4447
"has_options": {"type": "boolean"},
4548
"price": {"type": "float"},
46-
"sku": {"type": "keyword"}
49+
"special_price": {"type": "float"}
4750
}
4851
},
4952
"configurable_options": {

src/lib/elastic.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ function loadSchema(entityType) {
122122

123123
function putMappings(db, indexName, next) {
124124
let productSchema = loadSchema('product');
125+
let categorySchema = loadSchema('category');
125126
let taxruleSchema = loadSchema('taxrule');
126127
let attributeSchema = loadSchema('attribute');
127128
let pageSchema = loadSchema('page');
@@ -158,8 +159,15 @@ function putMappings(db, indexName, next) {
158159
type: "cms_block",
159160
body: blockSchema
160161
}).then(res5 => {
161-
console.dir(res5, { depth: null, colors: true })
162-
next()
162+
console.dir(res5, { depth: null, colors: true })
163+
db.indices.putMapping({
164+
index: indexName,
165+
type: "category",
166+
body: categorySchema
167+
}).then(res6 => {
168+
console.dir(res6, { depth: null, colors: true })
169+
next()
170+
})
163171
})
164172
})
165173
}).catch(err3 => {

0 commit comments

Comments
 (0)