server/src/app/Repositories/RdfDocumentRepository.php
changeset 502 74fba571487e
parent 499 b5cff30efa0a
child 506 8a5bb4b48b85
equal deleted inserted replaced
501:7b2dcd2b31c1 502:74fba571487e
   421             }
   421             }
   422         }
   422         }
   423 
   423 
   424         return $docList;
   424         return $docList;
   425     }
   425     }
       
   426 
       
   427     /**
       
   428      * Add country info for document.
       
   429      * This modify the document
       
   430      *
       
   431      * @param $doc the document instance
       
   432      * @return nothing
       
   433      */
       
   434     public function addCountryInfo($doc) {
       
   435         $params = [
       
   436             'index' => config('corpusparole.elasticsearch_index'),
       
   437             'type' => 'document',
       
   438             'id' => $doc->getId()
       
   439         ];
       
   440         $esRes = Es::get($params);
       
   441 
       
   442         if(!empty($esRes) && $esRes['found']) {
       
   443             $source = $esRes["_source"];
       
   444             if(array_key_exists('geonames_country', $source)) {
       
   445                 $doc->setCountryCode($source['geonames_country']);
       
   446             }
       
   447         } else {
       
   448             Log::error("RdfDocumentRepository::addCountryInfo : Document ".$doc->getId()." not found in index.");
       
   449         }
       
   450     }
       
   451 
   426 }
   452 }