[ANN] ocaml-search 0.1.1 - In-memory Search Index for OCaml values

I’m happy to announce the release of a little OCaml library for doing in-memory searches over OCaml values: ocaml-search.

Here’s a quick example:

module Book = struct
  type t = {
    title : string;
    author : string;

let books : Book.t list =
    { title = "Dune"; author = "Frank Herbet" };
    { title = "The Day of the Triffids"; author = "John Wyndham" };
    { title = "The Remains of the Day"; author = "Kazuo Ishiguro" }

module Mono = Search.Tfidf.Mono (Search.Uids.String) (Book)
let search = Mono.empty ()

You can then add an index to your search index along with the documents.

Mono.add_index search (fun t -> t.title);
List.iter (fun doc -> Mono.add_document search doc.Book.title doc) books

Before finally being able to search.

Mono.search search "day";;
- : Mono.doc list =
[{Book.title = "The Remains of the Day"; author = "Kazuo Ishiguro"};
 {Book.title = "The Day of the Triffids"; author = "John Wyndham"}]

The README provides more thorough documentation and also explains how it can also provide a heterogeneous search index should you want it. I have plans to make the library more easily extendible with your own search strategies, but thought the initial TF-IDF implementation might already be useful.

This library is heavily inspired by js-search without which it wouldn’t exist.

Happy Hacking :camel: