Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
preetwinder
jio
Commits
2a87cbb4
Commit
2a87cbb4
authored
Jul 06, 2017
by
preetwinder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add elasticlunrstorage
parent
a0c3917a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
0 deletions
+74
-0
src/jio.storage/elasticlunrstorage-test.js
src/jio.storage/elasticlunrstorage-test.js
+31
-0
src/jio.storage/elasticlunrstorage.js
src/jio.storage/elasticlunrstorage.js
+43
-0
No files found.
src/jio.storage/elasticlunrstorage-test.js
0 → 100644
View file @
2a87cbb4
(
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
src/jio.storage/elasticlunrstorage.js
0 → 100644
View file @
2a87cbb4
(
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment