javascripthtmlbrowserfull-text-searchfuse.js

How to implement fulltext search for offline website


I need a client-side fulltext search for big offline website. The site is opened by browser. I've made a research and found some solutions - fullproof, fuse.js, flexsearch.js, elasticlunr.js. I searched for js libs, because as i inderstand, it's the single solution (please correct me if i'm wrong).

Also i can't clearly understand some moments:

  1. As i know, browsers due to security policy block all scripts' execution from javascripts files. I couldn't run examples from fullproof git because of this problem, but i managed to run flexsearch example, because script execution was included in html code with tag. Can i implement some search system for my local website because i don't use any local server for hosting (like xampp)?
  2. From documentation for different js libs i undestand, that all they use for indexing either variable with list of key words or json file. Maybe i have a luck of information, but how i can use search system to find words/expressions from the whole website (it has a main page and a lot of included pages with information)? Do i have to create some sort of database or some json file?

I'll be very grateful for your answers, explanations, solutions or maybe examples about this problem, thank you!


Solution

  • First of all, browsers doesn't block js scripts execution. Secondly, i managed to find two ways to solve my problem - keywords search and fulltext search: 1) I created a database with keywords (json file) and used flexsearch library to search in this database. Example of usage u can find on their website, either an example of json file. 2) This time i created a database (json file), in which one recording is a text content of a website. Then again i used flexsearch to find a word in this database. After appropriate site was found, it opened up and the searched word was highlighted (u can find such js libraries in net). All the solutions don't require any internet connection and can be used for offline websites.