/** * @dataProvider datatypes */ public function testDataTypes1($string, $html, $bool, $int, $float, $date, $findField, $findValue) { $session = new ezcSearchSession($this->backend, new ezcSearchEmbeddedManager()); $a = new DataTypeTest('testId', $string, $html, $bool, $int, $float, $date); $session->index($a); $q = $session->createFindQuery('DataTypeTest'); $q->where($q->eq($findField, $findValue)); $r = $session->find($q); self::assertEquals(1, $r->resultCount); self::assertEquals($string, $r->documents['testId']['document']->string); self::assertEquals($html, $r->documents['testId']['document']->html); self::assertEquals($bool, $r->documents['testId']['document']->bool); self::assertEquals($int, $r->documents['testId']['document']->int); self::assertEquals($float, $r->documents['testId']['document']->float); self::assertEquals(date_create("{$date}")->format('\\sU'), $r->documents['testId']['document']->date->format('\\sU')); }
<?php $solr = new ezcSearchSolrHandler(); $session = new ezcSearchSession($solr, new ezcSearchEmbeddedManager()); $q = $session->createFindQuery('ezcSearchSimpleArticle'); $searchWords = split(' ', $searchWord); foreach ($searchWords as $searchWord) { $q->where($q->eq('body', $searchWord))->where($q->eq('title', $searchWord)); } $q->facet('type')->limit(10, $begin); $r = $session->find($q);
/** * @dataProvider datatypesMulti */ public function testDataTypes3($string, $html, $bool, $int, $float, $date, $findField, $findValue) { $session = new ezcSearchSession($this->backend, new ezcSearchEmbeddedManager()); $string = is_array($string) ? $string : array($string); $html = is_array($html) ? $html : array($html); $bool = is_array($bool) ? $bool : array($bool); $int = is_array($int) ? $int : array($int); $float = is_array($float) ? $float : array($float); $date = is_array($date) ? $date : array($date); $a = new DataTypeTestMulti('testId', $string, $html, $bool, $int, $float, $date); $session->index($a); $q = $session->createFindQuery('DataTypeTestMulti'); $q->where($q->eq($findField, $findValue)); $r = $session->find($q); self::assertEquals(1, $r->resultCount); self::assertEquals($string, $r->documents['testId']->document->string); self::assertEquals($html, $r->documents['testId']->document->html); self::assertEquals($bool, $r->documents['testId']->document->bool); self::assertEquals($int, $r->documents['testId']->document->int); self::assertEquals($float, $r->documents['testId']->document->float); self::assertEquals(date_create($date[0])->format('\\sU'), $r->documents['testId']->document->date[0]->format('\\sU')); }
/** * @{inheritDoc} */ public function new_search_query() { $this->query = $this->client->createFindQuery('\\phpbb\\titania\\search\\document'); return $this; }
<?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'); $searchWord = 'test'; // where either body or title contains thr $searchWord $q->where($q->lOr($q->eq('body', $searchWord), $q->eq('title', $searchWord))); // limit the query and order $q->limit(10); $q->orderBy('title'); // add a facet on url (not very useful) $q->facet('url'); // run the query and show titles for found documents $r = $session->find($q); foreach ($r->documents as $res) { echo $res->document->title, "\n"; }