Skip to content
This repository has been archived by the owner on Jan 22, 2021. It is now read-only.
/ IndexedFTS Public archive

Full-Text Search engine for web browser.

License

Notifications You must be signed in to change notification settings

macrat/IndexedFTS

Repository files navigation

IndexedFTS

Full-Text Search engine for web browser.

NPM

Build Status Coverage Status license document

install

HTML

<script src="https://unpkg.com/indexedfts"></script>

Node

$ npm install indexedfts

ES6

import IndexedFTS from 'indexedfts';

common js

const IndexedFTS = require('indexedfts').IndexedFTS;

example

// make database
const db = IndexedFTS('database-name', 1, {
	userid: 'primary',                     // primary key will indexed but can not full-text search
	name: {unique: true, fulltext: true},  // unique index and can full-text search
	description: 'fulltext',               // full-text search
});


db.open()
	.then(() => {
		db.put({
			userid: 1,
			name: 'hello',
			description: 'this is test\n',
		}, {
			userid: 20,
			name: 'world',
			description: 'check check\nhello hello world!',
		});
	})

	.then(() => db.search(['name', 'description'], 'hel').lower('userid', 5))
	.then(result => {
		console.log(result.length);   // output: 1
		console.log(result[0].name);  // output: hello
	})