Introduction

# Whot is 'Thoth'

`Thoth` is simple full-text search on Deno KV.

It serves as a wrapper for Deno KV that builds the key information used in n-gram search.

# Install

1. Install Deno

First, install deno cli.

Please refer to the official document.

2. Run

Write the following script.

// main.ts
import { createThothClient } from "jsr:@octo/thoth";

const kv = await Deno.openKv();
const thoth = createThothClient(kv, 3);

await thoth.register(["ABCDEFG", "abcdefg"], "000001");
await thoth.register(["あいうえお", "aiueo"], "000002");
await thoth.register(["ABCDEFGABCDEFG", "abcdefgabcdefg"], "000003");

console.log(await thoth.search("ABC"));
// => { "000001": { "0": [ 0 ] } }

console.log(await thoth.search("AC"));
// => {}

console.log(await thoth.search("ef"));
// => { "000001": { "1": [ 4 ] }, "000003": { "1": [ 4, 11 ] } }

Please execute the following command.

$ deno run --unstable-kv main.ts
{ "000001": { "0": [ 0 ] }, "000003": { "0": [ 0, 7 ] } }
{}
{ "000001": { "1": [ 4 ] }, "000003": { "1": [ 4, 11 ] } }