git.cweiske.de
/
phorkie.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b06abeb
)
delete previous files when updating
author
Christian Weiske
<cweiske@cweiske.de>
Tue, 1 May 2012 20:32:53 +0000
(22:32 +0200)
committer
Christian Weiske
<cweiske@cweiske.de>
Tue, 1 May 2012 20:32:53 +0000
(22:32 +0200)
src/phorkie/Indexer/Elasticsearch.php
patch
|
blob
|
history
diff --git
a/src/phorkie/Indexer/Elasticsearch.php
b/src/phorkie/Indexer/Elasticsearch.php
index c2fcfccde7f8d40f6e8568ad3c1a833510fa2b09..29212397368bcb3f1fbdc5e0b3972c09cb2f715f 100644
(file)
--- a/
src/phorkie/Indexer/Elasticsearch.php
+++ b/
src/phorkie/Indexer/Elasticsearch.php
@@
-32,6
+32,9
@@
class Indexer_Elasticsearch
$r->send();
//add files
$r->send();
//add files
+ //clean up before adding files; files might have been deleted
+ $this->deleteRepoFiles($repo);
+
foreach ($repo->getFiles() as $file) {
$r = new \HTTP_Request2(
$this->searchInstance . 'file/?parent=' . $repo->id,
foreach ($repo->getFiles() as $file) {
$r = new \HTTP_Request2(
$this->searchInstance . 'file/?parent=' . $repo->id,
@@
-59,6
+62,11
@@
class Indexer_Elasticsearch
);
$r->send();
);
$r->send();
+ $this->deleteRepoFiles($repo);
+ }
+
+ protected function deleteRepoFiles(Repository $repo)
+ {
//delete files of that repository
$r = new \HTTP_Request2(
$this->searchInstance . 'file/_query',
//delete files of that repository
$r = new \HTTP_Request2(
$this->searchInstance . 'file/_query',
@@
-67,7
+75,9
@@
class Indexer_Elasticsearch
$r->setBody(
json_encode(
(object)array(
$r->setBody(
json_encode(
(object)array(
- '_parent' => 'repo#' . $repo->id
+ 'field' => (object)array(
+ '_parent' => $repo->id
+ )
)
)
);
)
)
);