@foxql/foxql-index

1.0.20 • Public • Published

foxql-index

Inverted index database system simple implementation for foxql. Search result use case p2p connection proof.

Documentation

Install npm

npm i @foxql/foxql-index

Basic usage

const foxqlIndex = require('@foxql/foxql-index');

const database = new foxqlIndex();

database.pushCollection({
    collectionName : 'entrys',
    fields : [
        'title',
        'content'
    ],
    ref : 'documentId',
    schema : {
        title : {
            type : 'string',
            min : 3,
            max : 80
        },
        content : {
            type : 'string',
            min : 7,
            max : 500,
        },
        documentId : {
            makeFrom : ['title', 'content']
        }   
    }
});

Add Analyzer methods

database.useCollection('entrys').registerAnalyzer('tokenizer', (string)=>{
    return string.toLowerCase().replace(/  +/g, ' ').trim();
}); 

Add document

database.useCollection('entrys').addDoc({
    title : 'test title',
    content : 'test example content, very simple usage',
    documentId : 1
});

Search document

const results = database.useCollection('entrys').search("test query");
console.log(results);

Export Database

const dump = database.export();

Import Database

const dump = database.export();
database.import(dump);

Change analyzer methods sort

database.useCollection('entrys').registerAnalyzer('tokenizer', (string)=>{
    return string.toLowerCase().replace(/  +/g, ' ');
}); 
database.useCollection('entrys').registerAnalyzer('tokenizer2', (string)=>{
    return string.trim();
}); 

//if want aboving change methods sort

database.useCollection('entrys').analyzerSteps = [
    'tokenizer2',
    'tokenizer'
];
    

Delete document

database.useCollection('entrys').deleteDoc('ref id');

Get document by ref

database.useCollection('entrys').getDoc('ref id');

Package Sidebar

Install

npm i @foxql/foxql-index

Weekly Downloads

3

Version

1.0.20

License

ISC

Unpacked Size

19.4 kB

Total Files

12

Last publish

Collaborators

  • foxql