Skip to content

Fast and fuzzy search (tf-idf) for HTML and other native-text assets.

Notifications You must be signed in to change notification settings

t-ski/website-search

Repository files navigation

Website Search

Fast and simple website search (TF-IDF). For HTML and native-text assets.

npm i t-ski/website-search

Indexing

const index = new Index(path: string, options: {
  minTokenLength: 3,
  punctuationChars: [
    ".", ",", ":", ";", "!", "?", '"', "'", "(", ")", "{", "}", "[", "]"
  ],
  relevantFileExtensions: [ "html", "htm", "txt" ]
})
index.index()

Querying

const query = new Query(index: Index, options: {
  maxResults: 5,
  maxTokenDistance: 2,
  maxTokens: 30,
  scoreThreshold: 0.15
})
query.results()
query.time()

Example

new Index("./http")
.index()
.then(index => {
  const query = (search: string) = {
    const query = new Query(index, search);
    
    console.log(`Query: '${search}'`);

    console.log(query.results());

    console.log(`Duration: '${query.time()}'`);
  };
});

© Thassilo Martin Schiepanski

About

Fast and fuzzy search (tf-idf) for HTML and other native-text assets.

Topics

Resources

Stars

Watchers

Forks