Esempio n. 1
0
 function invalidate(Search_Index_Interface $index)
 {
     return $index->invalidateMultiple($this->expr);
 }
Esempio n. 2
0
 function search(Search_Index_Interface $index)
 {
     $this->finalize();
     try {
         $resultset = $index->find($this, $this->start, $this->count);
     } catch (Search_Elastic_SortException $e) {
         //on sort exception, try again without the sort field
         $this->sortOrder = null;
         $resultset = $index->find($this, $this->start, $this->count);
     } catch (Exception $e) {
         TikiLib::lib('errorreport')->report($e->getMessage());
         return Search_ResultSet::create([]);
     }
     $resultset->applyTransform(function ($entry) {
         if (!isset($entry['_index']) || !isset($this->foreignQueries[$entry['_index']])) {
             foreach ($this->transformations as $trans) {
                 $entry = $trans($entry);
             }
         }
         return $entry;
     });
     foreach ($this->foreignQueries as $indexName => $query) {
         $resultset->applyTransform(function ($entry) use($query, $indexName) {
             if (isset($entry['_index']) && $entry['_index'] == $indexName) {
                 foreach ($query->transformations as $trans) {
                     $entry = $trans($entry);
                 }
             }
             return $entry;
         });
     }
     return $resultset;
 }
 function __construct(Search_Index_Interface $index)
 {
     $this->parent = $index;
     $this->identifierClass = get_class($index->getTypeFactory()->identifier(1));
 }
Esempio n. 4
0
 function search(Search_Index_Interface $index)
 {
     if ($this->weightCalculator) {
         $this->expr->walk(array($this->weightCalculator, 'calculate'));
     }
     if ($this->identifierFields) {
         $fields = $this->identifierFields;
         $this->expr->walk(function (Search_Expr_Interface $expr) use($fields) {
             if (method_exists($expr, 'getField') && in_array($expr->getField(), $fields)) {
                 $expr->setType('identifier');
             }
         });
     }
     return $index->find($this, $this->start, $this->count);
 }