Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio_mebibou
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
Alexandra Rogova
jio_mebibou
Commits
04b2ec22
Commit
04b2ec22
authored
Jul 29, 2019
by
Alexandra Rogova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lint
parent
fc90baef
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
45 deletions
+43
-45
src/jio.storage/elasticlunrstorage.js
src/jio.storage/elasticlunrstorage.js
+24
-25
test/jio.storage/elasticlunrstorage.tests.js
test/jio.storage/elasticlunrstorage.tests.js
+19
-20
No files found.
src/jio.storage/elasticlunrstorage.js
View file @
04b2ec22
...
...
@@ -67,7 +67,7 @@
});
index
.
setRef
(
id
);
// do not store the documents in the index
//
index.saveDocument(false);
index
.
saveDocument
(
false
);
return
index
;
}
...
...
@@ -110,7 +110,7 @@
return
null
;
}
function
recursiveIndexQuery
(
index
,
indexedFields
,
query
,
sub_storage
)
{
function
recursiveIndexQuery
(
index
,
indexedFields
,
query
)
{
var
ids
=
null
,
subquery
,
i
,
...
...
@@ -306,38 +306,37 @@
context
=
this
,
args
=
arguments
;
return
this
.
_getIndex
()
.
push
(
function
(
index
)
{
.
push
(
function
(
index
)
{
idx
=
index
;
return
context
.
_sub_storage
.
repair
.
apply
(
context
.
_sub_storage
,
args
);
})
.
push
(
function
()
{
.
push
(
function
()
{
return
context
.
_sub_storage
.
allDocs
();
})
.
push
(
function
(
all_docs
)
{
.
push
(
function
(
all_docs
)
{
var
i
,
queue
=
new
RSVP
.
Queue
(),
add_to_queue
;
add_to_queue
=
function
(
id
)
{
queue
.
push
(
function
()
{
add_to_queue
=
function
(
id
)
{
queue
.
push
(
function
()
{
return
context
.
_sub_storage
.
get
(
id
.
toString
());
})
.
push
(
function
(
doc
)
{
.
push
(
function
(
doc
)
{
var
data
=
JSON
.
parse
(
JSON
.
stringify
(
doc
));
data
.
id
=
id
.
toString
();
idx
.
updateDoc
(
data
);
});
};
for
(
i
=
0
;
i
<
all_docs
.
data
.
rows
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
all_docs
.
data
.
rows
.
length
;
i
+=
1
)
{
add_to_queue
(
all_docs
.
data
.
rows
[
i
].
id
);
doc_ids
.
push
(
all_docs
.
data
.
rows
[
i
].
id
);
}
return
queue
;
})
.
push
(
undefined
,
function
(
my_error
)
{
if
(
my_error
.
status_code
===
501
)
{
//501 = sub_storage does not have allDocs capacity
//
if
(
my_error
.
status_code
!==
501
)
{
throw
my_error
;
//501 = sub_storage does not have allDocs capacity
}
else
throw
my_error
;
});
};
...
...
@@ -355,7 +354,7 @@
return
this
.
_sub_storage
.
hasCapacity
(
name
);
};
ElasticlunrStorage
.
prototype
.
buildQuery
=
function
(
options
)
{
// Appelé par allDocs
ElasticlunrStorage
.
prototype
.
buildQuery
=
function
(
options
)
{
var
context
=
this
,
indexedFields
=
this
.
_index_fields
,
runSubstorageQuery
=
options
.
select_list
||
options
.
include_docs
,
...
...
@@ -365,7 +364,7 @@
parsedQuery
=
jIO
.
QueryFactory
.
create
(
options
.
query
);
return
context
.
_getIndex
()
.
push
(
function
(
index
)
{
return
recursiveIndexQuery
(
index
,
indexedFields
,
parsedQuery
,
context
.
_sub_storage
);
return
recursiveIndexQuery
(
index
,
indexedFields
,
parsedQuery
);
})
.
push
(
function
(
ids
)
{
try
{
...
...
test/jio.storage/elasticlunrstorage.tests.js
View file @
04b2ec22
...
...
@@ -620,7 +620,6 @@
deepEqual
(
options
,
expected_options
,
"
repair 200 called
"
);
return
"
OK
"
;
};
jio
.
repair
(
expected_options
)
/*.then(function (result) {
equal(result, "OK");
...
...
@@ -633,7 +632,7 @@
});
});
test
(
"
repair adds missing documents
"
,
function
()
{
test
(
"
repair adds missing documents
"
,
function
()
{
stop
();
expect
(
2
);
...
...
@@ -660,12 +659,12 @@
sub_storage
.
put
(
"
foo
"
,
{
title
:
"
bar
"
});
return
jio
.
repair
()
.
push
(
function
()
{
.
push
(
function
()
{
return
jio
.
allDocs
({
query
:
'
title: "bar"
'
});
})
.
push
(
function
(
result
)
{
.
push
(
function
(
result
)
{
equal
(
result
.
data
.
total_rows
,
1
);
equal
(
result
.
data
.
rows
[
0
].
id
,
"
foo
"
);
})
...
...
@@ -677,7 +676,7 @@
});
});
test
(
"
repair updates documents
"
,
function
()
{
test
(
"
repair updates documents
"
,
function
()
{
expect
(
2
);
stop
();
...
...
@@ -706,16 +705,16 @@
});
return
jio
.
put
(
"
foo
"
,
{
title
:
"
bar
"
})
.
push
(
function
()
{
.
push
(
function
()
{
return
sub_storage
.
put
(
"
foo
"
,
{
title
:
"
Hello world!
"
});
})
.
push
(
function
()
{
.
push
(
function
()
{
return
jio
.
repair
();
})
.
push
(
function
()
{
.
push
(
function
()
{
return
jio
.
allDocs
({
query
:
'
title: "Hello world!"
'
});
})
.
push
(
function
(
result
)
{
.
push
(
function
(
result
)
{
equal
(
result
.
data
.
total_rows
,
1
);
equal
(
result
.
data
.
rows
[
0
].
id
,
"
foo
"
);
})
...
...
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