-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnode-example.js
61 lines (53 loc) · 1.85 KB
/
node-example.js
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
// ****************************************************************************************************
// Init
// ****************************************************************************************************
var Facetor = require("./index.js");
var catalogFacetor = new Facetor({ separator: "|" });
// ****************************************************************************************************
// Build Index
// ****************************************************************************************************
catalogFacetor.buildIndex({
facets: ["style", "category"],
items: [
{
title: "Rural Apple",
style: "rural",
category: "apples"
},
{
title: "Urban Apple",
style: "urban",
category: "apples"
},
{
title: "Rural Orange",
style: "rural",
category: "oranges"
},
{
title: "Urban Orange",
style: "urban",
category: "oranges"
},
{
title: "A mega rural urban apple orange hybrid",
style: ["rural", "urban"],
category: ["apple", "oranges"]
}
]
});
// ****************************************************************************************************
// Import / Export Index
// ****************************************************************************************************
var index = catalogFacetor.exportIndex();
catalogFacetor.importIndex(index);
// ****************************************************************************************************
// Build Results
// ****************************************************************************************************
// get result
var result = catalogFacetor.buildResult({
facets: ["style|rural", "category|oranges"],
attributes: ["path", "bitmap", "count", "increment", "status"]
});
// log results with tab spacing
console.log(JSON.stringify(result, null, "\t"));