/node-ft

In-memory Full-Text searching for Node.js

Primary LanguageJavaScript

Full-Text Search engine for NodeJS

Node-FT adds basic in-memory Full-Text search capabilities to Node. Supporting:

  • Document Indexing
  • Results Sorting
  • AND / OR Operations
  • Nested Expresions: First and (whole or world or (another word))

=======

Installation

npm install node-ft

NPM

======= Basic Usage

var nodeFT= require('node-ft');

var inx = nodeFT();

inx.index('1', "this is some text");
inx.index('2', "this is some more text");

var docs = inx.search("this");

Document storage

inx.index('1', "this is some text",
{ 
    value: 12,
    some: 'this is a doc' 
});

var docs = inx.search("this");

console.log(docs[0].doc.value);

Sort Results

var docs = inx.search("this", function(result) {
    return result.doc.sort;
});

Delete Document

inx.delete('2');

OR expressions

var docs = inx.search("this or that", function(result) {
    return result.doc.sort;
});

Nested Expressions

var docs = inx.search("this or (that and other)", function(result) {
    return result.doc.sort;
});

Clear Index

inx.clear();

Get Document Count

var docCount = inx.count();