I am developing a local web application with jQuery/JavaScript.
My goal is to create search engine for searching content from a JSON file. I already made it with regex, but it works slowly.
What is the best way? Is there a JavaScript search engine?
I am developing a local web application with jQuery/JavaScript.
My goal is to create search engine for searching content from a JSON file. I already made it with regex, but it works slowly.
What is the best way? Is there a JavaScript search engine?
Share Improve this question edited Oct 30, 2012 at 11:33 Quentin 944k132 gold badges1.3k silver badges1.4k bronze badges asked Oct 30, 2012 at 11:25 user1785360user1785360 4 |7 Answers
Reset to default 6Try lunr.js which supports full-text search in JavaScript.
Fuse.js is a lightweight fuzzy-search, in JavaScript, with zero dependencies. It has more github stars than Lunr, and has ongoing (and recent) commits as of August 2022.
The term "search engine" normally means that a large set of data is indexed (a resource intensive task). Searching the data set after indexing is then quick. If the data set is very large, it is more likely that indexing and search will be performed on the server (and only the search results are then returned to the browser).
If you just need to search fields in a JSON file that is small or medium in size, then consider JavaScript "search algorithms" rather than search engines.
I think it doesn't exist, you have developpe it
put your application contents in String object and developpe search function with indexOf (for target string) & substring (to extract fragment)
Have a look at fullproof, it's a basic search engine for use int he browser http://reyesr.github.com/fullproof/ There may be others though.
I think you have two options. Lunr that is mentioned earlier and search-index.
Elasticlunr is a lightweight full-text search engine in Javascript for browser search and offline search. Elasticlunr.js is developed based on Lunr.js, but more flexible than lunr.js.
Elasticlunr.js provides Query-Time boosting and field search. Elasticlunr.js is a bit like Solr, but much smaller and not as bright, but also provide flexible configuration and query-time boosting.
RegExp
isn't the right tool for the job... in any case, you say you've already made it: show us how far you've come: post some code, or set up a fiddle – Elias Van Ootegem Commented Oct 30, 2012 at 11:36