Full-text search for local/offline web “site” [dup

2020-07-18 03:31发布

问题:

This question already has answers here:
Closed 7 years ago.

Possible Duplicate:
Full-text search for static HTML files on CD-Rom via javascript

I'm starting development of an application that creates a bunch of HTML files locally that can then be browsed in whatever web browser is on the system (including mobile devices) to which they're copied. The HTML files have many interactive features, so it's essentially an offline web app. My question is, what is the best way to implement full-text search for these HTML files? Basically, the application should index the HTML files it generates, but we want to be able to make the HTML files and the generated index downloadable and available for users to browse and search offline. What is the best way to do this without writing an actual application to manage it? For example, I've implemented it using Solr for a demo/proof-of-concept and that works fine ... but of course that requires HTTP POST and GET requests to a server for indexing and querying. So since the indexes are really just files, I'm wondering if there's a way to query them offline (and without firing up a local web server for Solr) using just Javascript in the HTML files, maybe with Lucene instead of Solr?

回答1:

Thanks for introducing me to a few text search solutions written entirely in Javascript! I wanted to check out code for text search.

  • http://karussell.wordpress.com/2010/11/01/full-text-search-in-100-javascript-the-future-of-javascript-is-bright/

  • http://dev.theladders.com/archives/2006/11/introducing_javascript_fulltex_1.html


Lucene is written in Java and it needs a Java (technically a JVM) process to access.

PS1: If you are rolling your own simple text search, a stemmer in JS will make it more useful.

original: run running cat cats love loving crap crapping
stemmed: run run cat cat love love crap crap 

PS2: You can run another "Ngram-ized" index for spell checking too.