From 6d445737a4b814bedb2787ac4504352df38b48d2 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Tue, 1 May 2012 22:32:53 +0200 Subject: [PATCH] delete previous files when updating --- src/phorkie/Indexer/Elasticsearch.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 + ) ) ) ); -- 2.30.2