Search issues

I have a four tusands (4000) product list
while i try to search its take some time to load
first time its working file but when i clear the search box and put another text on that time taking some time to load search list

Based on the data you shared here

I have made a small algorithm that works if you search with words to search for products.

var data = your shared json in the mentioned link.

var map = {};

for(var i=0;i<data['list'].length;++i){
   var words = data['list'][i]['product_name'].trim().split(" ");
   for(var j=0;j<words.length;++j){
       if(map[words[j]] === undefined){
          map[words[j]] = [];

var search = 'Patanjali Homogenised Flavour';
var search_words = search.split(" ");
var results = [];

for(var i=0;i<search_words.length;++i){
  if(map[search_words[i]] !== undefined){
   	results = results.concat(map[search_words[i]]);