yathit / ydn-db-fulltext

Full text search module for YDN-DB
30 stars 4 forks source link

full text search a multiEntry field? #8

Open cocodrino opened 9 years ago

cocodrino commented 9 years ago

Hello..sorry but I found the documentation a bit confuse

I've this code:


var schema = {
    fullTextCatalogs: [{
        name: 'web',
        lang: 'en',
        sources: [
            {storeName: 'page', keyPath: 'link', weight : 0.8 },
            {storeName: 'page', keyPath: 'tags', weight : 0.4 },
            {storeName: 'page', keyPath: 'title',weight:1}

        ]
    }],

    stores: [
        {
            name: "page",
            autoIncrement: true,

            indexes: [
                {
                    name: 'title',
                    unique: true,
                    multiEntry: false
                },
                {
                    name: 'link',
                    unique: true,
                    multiEntry: false
                },
                {
                    name: 'image'

                }, {
                    name: 'tags',
                    multiEntry: true
                }

            ]
        }
    ]
};

I need can search text inside my tags..is it possible?

I'm trying use it

var db = new ydn.db.Storage('pocket-db', schema);
db.put('page',
    {
        name: "como freir un huevo",
        link: "www.gaa.com",
        image: false,
        tags: ["test", "huevo","good"]
    }).then(
    function (id) {
        console.log("ok> " + id)
    },
    function (e) {
        console.log("bad")
    });

and retrieve the info

db.search('web', 'good')
    .done(function (r) {
        console.log("r " + r)
    });

but seems doesnt works...is it possible or must I use some trick, for instance use a single entry and separate the tags with a specific character "music::event::art" ..thanks

yathit commented 9 years ago

Full text search index and normal index are in separate object store. So, you can use without conflict.

Only string index field value are indexed. So in your case remove 'tags' from full-text index and use plain query instead. db.values('page', 'tags', IDBKeyRange.only('good'););