1.0.20 • Published 2 years ago

@foxql/foxql-index v1.0.20

Weekly downloads
69
License
ISC
Repository
github
Last release
2 years ago

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');
1.0.20

2 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.0

4 years ago