Commit 2a87cbb4 by preetwinder

add elasticlunrstorage

1 parent a0c3917a
(function (Benchmark, jIO, RSVP, rJS) {
var suite = new Benchmark.Suite;
var storage_elastic, storage_memory;
suite.add('elasticlunrstorage-create', function() {
storage_elastic = jIO.createJIO({type: 'ElasticlunrStorage', keys: ['title', 'body']})
})
.add('elasticlunrstorage-put', function() {
return storage_elastic.put('1', {title: 'bob', body: 'bog'})
})
.add('elasticlunrstorage-get', function() {
return storage_elastic.get('1')
})
.add('memorystorage-create', function() {
storage_memory = jIO.createJIO({type: 'memory'})
})
.add('memorystorage-put', function() {
return storage_memory.put('1', {title: 'bob', body: 'bog'})
})
.add('memorystorage-get', function() {
return storage_memory.get('1')
})
.on('cycle', function(event) {
console.log(String(event.target));
})
.run({ 'async': false });
}(Benchmark, jIO, RSVP, rJS))
\ No newline at end of file
(function (jIO, RSVP, elasticlunr) {
"use strict";
(function (jIO, RSVP) {
function ElasticlunrStorage(spec) {
var that = this, i;
that._index = elasticlunr(function () {
for (i = 0; i < spec.keys.length; i++) {
this.addField(spec.keys[i]);
}
this.setRef('id')
});
}
ElasticlunrStorage.prototype.put = function (id, metadata) {
var that = this;
metadata['id'] = id;
that._index.addDoc(metadata);
};
ElasticlunrStorage.prototype.get = function (id) {
var that = this;
return that._index.search(id);
};
ElasticlunrStorage.prototype.buildQuery = function (query) {
var that = this;
var docstore_dict = that._index.toJSON().documentStore.docs;
console.log(docstore_dict)
return Object.keys(docstore_dict).map(function(key){
return docstore_dict[key]});
};
ElasticlunrStorage.prototype.hasCapacity = function (name) {
return (name === "list");
};
jIO.addStorage('ElasticlunrStorage', ElasticlunrStorage);
}(jIO, RSVP));
}(jIO, RSVP, elasticlunr));
\ No newline at end of file
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!