コード例 #1
0
    /**
     * return void
     */
    public function importXMLToDatabase()
    {
        echo "\n---------- Import to Database ----------\n";

        $xmlResponse = $this->curlCallXML($this->xmlUrl);
        $jsonArticles[] = $this->processXML($xmlResponse);

        foreach($jsonArticles as $container)
        {
            foreach($container as $article)
            {
                $solrIndexationJob = new SolrIndexationJob(null);
                $solrIndexationJob->setAttribute('data', $article);
                $solrIndexationJob->store();
            }
        }

        $this->logImport();

        echo "\n".$this->totalProcessed." articles were found and imported.\nRun process_solr_indexation_jobs to import them into SolR.\n";
    }
コード例 #2
0
    public static function importTripDatabase($month, $batch, $area)
    {
        echo "--------------------------------\r\n Importing 'Trip Database' data\r\n--------------------------------\r\n";
        $minMonth = ((self::$autoMode) ? self::$month    : (is_null($month) ? 1 : $month));
        $minBatch = ((self::$autoMode) ? self::$batch    : (is_null($batch) ? 1 : $batch));
        $maxMonth = ((self::$autoMode) ? self::$month+1  : (is_null($month) ? 13: $month+1));
        $maxBatch = ((self::$autoMode) ? self::$batch+1  : (is_null($batch) ? 6 : $batch+1));
        $areas    = is_null($area)    ? self::$areas    : array($area);

        $jsonArticles = array();
        foreach($areas as $area)
        {
            for($month = $minMonth; $month<$maxMonth ; $month++)
            {
                self::$month = $month;
                for($batch=$minBatch; $batch<$maxBatch ; $batch++)
                {
                    self::$batch = $batch;
                    $xmlResponse = self::curlCallTripAPI($area);
                    $jsonArticles[] = self::processXML($xmlResponse);
                }
            }
        }

        foreach($jsonArticles as $container)
        {
            foreach($container as $article)
            {
                $solrIndexationJob = new SolrIndexationJob(null);
                $solrIndexationJob->setAttribute('data', $article);
                $solrIndexationJob->store();
            }
        }

        $log = new eZSiteData(null);
        $log->setAttribute('name', 'trip_last_import_date');
        $log->setAttribute('value', self::$year.'-'.self::$month.'-'.self::$batch);
        $log->store();

        echo "\r\n".self::$totalProcessed." articles were found and imported.\r\nRun process_solr_indexation_jobs to import them into SolR.\r\n";
        echo "\r\nEnd of script. Bye!\r\n\r\n";
    }
コード例 #3
0
                'indent'        => 'on',
                'q'             => '*:*',
                'start'         => 0,
                'rows'          => 1,
                'fq'            => 'meta_remote_id_ms:'.$remoteId,
                'fl'            => '',//implode(',', $fields),
                'qt'            => '',
                'explainOther'  => '',
                'hl.fl'         => '',
            );

            $solrBase = new eZSolrBase();
            $result = $solrBase->rawSolrRequest( '/select', $params, 'php' );
            $result['response']['docs'][0]['attr_content_rating_'.$row['cluster_identifier'].'_f'] = $row['total'];

            $solrIndexationJob = new SolrIndexationJob(null);
            $solrIndexationJob->setAttribute('data', json_encode($result['response']['docs'][0]));
            $solrIndexationJob->store();
        }

        $mdb->query(
            sprintf(
                'UPDATE mm_rating_remote SET to_reindex = 0 WHERE remote_id = "%s"',
                $remoteId
            )
        );
    }

    eZContentObject::clearCache();
    $offset += 200;
}
コード例 #4
0
    // we let the search plugin deal with the indexation and flag the nodes not to be reindexed
    eZContentOperationCollection::registerSearchObject($object_id, false);
    eZContentObject::clearCache();
}

$i = 0;

//solrObjects
foreach($solrJsonObjects as $solrJsonObject)
{
    if (!($i%200) )
    {
        echo "Traitement Solr : $i\n";
    }

    $i++;

    $solrIndexationJob = new SolrIndexationJob(null);
    $solrIndexationJob->setAttribute('data', $solrJsonObject);
    $solrIndexationJob->store();
}

// Purge varnish cache of listing sort by most views :
echo "Purge varnish cache of listing sort by most views (".count($varnish_node_ids)." objects)\n";
$varnishControl = new VarnishControl();
$varnishControl->banMostViews( $varnish_node_ids );
// Purge varnish cache for homepage
echo "Purge varnish cache for homepage";
$varnishControl->banUri('/esibuild/main_view/app_content//');
コード例 #5
0
    public function processImport()
    {
        $i = 0;
        if (!is_array($this->feedArticles))
        {
            throw new Exception("Feed list should be an array.");
        }
        $parsedArticles = array();
        foreach ($this->feedArticles as $article)
        {
            $parsedArticles[] = $this->processArticle((array)$article);
        }

        foreach ($parsedArticles as $article)
        {
            $solrIndexationJob = new SolrIndexationJob();
            $solrIndexationJob->setAttribute('data', $article);
            $solrIndexationJob->store();
            $i++;
        }

        return $i;
    }
コード例 #6
0
/**
 * Get all pending indexation jobs
 * @throws Exception
 * @return array
 */
function getPendingJobs()
{
    $jobs = SolrIndexationJob::fetchPendingList();
    if( ! count( $jobs ) > 0 )
    {
        throw new Exception( 'No pending job found' );
    }

    return $jobs;
}
コード例 #7
0
    public function importTrial($trialId)
    {
        $url = $this->buildUrl('GetTrialDetails', array(
            'TrialIDnum' => $trialId,
            'username' => self::TRIAL_DETAILS_USERNAME,
            'password' => self::TRIAL_DETAILS_PASSWORD,
        ));

        $contents = $this->executeCurl($url);
        $trialData = $this->buildTrialData($trialId, $contents);
        if ($trialData == null) {
            return null;
        }
        $coreContentFields = array(
            $trialData['title'],
            $trialData['details']['scientific_title'],
            $trialData['details']['sponsor'],
            $trialData['conditions'],
            $trialData['details']['interventions'],
            implode(',', $trialData['country']),
            $trialData['id'],
            implode(',', $trialData['details']['secondary_id']),
        );

        $articleData = array(
            'meta_installation_id_ms'           => keZSolr::installationID(),
            //'meta_path_id_si'                   => self::getMetaPathId(),
            'meta_guid_ms'                      => md5('clinical_trials' . $trialData['id']),
            'meta_remote_id_ms'                 => md5('clinical_trials' . $trialData['id']),
            'meta_section_id_si'                => 1,
            'attr_cluster_uk_url_s'	            => md5('clinical_trials' . $trialData['link']),
            'attr_date_dt'                      => $trialData['details']['update_date'],
            'attr_offline_date_dt'              => '1970-01-01T01:00:00Z',
            'attr_archived_date_dt'	            => '1970-01-01T01:00:00Z',
            'attr_headline_t'                   => $trialData['title'],
            'attr_headline_s'                   => $trialData['title'],
            'attr_headline_lc_s'                => iconv('UTF-8', 'ASCII//TRANSLIT', strtolower($trialData['title'])),
            'attr_is_invisible_cluster_uk_b'    => false,
            'attr_depth_cluster_uk_i'           => 0,
            'attr_relative_depth_i'             => 0,
            'subattr_customer_type___source_id____s'        => self::getCustomerTypes(),
            'subattr_language___source_id____s'             => 'en',
            'subattr_local_application___source_id____s'    => $this->application->id,
            'subattr_publisher_folder___source_id____s'     => "clinical_trials_oncology",
            'meta_language_code_ms'     => 'eng-GB',
            'meta_class_identifier_ms' => 'article',
            'attr_exclude_from_search_cluster_uk_b' => false,
            'attr_hide_in_search_b' => false,
            "attr_clinical_trials_details_s" => json_encode($trialData['details']),
            'attr_core_content_t' => implode(',', $coreContentFields),
            'subattr_recruitment_status___source_id____s' => $trialData['status'],
            'attr_clinical_trials_conditions_s' => $trialData['conditions'],
            'subattr_gender___source_id____s' => $trialData['sex'],
            'attr_clinical_trials_min_age_i' => $trialData['min_age'],
            'attr_clinical_trials_max_age_i' => $trialData['max_age'],
            "attr_clinical_trials_country____s" => $trialData['country'],
        );
        $clusters = ClusterTool::getAllClusters();
        foreach ($clusters as $cluster)
        {
            $articleData["attr_{$cluster}_url_s"] = $trialData['id'];
            $articleData["subattr_language_{$cluster}____s"] = 'en';
            $articleData['subattr_local_application___source_mixed____s'][] = "{$cluster}##unused##{$this->application->id}";
            $articleData["attr_is_invisible_{$cluster}_b"] = false;
        }
        $data = json_encode($articleData);

        $solrIndexationJob = new SolrIndexationJob();
        $solrIndexationJob->setAttribute('data', $data);
        $solrIndexationJob->store();

        return true;
    }