--- a/server/src/app/Console/Commands/IndexDocuments.php Thu Oct 06 11:14:32 2016 +0200
+++ b/server/src/app/Console/Commands/IndexDocuments.php Thu Oct 06 16:45:37 2016 +0200
@@ -27,7 +27,7 @@
{--limit=0 : index only the first n documents, 0 (default) means index everything }
{--no-bulk : index documents one by one instead of using ElasticSearch bulk indexing }
{--step-size=100 : number of documents to retrieve from repository at a time before indexing}
- {--reset-geo-cache: reset geo cache befr indexing}';
+ {--reset-geo-cache : reset geo cache befr indexing}';
/**
* The console command description.
@@ -61,12 +61,8 @@
*
* @return int (1 if sucess, 0 if error)
*/
- private function resetIndex($resetGeoCache)
+ private function resetIndex()
{
- if($resetGeoCache) {
- // delete all rows in GeonamesHierarchy
- GeonamesHierarchy::getQuery()->delete();
- }
$indexParams = [
'index' => env('ELASTICSEARCH_INDEX')
];
@@ -189,17 +185,30 @@
$mLexvo = [];
if($s instanceof Resource && preg_match(config('corpusparole.bnf_ark_url_regexp'), $s->getUri(), $mBnf) === 1) {
+
array_push($res, [
'uri' => $mBnf[0],
'code' => $mBnf[1],
'type' => 'bnf'
]);
- } elseif($s instanceof Resource && preg_match(config('corpusparole.lexvo_url_regexp'), $s->getUri(). $mLexvo) === 1) {
+ } elseif($s instanceof Resource && preg_match(config('corpusparole.lexvo_url_regexp'), $s->getUri(), $mLexvo) === 1) {
array_push($res, [
'uri' => $mLexvo[0],
'code' => $mLexvo[1],
'type' => 'lxv'
]);
+ } elseif($s instanceof Literal && strpos($s->getDatatypeUri(), config('corpusparole.olac_base_url')) === 0 ) {
+ array_push($res, [
+ 'uri' => $s->getValue(),
+ 'code' => $s->getValue(),
+ 'type' => 'olac'
+ ]);
+ } elseif($s instanceof Literal) {
+ array_push($res, [
+ 'uri' => $s->getValue(),
+ 'code' => $s->getValue(),
+ 'type' => 'txt'
+ ]);
}
return $res;
@@ -216,7 +225,7 @@
},[]
))
);
- $labelsLexvo = $this->lexvoResolver->getLabels(
+ $labelsLexvo = $this->lexvoResolver->getNames(
array_unique(array_reduce(
$sres,
function($r, $so) {
@@ -311,9 +320,14 @@
$stepSize = $this->option('step-size');
$this->comment(' - Indexing with step size of '.$stepSize);
- $resetGeoCache = $this->option('reset-geo-cache', false);
+ if($this->option('reset-geo-cache', false)) {
+ // delete all rows in GeonamesHierarchy
+ GeonamesHierarchy::getQuery()->delete();
+ $this->comment('Geonames cache reset!');
+ }
+
$this->info('Resetting index...');
- $success = $this->resetIndex($resetGeoCache);
+ $success = $this->resetIndex();
if($success==1){
$this->comment('Index reset!');
}