Sitecore Commerce: Elasticsearch driven Faceted Search/Navigation for eCommerce – Part 2

In Part 1 of this series we described the faceted search/navigation search pattern with an example from the northface.com website. We also installed Elasticsearch and Kibana. In this post we’ll be setting up the index, define the data structure, create a mapping document, load some sample data and start constructing a query for faceted search/navigation.

Creating the Index
To store and index data in elasticsearch we first need to create an index. The index can have specific settings associated with it and can be defined in the body of the request. We will set the number_of_shards and number_of_replicas to 1 for simplicity and to avoid an issue where the result item scores can be incorrect with multiple shards and very small dataset.

Query:

1
2
3
4
5
6
7
8
9
PUT productitems
{
    "settings": {
    "index":{
            "number_of_shards": 1,
            "number_of_replicas": 1
        }
    }
}

Response:

1
2
3
4
5
{
    "acknowledged": true,
    "shards_acknowledged": true,
    "index": "productitems"
}

Defining the data structure
We have a concept of the Product which describes the product being sold. It has a Product Id, Name, Description, Image, Specifications, etc. The product may come in different variations, for example color or sizes in case of clothing products. A variation is represented by Variant entity. A Variant is what is actually inventoried, sold, and shipped when a customer purchases a product. It has a SKU, Price, Stock, Variant Image and other Variant specific attributes (color, size, etc.) associated with it.

The following Product->Variants structure represents a Color-Size attribute combination typical of a clothing product.

Product: Men’s Venture 2 Jacket

  • Variant: Red-Small
  • Variant: Red-Medium
  • Variant: Red-Large
  • Variant: Blue-Small
  • Variant: Blue-Medium
  • Variant: Blue-Large
  • Variant: Yellow-Small
  • Variant: Yellow-Medium
  • Variant: Yellow-Large

A JSON representation of such a hierarchy would look something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{
  "product_id": "NF0A2VD3",
  "product_name": "MEN'S VENTURE 2 JACKET",
  "product_image": "http://www.khopdi.com/wp-content/uploads/Posts/Sitecore-Elasticsearch/NF0A2VD3_5PL_hero.jpg",
  "product_base_price": 99.00,
  "product_description": "Lightweight, waterproof and windproof jacket that features a durable yet breathable ripstop exterior, Relaxed Fit and adjustable hood that leaves room for a helmet and extra layer",
  "product_brand": "The North Face",
  "variants" : [{
                    "variant_name": "Red Men's Venture 2 Jacket - Small",
                    "variant_id": "5PLRS",
                    "variant_price": 99.00,
                    "variant_primary_color": "Red"
                    "variant_size": "S",
                    "variant_image":"http://www.khopdi.com/wp-content/uploads/Posts/Sitecore-Elasticsearch/NF0A2VD3_5PL_hero.jpg",
                },
                {
                    "variant_name": "Red Men's Venture 2 Jacket - Medium",
                    "variant_id": "5PLRM",
                    "variant_price": 99.00,
                    "variant_primary_color": "Red"
                    "variant_size": "M",
                    "variant_image":"http://www.khopdi.com/wp-content/uploads/Posts/Sitecore-Elasticsearch/NF0A2VD3_5PL_hero.jpg",
                },
                {  
                    "variant_name": "Blue Men's Venture 2 Jacket - Small",
                    "variant_id": "5PLBS",
                    "variant_price": 99.00,
                    "variant_primary_color": "Blue"
                    "variant_size": "S",
                    "variant_image":"http://www.khopdi.com/wp-content/uploads/Posts/Sitecore-Elasticsearch/NF0A2VD3_7KR_hero.jpg",
                },
                {
                    "variant_name": "Blue Men's Venture 2 Jacket - Medium",
                    "variant_id": "5PLBM",
                    "variant_price": 99.00,
                    "variant_primary_color": "Blue"
                    "variant_size": "M",
                    "variant_image":"http://www.khopdi.com/wp-content/uploads/Posts/Sitecore-Elasticsearch/NF0A2VD3_7KS_hero.jpg",
                }
              ]
}

Denormalizing the data structure
In our NorthFace.com example from Part 1, we performed a faceted search for Red and Orange Jackets and the results came back with the images showing the appropriate colors. To be able to achieve this we need to index the Variants instead of the Products. Doing this brings up a problem though. Now if you searched for “Jacket” without the color facet selected you will get all Variants for a Product showing up in the results. This is not an ideal experience but thankfully there is a way to fix it which I’ll describe shortly.

JSON Representation of denormalized data:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
[{
    "product_id": "NF0A2VD3",
    "product_name": "MEN'S VENTURE 2 JACKET",
    "product_image": "http://www.khopdi.com/wp-content/uploads/Posts/Sitecore-Elasticsearch/NF0A2VD3_5PL_hero.jpg",
    "product_base_price": 99.00,
    "product_description": "Lightweight, waterproof and windproof jacket that features a durable yet breathable ripstop exterior, Relaxed Fit and adjustable hood that leaves room for a helmet and extra layer",
    "product_brand": "The North Face",
    "variant_name": "Red Men's Venture 2 Jacket - Small",
    "variant_id": "5PLR-S",
    "variant_price": 99.00,
    "variant_primary_color": "Red",
    "variant_size": "S",
    "variant_image":"http://www.khopdi.com/wp-content/uploads/Posts/Sitecore-Elasticsearch/NF0A2VD3_5PL_hero.jpg"
 },
{
    "product_id": "NF0A2VD3",
    "product_name": "MEN'S VENTURE 2 JACKET",
    "product_image": "http://www.khopdi.com/wp-content/uploads/Posts/Sitecore-Elasticsearch/NF0A2VD3_5PL_hero.jpg",
    "product_base_price": 99.00,
    "product_description": "Lightweight, waterproof and windproof jacket that features a durable yet breathable ripstop exterior, Relaxed Fit and adjustable hood that leaves room for a helmet and extra layer",
    "product_brand": "The North Face",
    "variant_name": "Red Men's Venture 2 Jacket - Medium",
    "variant_id": "5PLR-M",
    "variant_price": 99.00,
    "variant_primary_color": "Red",
    "variant_size": "M",
    "variant_image":"http://www.khopdi.com/wp-content/uploads/Posts/Sitecore-Elasticsearch/NF0A2VD3_5PL_hero.jpg",
},
{  
    "product_id": "NF0A2VD3",
    "product_name": "MEN'S VENTURE 2 JACKET",
    "product_image": "http://www.khopdi.com/wp-content/uploads/Posts/Sitecore-Elasticsearch/NF0A2VD3_5PL_hero.jpg",
    "product_base_price": 99.00,
    "product_description": "Lightweight, waterproof and windproof jacket that features a durable yet breathable ripstop exterior, Relaxed Fit and adjustable hood that leaves room for a helmet and extra layer",
    "product_brand": "The North Face",
    "variant_name": "Blue Men's Venture 2 Jacket - Small",
    "variant_id": "7KR-S",
    "variant_price": 99.00,
    "variant_primary_color": "Blue",
    "variant_size": "S",
    "variant_image":"http://www.khopdi.com/wp-content/uploads/Posts/Sitecore-Elasticsearch/NF0A2VD3_7KR_hero.jpg",
},
{
    "product_id": "NF0A2VD3",
    "product_name": "MEN'S VENTURE 2 JACKET",
    "product_image": "http://www.khopdi.com/wp-content/uploads/Posts/Sitecore-Elasticsearch/NF0A2VD3_5PL_hero.jpg",
    "product_base_price": 99.00,
    "product_description": "Lightweight, waterproof and windproof jacket that features a durable yet breathable ripstop exterior, Relaxed Fit and adjustable hood that leaves room for a helmet and extra layer",
    "product_brand": "The North Face",
    "variant_name": "Blue Men's Venture 2 Jacket - Medium",
    "variant_id": "7KR-M",
    "variant_price": 99.00,
    "variant_primary_color": "Blue",
    "variant_size": "M",
    "variant_image":"http://www.khopdi.com/wp-content/uploads/Posts/Sitecore-Elasticsearch/NF0A2VD3_7KR_hero.jpg",
}]

Loading Sample Data in the Index
We’ll just use the Dev Tools in kibana to load sample data. We have 36 items in our sample data and I’ve crafted the JSON to insert them one at a time, There is a way to bulk load data in to elasticsearch using the _bulk endpoint, but I just used the regular post method and selected all the POST statements to execute them all at once.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
 /productitems/_doc
{
    "product_id": "NF0A33QV",
    "product_name": "MEN'S CAMPSHIRE PULLOVER HOODIE",
    "product_image": "http://www.khopdi.com/nf0a33qv_hk9_hero",
    "product_base_price": 149,
    "product_description": "Stay warmer while soaking up camp vibes in this heavyweight pullover hoodie that’s crafted of warm Sherpa fleece.",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Fleece",
    "product_activity": "hiking",
    "variant_name": "Black Men's Campshire Pullover Hoodie - Medium",
    "variant_id":"6HJ-M",
    "variant_price":149,
    "variant_primary_color":"Black",
    "variant_colors": ["WEATHERED BLACK", "CARGO KHAKI"],
    "variant_size":"M",
    "variant_image": "http://www.khopdi.com/nf0a33qv_6hj_hero"
}

POST /productitems/_doc
{
    "product_id": "NF0A2VD3",
    "product_name": "MEN'S VENTURE 2 JACKET",
    "product_image": "http://www.khopdi.com/nf0a2vd3_5pl_hero",
    "product_base_price": 99,
    "product_description": "lightweight, waterproof and windproof jacket that features a durable yet breathable ripstop exterior, Relaxed Fit and adjustable hood that leaves room for a helmet and extra layer",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Rainwear",
    "product_activity": "hiking",
    "variant_name": "Red Men's Venture 2 Jacket - Medium",
    "variant_id":"5PLR-M",
    "variant_price":99,
    "variant_primary_color":"Red",
    "variant_colors": ["RAGE RED", "FIG BROWN"],
    "variant_size":"M",
    "variant_image": "http://www.khopdi.com/nf0a2vd3_5pl_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A2VD3",
    "product_name": "MEN'S VENTURE 2 JACKET",
    "product_image": "http://www.khopdi.com/nf0a2vd3_5pl_hero",
    "product_base_price": 99,
    "product_description": "lightweight, waterproof and windproof jacket that features a durable yet breathable ripstop exterior, Relaxed Fit and adjustable hood that leaves room for a helmet and extra layer",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Rainwear",
    "product_activity": "hiking",
    "variant_name": "Red Men's Venture 2 Jacket - Large",
    "variant_id":"5PLR-L",
    "variant_price":99,
    "variant_primary_color":"Red",
    "variant_colors": ["RAGe RED", "FIG BROWN"],
    "variant_size":"L",
    "variant_image": "http://www.khopdi.com/nf0a2vd3_5pl_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A2VD3",
    "product_name": "MEN'S VENTURE 2 JACKET",
    "product_image": "http://www.khopdi.com/nf0a2vd3_5pl_hero",
    "product_base_price": 99,
    "product_description": "lightweight, waterproof and windproof jacket that features a durable yet breathable ripstop exterior, Relaxed Fit and adjustable hood that leaves room for a helmet and extra layer",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Rainwear",
    "product_activity": "hiking",
    "variant_name": "Blue Men's Venture 2 Jacket - Small",
    "variant_id":"7KR-S",
    "variant_price":100,
    "variant_primary_color":"Blue",
    "variant_colors": ["TURKISH SEA|URBAN NAVY", "PERSIAN ORANGE"],
    "variant_size": "S",
    "variant_image": "http://www.khopdi.com/nf0a2vd3_7kr_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A2VD3",
    "product_name": "MEN'S VENTURE 2 JACKET",
    "product_image": "http://www.khopdi.com/nf0a2vd3_5pl_hero",
    "product_base_price": 99,
    "product_description": "lightweight, waterproof and windproof jacket that features a durable yet breathable ripstop exterior, Relaxed Fit and adjustable hood that leaves room for a helmet and extra layer",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Rainwear",
    "product_activity": "hiking",
    "variant_name": "Blue Men's Venture 2 Jacket - Medium",
    "variant_id":"7KR-M",
    "variant_price":100,
    "variant_primary_color":"Blue",
    "variant_colors": ["TURKISH SEA|URBAN NAVY", "PERSIAN ORANGE"],
    "variant_size":"M",
    "variant_image": "http://www.khopdi.com/nf0a2vd3_7kr_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A2VD3",
    "product_name": "MEN'S VENTURE 2 JACKET",
    "product_image": "http://www.khopdi.com/nf0a2vd3_5pl_hero",
    "product_base_price": 99,
    "product_description": "lightweight, waterproof and windproof jacket that features a durable yet breathable ripstop exterior, Relaxed Fit and adjustable hood that leaves room for a helmet and extra layer",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Rainwear",
    "product_activity": "hiking",
    "variant_name": "Blue Men's Venture 2 Jacket - Large",
    "variant_id":"7KR-L",
    "variant_price":100,
    "variant_primary_color":"Blue",
    "variant_colors": ["TURKISH SEA|URBAN NAVY", "pERSIAN ORANGE"],
    "variant_size":"L",
    "variant_image": "http://www.khopdi.com/nf0a2vd3_7kr_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A2VD3",
    "product_name": "MEN'S VENTURE 2 JACKET",
    "product_image": "http://www.khopdi.com/nf0a2vd3_5pl_hero",
    "product_base_price": 99,
    "product_description": "lightweight, waterproof and windproof jacket that features a durable yet breathable ripstop exterior, Relaxed Fit and adjustable hood that leaves room for a helmet and extra layer",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Rainwear",
    "product_activity": "hiking",
    "variant_name": "Yellow Men's Venture 2 Jacket - Small",
    "variant_id":"7KS-S",
    "variant_price":103,
    "variant_primary_color":"Yellow",
    "variant_colors": ["ACID YELLOW", "LEOPARD YELLOW"],
    "variant_size": "S",
    "variant_image": "http://www.khopdi.com/nf0a2vd3_7ks_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A2VD3",
    "product_name": "MEN'S VENTURE 2 JACKET",
    "product_image": "http://www.khopdi.com/nf0a2vd3_5pl_hero",
    "product_base_price": 99,
    "product_description": "lightweight, waterproof and windproof jacket that features a durable yet breathable ripstop exterior, Relaxed Fit and adjustable hood that leaves room for a helmet and extra layer",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Rainwear",
    "product_activity": "hiking",
    "variant_name": "Yellow Men's Venture 2 Jacket - Medium",
    "variant_id":"7KS-M",
    "variant_price":103,
    "variant_primary_color":"Yellow",
    "variant_colors": ["ACID YELLOW", "LEOPARD YELLOW"],
    "variant_size":"M",
    "variant_image": "http://www.khopdi.com/nf0a2vd3_7ks_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A2VD3",
    "product_name": "MEN'S VENTURE 2 JACKET",
    "product_image": "http://www.khopdi.com/nf0a2vd3_5pl_hero",
    "product_base_price": 99,
    "product_description": "lightweight, waterproof and windproof jacket that features a durable yet breathable ripstop exterior, Relaxed Fit and adjustable hood that leaves room for a helmet and extra layer",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Rainwear",
    "product_activity": "hiking",
    "variant_name": "Yellow Men's Venture 2 Jacket - Large",
    "variant_id":"7KS-L",
    "variant_price":103,
    "variant_primary_color":"Yellow",
    "variant_colors": ["ACID YELLOW", "lEOPARD YELLOW"],
    "variant_size":"L",
    "variant_image": "http://www.khopdi.com/nf0a2vd3_7ks_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A3MGO",
    "product_name": "MEN’S DOWN SIERRA 2.0 JACKET",
    "product_IMAGE": "http://www.khopdi.com/nf0a3mgo_h2g_hero",
    "product_base_price":279.00,
    "product_description":"550-fill goose down insulated parka featuring a water-repellent finish, removable hood, and bungee-cord-cinch waist",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Insulated & Down",
    "product_activity":"City",
    "variant_name": "Blue Men's Down Sierra 2.0 Jacket - Small",
    "variant_id":"H2G-S",
    "variant_price":279,
    "variant_primary_color":"Blue",
    "variant_colors": ["URBAN NAVY"],
    "variant_size": "S",
    "variant_image": "http://www.khopdi.com/nf0a3mgo_h2g_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A3MGO",
    "product_name": "MEN’S DOWN SIERRA 2.0 JACKET",
    "product_image": "http://www.khopdi.com/nf0a3mgo_h2g_hero",
    "product_base_price":279.00,
    "product_description":"550-fill goose down insulated parka featuring a water-repellent finish, removable hood, and bungee-cord-cinch waist",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Insulated & Down",
    "product_activity":"City",
    "variant_name": "Blue Men's Down Sierra 2.0 Jacket - Medium",
    "variant_id":"H2G-M",
    "variant_price":279,
    "variant_primary_color":"Blue",
    "variant_colors": ["URBAN NAVY"],
    "variant_size":"M",
    "variant_image": "http://www.khopdi.com/nf0a3mgo_h2g_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A3MGO",
    "product_name": "MEN’S DOWN SIERRA 2.0 JACKET",
    "product_image": "http://www.khopdi.com/nf0a3mgo_h2g_hero",
    "product_base_price":279.00,
    "product_description":"550-fill goose down insulated parka featuring a water-repellent finish, removable hood, and bungee-cord-cinch waist",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Insulated & Down",
    "product_activity":"City",
    "variant_name": "Blue Men's Down Sierra 2.0 Jacket - Large",
    "variant_id":"H2G-L",
    "variant_price":279,
    "variant_primary_color":"Blue",
    "variant_colors": ["URBAN NAVY"],
    "variant_size":"L",
    "variant_image": "http://www.khopdi.com/nf0a3mgo_h2g_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A3MGO",
    "product_name": "MEN’S DOWN SIERRA 2.0 JACKET",
    "product_image": "http://www.khopdi.com/nf0a3mgo_h2g_hero",
    "product_base_price":279.00,
    "product_description":"550-fill goose down insulated parka featuring a water-repellent finish, removable hood, and bungee-cord-cinch waist",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Insulated & Down",
    "product_activity":"City",
    "variant_name": "Red Men's Down Sierra 2.0 Jacket - Small",
    "variant_id":"2V5-S",
    "variant_price":279,
    "variant_primary_color":"Red",
    "variant_colors": ["CALDERA RED"],
    "variant_size": "S",
    "variant_image": "http://www.khopdi.com/nf0a3mgo_2v5_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A3MGO",
    "product_name": "MEN’S DOWN SIERRA 2.0 JACKET",
    "product_image": "http://www.khopdi.com/nf0a3mgo_h2g_hero",
    "product_base_price":279.00,
    "product_description":"550-fill goose down insulated parka featuring a water-repellent finish, removable hood, and bungee-cord-cinch waist",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Insulated & Down",
    "product_activity":"City",
    "variant_name": "Red Men's Down Sierra 2.0 Jacket - Medium",
    "variant_id":"2V5-M",
    "variant_price":279,
    "variant_primary_color":"Red",
    "variant_colors": ["CALDERA RED"],
    "variant_size":"M",
    "variant_image": "http://www.khopdi.com/nf0a3mgo_2v5_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A3MGO",
    "product_name": "MEN’S DOWN SIERRA 2.0 JACKET",
    "product_image": "http://www.khopdi.com/nf0a3mgo_h2g_hero",
    "product_base_price":279.00,
    "product_description":"550-fill goose down insulated parka featuring a water-repellent finish, removable hood, and bungee-cord-cinch waist",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Insulated & Down",
    "product_activity":"City",
    "variant_name": "Red Men's Down Sierra 2.0 Jacket - Large",
    "variant_id":"2V5-L",
    "variant_price":279,
    "variant_primary_color":"Red",
    "variant_COLOR":"CALDERA RED",
    "variant_size":"L",
    "variant_image": "http://www.khopdi.com/nf0a3mgo_2v5_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A3MGO",
    "product_name": "MEN’S DOWN SIERRA 2.0 JACKET",
    "product_image": "http://www.khopdi.com/nf0a3mgo_h2g_hero",
    "product_base_price":279.00,
    "product_description":"550-fill goose down insulated parka featuring a water-repellent finish, removable hood, and bungee-cord-cinch waist",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Insulated & Down",
    "product_activity":"City",
    "variant_name": "Black Men's Down Sierra 2.0 Jacket - Small",
    "variant_id":"ZLY-S",
    "variant_price":279,
    "variant_primary_color":"Black",
    "variant_colors": ["WEATHERED BLACK"],
    "variant_size": "S",
    "variant_image": "http://www.khopdi.com/nf0a3mgo_zly_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A3MGO",
    "product_name": "MEN’S DOWN SIERRA 2.0 JACKET",
    "product_image": "http://www.khopdi.com/nf0a3mgo_h2g_hero",
    "product_base_price":279.00,
    "product_description":"550-fill goose down insulated parka featuring a water-repellent finish, removable hood, and bungee-cord-cinch waist",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Insulated & Down",
    "product_activity":"City",
    "variant_name": "Black Men's Down Sierra 2.0 Jacket - Medium",
    "variant_id":"ZLY-M",
    "variant_price":279,
    "variant_primary_color":"Black",
    "variant_colors": ["WEATHERED BLACK"],
    "variant_size":"M",
    "variant_image": "http://www.khopdi.com/nf0a3mgo_zly_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A3MGO",
    "product_name": "MEN’S DOWN SIERRA 2.0 JACKET",
    "product_image": "http://www.khopdi.com/nf0a3mgo_h2g_hero",
    "product_base_price":279.00,
    "product_description":"550-fill goose down insulated parka featuring a water-repellent finish, removable hood, and bungee-cord-cinch waist",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Insulated & Down",
    "product_activity":"City",
    "variant_name": "Black Men's Down Sierra 2.0 Jacket - Large",
    "variant_id":"ZLY-L",
    "variant_price":279,
    "variant_primary_color":"Black",
    "variant_colors": ["wEATHERED BLACK"],
    "variant_size":"L",
    "variant_image": "http://www.khopdi.com/nf0a3mgo_zly_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A33QV",
    "product_name": "MEN'S CAMPSHIRE PULLOVER HOODIE",
    "product_image": "http://www.khopdi.com/nf0a33qv_hk9_hero",
    "product_base_price": 149,
    "product_description": "Stay warmer while soaking up camp vibes in this heavyweight pullover hoodie that’s crafted of warm Sherpa fleece.",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Fleece",
    "product_activity": "hiking",
    "variant_name": "Red Men's Campshire Pullover Hoodie - Small",
    "variant_id":"HK9-S",
    "variant_price":149,
    "variant_primary_color":"Red",
    "variant_colors": ["CALDERA RED", "ASPHALT GREY"],
    "variant_size": "S",
    "variant_image": "http://www.khopdi.com/nf0a33qv_hk9_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A33QV",
    "product_name": "MEN'S CAMPSHIRE PULLOVER HOODIE",
    "product_image": "http://www.khopdi.com/nf0a33qv_hk9_hero",
    "product_base_price": 149,
    "product_description": "Stay warmer while soaking up camp vibes in this heavyweight pullover hoodie that’s crafted of warm Sherpa fleece.",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Fleece",
    "product_activity": "hiking",
    "variant_name": "Red Men's Campshire Pullover Hoodie - Medium",
    "variant_id":"HK9-M",
    "variant_price":149,
    "variant_primary_color":"Red",
    "variant_colors": ["CALDERA RED", "ASPHALT GREY"],
    "variant_size":"M",
    "variant_image": "http://www.khopdi.com/nf0a33qv_hk9_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A33QV",
    "product_name": "MEN'S CAMPSHIRE PULLOVER HOODIE",
    "product_image": "http://www.khopdi.com/nf0a33qv_hk9_hero",
    "product_base_price": 149,
    "product_description": "Stay warmer while soaking up camp vibes in this heavyweight pullover hoodie that’s crafted of warm Sherpa fleece.",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Fleece",
    "product_activity": "hiking",
    "variant_name": "Red Men's Campshire Pullover Hoodie - Large",
    "variant_id":"HK9-L",
    "variant_price":149,
    "variant_primary_color":"Red",
    "variant_colors": ["CALDERA Red", "ASPHALT GREY"],
    "variant_size":"L",
    "variant_image": "http://www.khopdi.com/nf0a33qv_hk9_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A33QV",
    "product_name": "MEN'S CAMPSHIRE PULLOVER HOODIE",
    "product_image": "http://www.khopdi.com/nf0a33qv_hk9_hero",
    "product_base_price": 149,
    "product_description": "Stay warmer while soaking up camp vibes in this heavyweight pullover hoodie that’s crafted of warm Sherpa fleece.",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Fleece",
    "product_activity": "hiking",
    "variant_naMe": "blue men's caMpshire PUllover Hoodie - Small",
    "variant_id":"8YR-S",
    "variant_price":149,
    "variant_primary_color":"Blue",
    "variant_colors": ["URBAN NAVY", "CALDERA RED"],
    "variant_size": "S",
    "variant_image": "http://www.khopdi.com/nf0a33qv_8yr_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A33QV",
    "product_name": "MEN'S CAMPSHIRE PULLOVER HOODIE",
    "product_image": "http://www.khopdi.com/nf0a33qv_hk9_hero",
    "product_base_price": 149,
    "product_description": "Stay warmer while soaking up camp vibes in this heavyweight pullover hoodie that’s crafted of warm Sherpa fleece.",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Fleece",
    "product_activity": "hiking",
    "variant_naMe": "blue men's caMpshire PUllover Hoodie - Medium",
    "variant_id":"8YR-M",
    "variant_price":149,
    "variant_primary_color":"Blue",
    "variant_colors": ["URBAN NAVY", "CALDERA RED"],
    "variant_size":"M",
    "variant_image": "http://www.khopdi.com/nf0a33qv_8yr_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A33QV",
    "product_name": "MEN'S CAMPSHIRE PULLOVER HOODIE",
    "product_image": "http://www.khopdi.com/nf0a33qv_hk9_hero",
    "product_base_price": 149,
    "product_description": "Stay warmer while soaking up camp vibes in this heavyweight pullover hoodie that’s crafted of warm Sherpa fleece.",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Fleece",
    "product_activity": "hiking",
    "variant_naMe": "blue men's caMpshire PUllover Hoodie - Large",
    "variant_id":"8YR-L",
    "variant_price":149,
    "variant_primary_color":"Blue",
    "variant_colors": ["URBAN NAVY", "CALDERA RED"],
    "variant_size":"L",
    "variant_image": "http://www.khopdi.com/nf0a33qv_8yr_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A33QV",
    "product_name": "MEN'S CAMPSHIRE PULLOVER HOODIE",
    "product_image": "http://www.khopdi.com/nf0a33qv_hk9_hero",
    "product_base_price": 149,
    "product_description": "Stay warmer while soaking up camp vibes in this heavyweight pullover hoodie that’s crafted of warm Sherpa fleece.",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Fleece",
    "product_activity": "hiking",
    "variant_name": "Black Men's Campshire Pullover Hoodie - Small",
    "variant_id":"6HJ-S",
    "variant_price":149,
    "variant_primary_color":"Black",
    "variant_colors": ["WEATHERED BLACK", "CARGO KHAKI"],
    "variant_size": "S",
    "variant_image": "http://www.khopdi.com/nf0a33qv_6hj_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A33QV",
    "product_name": "MEN'S CAMPSHIRE PULLOVER HOODIE",
    "product_image": "http://www.khopdi.com/nf0a33qv_hk9_hero",
    "product_base_price": 149,
    "product_description": "Stay warmer while soaking up camp vibes in this heavyweight pullover hoodie that’s crafted of warm Sherpa fleece.",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Fleece",
    "product_activity": "hiking",
    "variant_name": "Black Men's Campshire Pullover Hoodie - Medium",
    "variant_id":"6HJ-M",
    "variant_price":149,
    "variant_primary_color":"Black",
    "variant_colors": ["WEATHERED BLACK", "CARGO KHAKI"],
    "variant_size":"M",
    "variant_image": "http://www.khopdi.com/nf0a33qv_6hj_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A33QV",
    "product_name": "MEN'S CAMPSHIRE PULLOVER HOODIE",
    "product_image": "http://www.khopdi.com/nf0a33qv_hk9_hero",
    "product_base_price": 149,
    "product_description": "Stay warmer while soaking up camp vibes in this heavyweight pullover hoodie that’s crafted of warm Sherpa fleece.",
    "product_brand":"The North Face",
    "product_category": "Men's|Jackets & Vests|Fleece",
    "product_activity": "hiking",
    "variant_name": "Black Men's Campshire Pullover Hoodie - Large",
    "variant_id":"6HJ-L",
    "variant_price":149,
    "variant_primary_color":"Black",
    "variant_colors": ["WEATHERED BLacK", "CARGO KHAKI"],
    "variant_size":"L",
    "variant_image": "http://www.khopdi.com/nf0a33qv_6hj_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A2TCT",
    "product_name": "MEN’S MOTION PANTS",
    "product_image": "http://www.khopdi.com/nf0a2tct_t5c_hero",
    "product_base_price":75,
    "product_description": "Designed to maximize your mobility, these midweight pants are crafted with durable Sorona®  triexta yarns.",
    "product_brand":"The North Face",
    "product_category": "Men's|Bottoms|Casual & Hike",
    "product_activity": "hiking",
    "variant_name": "Grey Men's Motion Pants - Small",
    "variant_id":"0C5-S",
    "variant_price":75,
    "variant_primary_color": "Grey",
    "variant_colors": ["ASPHALT GREY"],
    "variant_size": "S",
    "variant_image": "http://www.khopdi.com/nf0a2tct_0c5_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A2TCT",
    "product_name": "MEN’S MOTION PANTS",
    "product_image": "http://www.khopdi.com/nf0a2tct_t5c_hero",
    "product_base_price":75,
    "product_description": "Designed to maximize your mobility, these midweight pants are crafted with durable Sorona®  triexta yarns.",
    "product_brand":"The North Face",
    "product_category": "Men's|Bottoms|Casual & Hike",
    "product_activity": "hiking",
    "variant_name": "Grey Men's Motion Pants - Medium",
    "variant_id":"0C5-M",
    "variant_price":75,
    "variant_primary_color": "Grey",
    "variant_colors": ["ASPHALT GREY"],
    "variant_size":"M",
    "variant_image": "http://www.khopdi.com/nf0a2tct_0c5_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A2TCT",
    "product_name": "MEN’S MOTION PANTS",
    "product_image": "http://www.khopdi.com/nf0a2tct_t5c_hero",
    "product_base_price":75,
    "product_description": "Designed to maximize your mobility, these midweight pants are crafted with durable Sorona®  triexta yarns.",
    "product_brand":"The North Face",
    "product_category": "Men's|Bottoms|Casual & Hike",
    "product_activity": "hiking",
    "variant_name": "Grey Men's Motion Pants - Large",
    "variant_id":"0C5-L",
    "variant_price":75,
    "variant_primary_color": "Grey",
    "variant_colors": ["ASPHALT GREY"],
    "variant_size":"L",
    "variant_image": "http://www.khopdi.com/nf0a2tct_0c5_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A2TCT",
    "product_name": "MEN’S MOTION PANTS",
    "product_image": "http://www.khopdi.com/nf0a2tct_t5c_hero",
    "product_base_price":75,
    "product_description": "Designed to maximize your mobility, these midweight pants are crafted with durable Sorona®  triexta yarns.",
    "product_brand":"The North Face",
    "product_category": "Men's|Bottoms|Casual & Hike",
    "product_activity": "hiking",
    "variant_name": "Khaki Men's Motion Pants - Small",
    "variant_id":"T5C-S",
    "variant_price":75,
    "variant_primary_color": "Brown",
    "variant_colors": ["CARGO KHAKI"],
    "variant_size": "S",
    "variant_image": "http://www.khopdi.com/nf0a2tct_t5c_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A2TCT",
    "product_name": "MEN’S MOTION PANTS",
    "product_image": "http://www.khopdi.com/nf0a2tct_t5c_hero",
    "product_base_price":75,
    "product_description": "Designed to maximize your mobility, these midweight pants are crafted with durable Sorona®  triexta yarns.",
    "product_brand":"The North Face",
    "product_category": "Men's|Bottoms|Casual & Hike",
    "product_activity": "hiking",
    "variant_name": "Khaki Men's Motion Pants - Medium",
    "variant_id":"T5C-M",
    "variant_price":75,
    "variant_primary_color": "Brown",
    "variant_colors": ["CARGO KHAKI"],
    "variant_size":"M",
    "variant_image": "http://www.khopdi.com/nf0a2tct_t5c_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A2TCT",
    "product_name": "MEN’S MOTION PANTS",
    "product_image": "http://www.khopdi.com/nf0a2tct_t5c_hero",
    "product_base_price":75,
    "product_description": "Designed to maximize your mobility, these midweight pants are crafted with durable Sorona®  triexta yarns.",
    "product_brand":"The North Face",
    "product_category": "Men's|Bottoms|Casual & Hike",
    "product_activity": "hiking",
    "variant_name": "Khaki Men's Motion Pants - Large",
    "variant_id":"T5C-L",
    "variant_price":75,
    "variant_primary_color": "Brown",
    "variant_colors": ["CARGO KHAKI"],
    "variant_size":"L",
    "variant_image": "http://www.khopdi.com/nf0a2tct_t5c_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A2TCT",
    "product_name": "MEN’S MOTION PANTS",
    "product_image": "http://www.khopdi.com/nf0a2tct_t5c_hero",
    "product_base_price":75,
    "product_description": "Designed to maximize your mobility, these midweight pants are crafted with durable Sorona®  triexta yarns.",
    "product_brand":"The North Face",
    "product_category": "Men's|Bottoms|Casual & Hike",
    "product_activity": "hiking",
    "variant_name": "Clover Men's Motion Pants - Small",
    "variant_id":"3NF-S",
    "variant_price":75,
    "variant_primary_color": "Green",
    "variant_colors": ["FOUR LEAF CLOVER"],
    "variant_size": "S",
    "variant_image": "http://www.khopdi.com/nf0a2tct_3nf_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A2TCT",
    "product_name": "MEN’S MOTION PANTS",
    "product_image": "http://www.khopdi.com/nf0a2tct_t5c_hero",
    "product_base_price":75,
    "product_description": "Designed to maximize your mobility, these midweight pants are crafted with durable Sorona®  triexta yarns.",
    "product_brand":"The North Face",
    "product_category": "Men's|Bottoms|Casual & Hike",
    "product_activity": "hiking",
    "variant_name": "Clover Men's Motion Pants - Medium",
    "variant_id":"3NF-M",
    "variant_price":75,
    "variant_primary_color": "Green",
    "variant_colors": ["FOUR LEAF CLOVER"],
    "variant_size":"M",
    "variant_image": "http://www.khopdi.com/nf0a2tct_3nf_hero"
}


POST /productitems/_doc
{
    "product_id": "NF0A2TCT",
    "product_name": "MEN’S MOTION PANTS",
    "product_image": "http://www.khopdi.com/nf0a2tct_t5c_hero",
    "product_base_price":75,
    "product_description": "Designed to maximize your mobility, these midweight pants are crafted with durable Sorona®  triexta yarns.",
    "product_brand":"The North Face",
    "product_category": "Men's|Bottoms|Casual & Hike",
    "product_activity": "hiking",
    "variant_name": "Clover Men's Motion Pants - Large",
    "variant_id":"3NF-L",
    "variant_price":75,
    "variant_primary_color": "Green",
    "variant_colors": ["FOUR LEAF CLOVER"],
    "variant_size":"L",
    "variant_image": "http://www.khopdi.com/nf0a2tct_3nf_hero"
}

Sample Search
We’ll run a test search just to make sure elasticsearch has our data and is able to return it. We can just use the _search endpoint without any parameters to return all the items in the index. In this case we should get back a total of 36 hits.

1
GET /productitems/_search

Slightly more involved query that searches for Red Jacket in the variant_name and variant_primary_color fields

1
2
3
4
5
6
7
8
9
10
GET /productitems/_search
{
  "query":{
      "multi_match":{
          "query": "Jacket",
          "type" : "best_fields",
          "fields": ["variant_name", "variant_primary_color"]
    }
  }
}

The above query uses the multi_match operator which builds on the match query to allow multi-field queries. The results are all variants as expected since that’s what we indexed but this is not what we should be showing the end user. We need to only have one record per product. So all the Red-L, Red-M, Red-S, Blue-S…etc. items need to be collapsed as a single product entry. Elasticsearch has a way to do this using the collapse operator. See the modified query below to see it in action.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
GET /productitems/_search
{
  "query":{
    "bool":{
      "must":{
        "multi_match":{
          "query": "Jacket",
          "type" : "best_fields",
          "fields": ["variant_name", "variant_primary_color"]
        }
      }
    }
  },
  "collapse":{
    "field" : "product_id.keyword"
  }
}

Results: Observe that the hits are now collapsed and only have one entry per product_id.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 18,
    "max_score": 0.60858977,
    "hits": [
      {
        "_index": "productitems",
        "_type": "_doc",
        "_id": "Y6IlmmYBoxRprfxd0bkf",
        "_score": 0.60858977,
        "_source": {
          "product_id": "NF0A2VD3",
          "product_name": "MEN'S VENTURE 2 JACKET",
          "product_image": "http://www.khopdi.com/nf0a2vd3_5pl_hero",
          "product_base_price": 99,
          "product_description": "lightweight, waterproof and windproof jacket that features a durable yet breathable ripstop exterior, Relaxed Fit and adjustable hood that leaves room for a helmet and extra layer",
          "product_brand": "The North Face",
          "product_category": "Men's|Jackets & Vests|Rainwear",
          "product_activity": "hiking",
          "variant_name": "Red Men's Venture 2 Jacket - Small",
          "variant_id": "5PLR-S",
          "variant_price": 99,
          "variant_primary_color": "Red",
          "variant_colors": [
            "RAGE RED",
            "FIG BROWN"
          ],
          "variant_size": "S",
          "variant_image": "http://www.khopdi.com/nf0a2vd3_5pl_hero"
        },
        "fields": {
          "product_id.keyword": [
            "NF0A2VD3"
          ]
        }
      },
      {
        "_index": "productitems",
        "_type": "_doc",
        "_id": "bKIlmmYBoxRprfxd0rnw",
        "_score": 0.56974363,
        "_source": {
          "product_id": "NF0A3MGO",
          "product_name": "MEN’S DOWN SIERRA 2.0 JACKET",
          "product_IMAGE": "http://www.khopdi.com/nf0a3mgo_h2g_hero",
          "product_base_price": 279,
          "product_description": "550-fill goose down insulated parka featuring a water-repellent finish, removable hood, and bungee-cord-cinch waist",
          "product_brand": "The North Face",
          "product_category": "Men's|Jackets & Vests|Insulated & Down",
          "product_activity": "City",
          "variant_name": "Blue Men's Down Sierra 2.0 Jacket - Small",
          "variant_id": "H2G-S",
          "variant_price": 279,
          "variant_primary_color": "Blue",
          "variant_colors": [
            "URBAN NAVY"
          ],
          "variant_size": "S",
          "variant_image": "http://www.khopdi.com/nf0a3mgo_h2g_hero"
        },
        "fields": {
          "product_id.keyword": [
            "NF0A3MGO"
          ]
        }
      }
    ]
  }
}

In the next post in this series we’ll improve on our query to add aggregation and filtering by facets.

Sitecore Commerce: Elasticsearch driven Faceted Search/Navigation for eCommerce – Part 1

This will be a series of posts on how to make Elasticsearch work with Sitecore in an eCommerce scenario. Elasticsearch is a great search engine but some work needs to be done to configure it to the specific use case of an eCommerce Faceted Search/Navigation scenario. In this first post we’ll be focusing on installing the Elasticsearch instance. In the following posts we’ll be defining the data mapping, inserting some test data and building a query suitable for Faceted Search/Guided Navigation and finally making Sitecore talk to Elasticsearch.

Faceted Search/Navigation, also known as Guided Navigation is a technique which extends the traditional full-text search with a faceted navigation system. It allows the users to refine or narrow down the product search result set using filters based on faceted classification of the product records. The search and navigation user interface is built such that each incremental filtration restricts the filters further and narrows down the results quickly. The user is also shown the count of products in each of the available facet constraints. For example, if the user is searching for a T-Shirts and the T-shirts come in Red, Green, and Blue color. Here Color would be the dimension and the values (Red, Green and Blue) would be facet constraints and the user would be shown how many of the Red (20), Green (12), Blue (10) products are available. Any constraints with 0 items available would be excluded from the UI as it would lead to a zero results page.

The products have dimensions or facets defined on them such as Brand, Color, Size, Categories, Physical Dimensions, Price, etc. A faceted search system classifies each Product along multiple explicit dimensions/facets which enables the search results to be accessed and ordered in multiple ways rather than in a single, pre-determined, taxonomic order. Increasing number of modern eCommerce sites now use the faceted search/navigation pattern and it has become a well understood eCommerce user experience but proper care must be taken during information architecture design of the site to support Faceted Search.

Here is a screenshot from northface.com as an example that uses faceted navigation. The products on the northface site have category, color, size, price, and activity as facets. See the annotations on the screenshots for the facets and the constraints UI as well as the commonly used item count feature. The UI also allows sorting by Relevance, Price, Rating, etc. Also note that the display images for the search results reflect the color facet constraint (Red and Orange). We are going to need to index the product data in a certain way to be able to support this.


Installing Elasticsearch 6.4.2 (windows command line way)

Install Java
The specific version of elasticsearch we will be installing need version 9. Download and install java from http://download.oracle.com/otn/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/jre-9.0.4_windows-x64_bin.exe. Oracle will annoyingly make you signup and login to be able to download this.

Install Elasticsearch

  • Download the latest elasticsearch version (6.4.2 as of this writing) from https://www.elastic.co/downloads/elasticsearch
  • Unblock, Extract and Copy the downloaded files to c:\elasticsearch-6.4.2
  • Run the elasticsearch batch file from C:\elasticsearch-6.4.2\bin>elasticsearch.bat
  • Check if elasticsearch responds on port 9200 http://localhost:9200/

Install Kibana
We’ll be using the DevTools from Kibana to interact with the elasticsearch instance.

  • Download from https://www.elastic.co/downloads/kibana
  • Unblock, Extract and Copy the downloaded files to C:\kibana-6.4.2-windows-x86_64
  • This will take longer to download and extract kibana as it’s a larger download and has lot more files.
  • C:\kibana-6.4.2-windows-x86_64\bin>kibana.bat
  • Check if Kibana Responds at http://localhost:5601

Testing the Installtion

  • Open kibana from http://localhost:5601 and go to the DevTools sections
  • In the left hand pane of the Console area Type “GET /” and hit the green play button to run the query.
  • You should see the elasticsearch cluster information returned in the right hand pane.

In the next post we’ll create the index, define the Data Mapping, load some test data and construct a query suitable for our needs.