Пример #1
0
    public function search($remoteId, $nodeId, $language) {
        $queryParameters = array();

        if ($remoteId)
            $queryParameters[] = 'meta_remote_id_ms:' . $remoteId;
        if ($nodeId)
            $queryParameters[] = 'meta_node_id_si:' . $nodeId;
        if ($language)
            $queryParameters[] = 'meta_language_code_ms:' . $language;

        $parameters = array();
        if (count($queryParameters))
            $parameters['q'] = implode(' AND ', $queryParameters);

        $solr = new eZSolrBase(false);
        $rawSearch = $solr->rawSearch($parameters);

        $docs = array();
        if (isset($rawSearch['response']['docs'])) {
            $docs = $rawSearch['response']['docs'];
        }

        return $docs;
    }
Пример #2
0
 /**
  *
  * @param eZSolrBase $fromCore
  * @param eZSolrBase $toCore
  * @param <type> $keyField
  * @param <type> $filterQuery
  * @param <type> $params hash array with fields to modify or add, fields to suppress
  *      hash keys: 'modify_fields' (hash array key->value),
  *                 'suppress_fields' (array of strings),
  *                 'add_fields' (hash array key->value)
  * @param <type> $commit
  * @param <type> $optimize
  * @param <type> $commitWithin
  */
 public static function moveDocumentsByQuery(eZSolrBase $fromCore, eZSolrBase $toCore, $keyField, $filterQuery, $params = array(), $commit = false, $optimize = false, $commitWithin = 0)
 {
     $resultArray = $fromCore->rawSearch(array('q' => '*:*', 'fl' => $keyField, 'rows' => 1000000, 'fq' => $filterQuery), 'json');
     foreach ($resultArray['response']['docs'] as $doc) {
         // don't issue commits, let alone optimize commands for this batch
         $result = self::moveDocument($fromCore, $toCore, $keyField, $doc[$keyField], $params, false, false, $commitWithin);
     }
     if ($commitWithin == 0) {
         $fromCore->commit();
         $toCore->commit();
     }
 }