Example #1
0
 /**
  * Applies the current prefix to the clause in $string
  *
  * @param ezcSearchQuery $q
  * @param string $string
  *
  * @return string
  */
 private function processPrefix(ezcSearchQuery $q, $string)
 {
     switch ($this->prefix) {
         case ezcSearchQueryToken::PLUS:
             $string = $q->important($string);
             break;
         case ezcSearchQueryToken::MINUS:
             $string = $q->not($string);
             break;
     }
     return $string;
 }
Example #2
0
 /**
  * Converts a raw zendlucene result into a document using the definition $def
  *
  * @param ezcSearchQuery $query
  * @param mixed $response
  * @return ezcSearchResult
  */
 private function createResponseFromData(ezcSearchQuery $query, $response)
 {
     $def = $query->getDefinition();
     $s = new ezcSearchResult();
     $s->resultCount = count($response);
     $counter = -1;
     foreach ($response as $hit) {
         $counter++;
         if ($counter < $query->offset) {
             continue;
         }
         if ($query->limit !== null && $counter >= $query->limit + $query->offset) {
             break;
         }
         $resultDocument = $this->createDataForHit($hit, $def);
         $idProperty = $def->idProperty;
         $s->documents[$resultDocument->document->{$idProperty}] = $resultDocument;
     }
     return $s;
 }
Example #3
0
 /**
  * Converts a raw zendlucene result into a document using the definition $def
  *
  * @param ezcSearchQuery $query
  * @param mixed $response
  * @return ezcSearchResult
  */
 private function createResponseFromData(ezcSearchQuery $query, $response)
 {
     $def = $query->getDefinition();
     $s = new ezcSearchResult();
     $s->resultCount = count($response);
     $counter = -1;
     foreach ($response as $hit) {
         $counter++;
         if ($counter < $query->offset) {
             continue;
         }
         if ($query->limit !== null && $counter >= $query->limit + $query->offset) {
             break;
         }
         $document = $hit->getDocument();
         $className = $def->documentType;
         $obj = new $className();
         $attr = array();
         foreach ($def->fields as $field) {
             $fieldName = $this->mapFieldType($field->field, $field->type);
             if ($field->inResult) {
                 $attr[$field->field] = $this->mapFieldValuesForReturn($field, $document->{$fieldName});
             }
         }
         $obj->setState($attr);
         $idProperty = $def->idProperty;
         $s->documents[$attr[$idProperty]] = array('meta' => array('score' => $hit->score), 'document' => $obj);
     }
     return $s;
 }