You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constlunr=require('lunr');constItemsJS=require('itemsjs');constdata=[{id: 1,title: 'Moby Dick',text: 'Call me Ishmael. Some years ago...',category: 'fiction'},{id: 2,title: 'Zen and the Art of Motorcycle Maintenance',text: 'I can see by my watch...',category: 'fiction'},{id: 3,title: 'Neuromancer',text: 'The sky above the port was...',category: 'fiction'},{id: 4,title: 'Zen and the Art of Archery',text: 'At first sight it must seem...',category: 'non-fiction'}];// configuration for itemsjs faceted searchconstconfiguration={native_search_enabled: false,custom_id_field: 'id',// 'id' is a default one but we can also use 'uuid' and other if necessaryaggregations: {category: {title: 'Categories',size: 10,conjunction: true}}}// indexing lunr with dataconstidx=lunr(function(){this.ref('id');this.field('title');this.field('text');this.field('category');data.forEach(v=>{this.add(v);});});// indexing data into itemsjsconstitemsjs=ItemsJS(data,configuration);// searchingconstsearch_result=idx.search('sky');console.log(search_result);constresult=itemsjs.search({per_page: 3,// important! providing ids from full text searchids: search_result.map(v=>v.ref),filters: {category: ['fiction'],}});console.log(result);//console.log(result.data.items);//console.log(result.data.aggregations.category);