Example #1
0
switch ($search_fields) {
    case 'titleonly':
        $query_fields[] = 'title';
        break;
    case 'msgonly':
        $query_fields[] = 'text';
        break;
    default:
        $query_fields[] = 'title';
        $query_fields[] = 'text';
        break;
}
// Keywords specified?
if ($keywords) {
    titania_search::clean_keywords($keywords);
    $qb = new ezcSearchQueryBuilder();
    $qb->parseSearchQuery($query, $keywords, $query_fields);
    unset($qb);
}
// Author specified?
if ($user_id) {
    $query->where($query->eq('author', $user_id));
}
// Contrib specified?
if ($contrib_id) {
    $query->where($query->eq('parent_id', $contrib_id));
}
// Find contribution
if ($mode == 'find-contribution') {
    if (sizeof($categories) == 1 && $categories[0] == 0) {
        // All
Example #2
0
 public static function testWithColon2()
 {
     $q = self::setupQuery('DefinitionTwoFields');
     $qb = new ezcSearchQueryBuilder();
     $qb->parseSearchQuery($q, '"http://blahblah"', array('fieldOne', 'fieldTwo'));
     self::assertSame(array('( fieldOne_t:"http://blahblah" OR fieldTwo_t:"http://blahblah" )'), $q->whereClauses);
 }
 public static function testOrdOnlyWithDelimiters()
 {
     $q = self::setupQuery('DefinitionOneField');
     $qb = new ezcSearchQueryBuilder();
     $qb->parseSearchQuery($q, 'INTERSPORT', array('fieldOne'));
     self::assertSame(array('fieldOne_t:INTERSPORT'), $q->whereClauses);
 }
Example #4
0
 /**
  * @{inheritDoc}
  */
 public function set_keywords($keywords, $search_title, $search_text)
 {
     $keywords = $this->clean_string($keywords);
     $fields = array();
     if ($search_title) {
         $fields[] = 'title';
     }
     if ($search_text) {
         $fields[] = 'text';
     }
     $qb = new \ezcSearchQueryBuilder();
     $qb->parseSearchQuery($this->query, $keywords, $fields);
     return $this;
 }
Example #5
0
 public static function tokenize($string)
 {
     return parent::tokenize($string);
 }
Example #6
0
 public function testUpdateDocument2()
 {
     $session = new ezcSearchSession($this->backend, new ezcSearchXmlManager($this->testFilesDir));
     $session->index(new Document(1, 'Test'));
     $session->update(new Document(1, 'Something else'));
     $session->index(new Document(2, 'Test'));
     $queryBuilder = new ezcSearchQueryBuilder();
     $query = $session->createFindQuery('Document');
     $queryBuilder->parseSearchQuery($query, 'Test', array('title', 'body'));
     $r = $session->find($query);
     self::assertEquals(2, $r->documents[2]->document->id);
     self::assertEquals('Test', $r->documents[2]->document->title);
     self::assertEquals(1, $r->resultCount);
 }
Example #7
0
 /**
  * Perform a normal search
  *
  * @param string $search_query The user input for a search query
  * @param object|bool $sort The sort class
  * @param array $fields The fields to search
  *
  * @return The documents of the result
  */
 public static function search($search_query, &$sort, $fields = array('text', 'title'))
 {
     if (self::initialize() === false) {
         return false;
     }
     self::clean_keywords($search_query);
     $query = self::$index->createFindQuery('titania_article');
     $qb = new ezcSearchQueryBuilder();
     $qb->parseSearchQuery($query, $search_query, $fields);
     unset($qb);
     return self::custom_search($query, $sort);
 }
Example #8
0
<?php

require_once 'tutorial_autoload.php';
// setup
$handler = new ezcSearchSolrHandler();
$manager = new ezcSearchEmbeddedManager();
$session = new ezcSearchSession($handler, $manager);
// initialize a pre-configured query
$q = $session->createFindQuery('Article');
// where either body or title contains test but not article
$searchWord = 'test -article';
// run the query builder to search for the $searchWord in body and title
$qb = new ezcSearchQueryBuilder();
$qb->parseSearchQuery($q, $searchWord, array('body', 'title'));
// run the query and show titles for found documents, and its score
$r = $session->find($q);
foreach ($r->documents as $res) {
    echo $res->document->score, ", ", $res->document->title, "\n";
}