Full Text Javascript Search

How would you implement a full-text poor person search in Javascript?

I implement a static web page without a database backend, and the page loads several thousand records of short text strings through an Ajax JSON load. I would like the user to be able to filter these strings effectively with keyword searches, ideally with something smarter than just iterating over each row and executing Javascript .indexOf() .

I was thinking of making my JSON hidden HTML and using the JQuery DOM search plugin, but I doubt it will be faster than repeating my JSON list.

+6
source share
1 answer

several thousand records

This is not the case, see Full-text search in JavaScript with a full-text search demonstration in 40k lines.

.indexOf ()

JavaScript is a bit limited when it comes to text manipulation, but it will do the job.

Here is a pretty simple guide that is perfect for your question. Jekyll + lunr.js = Static websites with powerful full-text search using JavaScript

I have experience creating static web pages with less data and, as a rule, performance is the last problem on the way.

+5
source

All Articles