src/snac/server/elastic/ElasticSearchUtil.php
/**
     * Write or Update Name Indices
     *
     * Writes the names from the given constellation to the name indices in Elastic Search.  If they already exist in ES, they
     * are updated. If not, they are inserted.
     *
     * @param \snac\data\Constellation $constellation The constellation object to insert/update in Elastic Search
     */
Write or Update Name Indices
Writes the names from the given constellation to the name indices in Elastic Search.  If they already exist in ES, they
are updated. If not, they are inserted.

@param \snac\data\Constellation $constellation The constellation object to insert/update in Elastic Search
Write or Update Name Indices Writes the names from the given constellation to the name indices in Elastic Search . If they already exist in ES they are updated . If not they are inserted . @param \ snac \ data \ Constellation $constellation The constellation object to insert / update in Elastic Search
public function writeToNameIndices(&$constellation) {
        if ($this->connector != null) {
            $wiki = new \snac\server\util\WikipediaUtil();
            list($hasImage, $imgURL, $imgMeta) = $wiki->getWikiImage($constellation->getArk());
            $subjects = [];
            foreach ($constellation->getSubjects() as $subject) {
                array_push($subjects, $subject->getTerm()->getTerm());
            }
            $occupations = [];
            foreach ($constellation->getOccupations() as $occupation) {
                array_push($occupations, $occupation->getTerm()->getTerm());
            }
            $activities = [];
            foreach ($constellation->getActivities() as $activity) {
                array_push($activities, $activity->getTerm()->getTerm());
            }
            $biogHists = [];
            foreach ($constellation->getBiogHistList() as $biogHist) {
                array_push($biogHists, $biogHist->getText());
            }
            $params = [
                'index' => \snac\Config::$ELASTIC_SEARCH_BASE_INDEX,
                'id' => $constellation->getID(),
                'body' => [
                    'nameEntry' => $constellation->getPreferredNameEntry()->getOriginal(),
                    'entityType' => $constellation->getEntityType()->getTerm(),
                    'arkID' => $constellation->getArk(),
                    'id' => (int) $constellation->getID(),
                    'degree' => (int) count($constellation->getRelations()),
                    'resources' => (int) count($constellation->getResourceRelations()),
                    'subject' => $subjects,
                    'occupation' => $occupations,
                    'activity' => $activities,
                    'biogHist' => $biogHists,
                    'hasImage' => $hasImage,
                    'imageURL' => $imgURL,
                    'imageMeta' => $imgMeta,
                    'timestamp' => date('c')
                ]
            ];
            $this->connector->index($params);
            foreach ($constellation->getNameEntries() as $entry) {
                $params = [
                    'index' => \snac\Config::$ELASTIC_SEARCH_ALL_INDEX,
                    'id' => $entry->getID(),
                    'body' => [
                        'nameEntry' => $entry->getOriginal(),
                        'entityType' => $constellation->getEntityType()->getTerm(),
                        'arkID' => $constellation->getArk(),
                        'id' => (int) $constellation->getID(),
                        'name_id' => (int) $entry->getID(),
                        'degree' => (int) count($constellation->getRelations()),
                        'resources' => (int) count($constellation->getResourceRelations()),
                        'timestamp' => date("c")
                    ]
                ];
                $this->connector->index($params);
            }
            $this->logger->addDebug("Updated elastic search with new constellation name entries");
        }
    }
public function writeToNameIndices ( & $ constellation ) { if ( $ this -> connector != null ) { $ wiki = new \ snac \ server \ util \ WikipediaUtil ( ) ; list ( $ hasImage , $ imgURL , $ imgMeta ) = $ wiki -> getWikiImage ( $ constellation -> getArk ( ) ) ; $ subjects = [ ] ; foreach ( $ constellation -> getSubjects ( ) as $ subject ) { array_push ( $ subjects , $ subject -> getTerm ( ) -> getTerm ( ) ) ; } $ occupations = [ ] ; foreach ( $ constellation -> getOccupations ( ) as $ occupation ) { array_push ( $ occupations , $ occupation -> getTerm ( ) -> getTerm ( ) ) ; } $ activities = [ ] ; foreach ( $ constellation -> getActivities ( ) as $ activity ) { array_push ( $ activities , $ activity -> getTerm ( ) -> getTerm ( ) ) ; } $ biogHists = [ ] ; foreach ( $ constellation -> getBiogHistList ( ) as $ biogHist ) { array_push ( $ biogHists , $ biogHist -> getText ( ) ) ; } $ params = [ 'index' => \ snac \ Config :: $ ELASTIC_SEARCH_BASE_INDEX , 'id' => $ constellation -> getID ( ) , 'body' => [ 'nameEntry' => $ constellation -> getPreferredNameEntry ( ) -> getOriginal ( ) , 'entityType' => $ constellation -> getEntityType ( ) -> getTerm ( ) , 'arkID' => $ constellation -> getArk ( ) , 'id' => ( int ) $ constellation -> getID ( ) , 'degree' => ( int ) count ( $ constellation -> getRelations ( ) ) , 'resources' => ( int ) count ( $ constellation -> getResourceRelations ( ) ) , 'subject' => $ subjects , 'occupation' => $ occupations , 'activity' => $ activities , 'biogHist' => $ biogHists , 'hasImage' => $ hasImage , 'imageURL' => $ imgURL , 'imageMeta' => $ imgMeta , 'timestamp' => date ( 'c' ) ] ] ; $ this -> connector -> index ( $ params ) ; foreach ( $ constellation -> getNameEntries ( ) as $ entry ) { $ params = [ 'index' => \ snac \ Config :: $ ELASTIC_SEARCH_ALL_INDEX , 'id' => $ entry -> getID ( ) , 'body' => [ 'nameEntry' => $ entry -> getOriginal ( ) , 'entityType' => $ constellation -> getEntityType ( ) -> getTerm ( ) , 'arkID' => $ constellation -> getArk ( ) , 'id' => ( int ) $ constellation -> getID ( ) , 'name_id' => ( int ) $ entry -> getID ( ) , 'degree' => ( int ) count ( $ constellation -> getRelations ( ) ) , 'resources' => ( int ) count ( $ constellation -> getResourceRelations ( ) ) , 'timestamp' => date ( " c " ) ] ] ; $ this -> connector -> index ( $ params ) ; } $ this -> logger -> addDebug ( " Updated elastic search with new constellation name entries " ) ; } }
Write or Update Name Indices
 Writes the names from the given constellation to the name indices in Elastic Search.
Write or Update Name Indices Writes the names from the given constellation to the name indices in Elastic Search .
// Check wikipedia for an image to cache // 'index' => \snac\Config::$ELASTIC_SEARCH_BASE_INDEX,