a full text indexing library for javascript
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
Christopher Ramey a628ddfa2e pre-archival commit 2 months ago
example Added better examples and created new README 9 years ago
LICENCE Added copyright information 9 years ago
README.md pre-archival commit 2 months ago
tidx.js Bug fixes for search chaining scheme 9 years ago

README.md

Tidx

Tidx has been retired. There are better Javascript full text indexing libraries available. This project is merely kept here for archival purposes.

Tidx is a simple Javascript full text indexing library. Tidx is BSD licensed.

basic usage

First, create a new Tidx object:

var idx = new Tidx();

Next, add your data to the index with the index function:

idx.index(true, 1, 'Name', 'John D. Smith');

The index function accepts four arguments: The first is a boolean which is if the data to be added to the index should be tokenized (that is, broken down into discrete searchable terms), the second is the unique identifier for the data (which will be returned when you search), a field name associated with the data (or null if you don't have a field) and the value you wish to add to the index. In the above example, since we've enabled tokenization, the value would be indexed as three terms "john", "d" and "smith".

Searching your index is easy:

var results = idx.search(true, 'john');

The search function accepts two arguments: A boolean argument of true if you wish your search terms to be logically conjuct (as if connected by AND) or false if you want your terms to be logically disjunct (as if connected by OR). The second argument is your search terms. The search function supports multiword terms when surrounded by quotes "John Smith", and fields can be specified by name if using a semi-colon (e.g. "name:john") The returned results of the search function is an array of IDs ordered by frequency of terms from your search.

Fully functional examples of usage can be found in the examples directory.

advanced usage

Tidx also supports chaining searches together. This is useful in instances where you may have multiple points of entry for a single search, and the results should be an aggregate of each. After your index is initialized and data has been added (see above), you can then search it using raw_search:

var raw_results = {};
var term_count = idx.raw_search('John', raw_results);

Additional searches may then be added in the same way:

term_count += idx.raw_search('Smith', raw_results);

Field specific, single term scans may also be included:

term_count += idx.field_scan('Name', 'David', raw_results);

Finally, the results can be ordered and filtered:

var results = idx.order(raw_results, term_count);

If you'd like the results of your search terms to be logically conjunct (as if connected by AND), specific the term count you collected from search. If you'd like them to be logically disjunct (as if connected by OR), specify a term count of zero.