A tiny, full-text search engine for static sites built with Rust and WASM

栏目: IT技术 · 发布时间: 5年前

内容简介:This is a lightweight, fast, full-text search engine for static websites. I'm using it on

tinysearch

This is a lightweight, fast, full-text search engine for static websites. I'm using it on my blog :

A tiny, full-text search engine for static sites built with Rust and WASM

It is a Rust/WASM port of the Python code from the article "Writing a full-text search engine using Bloom filters" . This can be seen as an alternative to lunr.js and elasticlunr .

The idea is to generate a small, self-contained WASM module from a list of articles on your website and ship it to browsers. tinysearch can be integrated into the build process of generators like Jekyll , Hugo , zola , or Cobalt .

Limitations

  • Only searches for entire words. There are no search suggestions (yet).
  • Since we bundle all search indices for all articles into one static binary, we recommend to only use it for small- to medium-size websites. Expect around 4kB (non-compressed) per article.

Installation

wasm-pack is required to build the WASM module. Install it with

cargo install wasm-pack

To optimize the JavaScript output, you'll also need terser :

npm install terser -g

If you want to make the WebAssembly as small as possible, we recommend to install binaryen as well. On macOS you can install it with homebrew :

brew install binaryen

Alternatively, you can download the binary from the release page or use your OS package manager.

After that, you can install tinysearch itself:

cargo install tinysearch

Usage

As an input, we require a JSON file, which contains a the content you like to index. Check out this example file ).

tinysearch fixtures/index.json

(You can take a look at the code examples for different static site generators here .)

This will create a WASM module and the JavaScript glue code to integrate it into your homepage. You can open the demo.html from any webserver to see the result.

For example, Python has a built-in webserver for testing:

python -m SimpleHTTPServer

then browse to http://0.0.0.0:8000/demo.html to see the result.

For advanced usage options, try

tinysearch --help

Maintainers

  • Matthias Endler (@mre)
  • Jorge-Luis Betancourt (@jorgelbg)

License

tinysearch is licensed under either of

at your option.


以上所述就是小编给大家介绍的《A tiny, full-text search engine for static sites built with Rust and WASM》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Servlet和JSP学习指南

Servlet和JSP学习指南

Budi Kurniawan / 崔毅、俞哲皆、俞黎敏 / 机械工业出版社华章公司 / 2013-4-14 / 59.00元

本书是系统学习Servlet和JSP的必读之作。由全球知名的Java技术专家(《How Tomcat Works》作者)亲自执笔,不仅全面解读Servlet 和JSP 的最新技术,重点阐述Java Web开发的重要编程概念和设计模型,而且包含大量可操作性极强的案例。 本书共18章:第1章介绍Servlet API和几个简单的Servlet;第2章讨论Session追踪,以及保持状态的4种技术......一起来看看 《Servlet和JSP学习指南》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具