+ /**
+ * When updating the repository, we don't have a creation date.
+ * We need to keep it, but elasticsearch does not have a simple way
+ * to update some fields only (without using a custom script).
+ *
+ * @return integer Unix timestamp
+ */
+ protected function getCrDate(Repository $repo)
+ {
+ $r = new Database_Adapter_Elasticsearch_HTTPRequest(
+ $this->searchInstance . 'repo/' . $repo->id,
+ \HTTP_Request2::METHOD_GET
+ );
+ $json = json_decode($r->send()->getBody());
+
+ if (!isset($json->_source->crdate)) {
+ return null;
+ }
+
+ return strtotime($json->_source->crdate);
+ }
+