user1785360
user1785360

Reputation:

JavaScript client-side 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?

Upvotes: 6

Views: 5199

Answers (7)

Gurgolo
Gurgolo

Reputation: 332

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.

Upvotes: 0

Jeremy Lynch
Jeremy Lynch

Reputation: 7210

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.

Upvotes: 3

Espen Klem
Espen Klem

Reputation: 331

I think you have two options. Lunr that is mentioned earlier and search-index.

Upvotes: 1

Tvaroh
Tvaroh

Reputation: 6763

Try lunr.js which supports full-text search in JavaScript.

Upvotes: 6

Valeriane
Valeriane

Reputation: 954

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)

Upvotes: 1

qSirassi
qSirassi

Reputation: 61

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.

Upvotes: 1

mtmacdonald
mtmacdonald

Reputation: 15070

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.

Upvotes: 2

Related Questions