diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2012-05-01 22:32:53 +0200 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2012-05-01 22:32:53 +0200 |
| commit | 6d445737a4b814bedb2787ac4504352df38b48d2 (patch) | |
| tree | 53e56a69b96770f6f3590c59b3f0c34ab992978c /src | |
| parent | b06abebda261ebecd52c6c32e762ccf14e24cdbf (diff) | |
| download | phorkie-6d445737a4b814bedb2787ac4504352df38b48d2.tar.gz phorkie-6d445737a4b814bedb2787ac4504352df38b48d2.zip | |
delete previous files when updating
Diffstat (limited to 'src')
| -rw-r--r-- | src/phorkie/Indexer/Elasticsearch.php | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/phorkie/Indexer/Elasticsearch.php b/src/phorkie/Indexer/Elasticsearch.php index c2fcfcc..2921239 100644 --- a/src/phorkie/Indexer/Elasticsearch.php +++ b/src/phorkie/Indexer/Elasticsearch.php @@ -32,6 +32,9 @@ class Indexer_Elasticsearch $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, @@ -59,6 +62,11 @@ class Indexer_Elasticsearch ); $r->send(); + $this->deleteRepoFiles($repo); + } + + protected function deleteRepoFiles(Repository $repo) + { //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( - '_parent' => 'repo#' . $repo->id + 'field' => (object)array( + '_parent' => $repo->id + ) ) ) ); |
