ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilLuceneSearcher Class Reference

Reads and parses lucene search results. More...

+ Collaboration diagram for ilLuceneSearcher:

Public Member Functions

 setType ($a_type)
 Set search type.
 getType ()
 Get type.
 search ()
 Search.
 highlight ($a_obj_ids)
 Highlight/Detail query.
 nextResultPage ()
 get next result page
 getHighlighter ()
 get highlighter
 getResult ()
 Get result.
 getPageNumber ()
 get current page number

Static Public Member Functions

static getInstance (ilLuceneQueryParser $qp)
 Get singleton instance.

Data Fields

const TYPE_STANDARD = 1
const TYPE_USER = 2

Protected Member Functions

 performSearch ()
 search lucene

Private Member Functions

 __construct ($qp)
 Constructor.

Private Attributes

 $query_parser = null
 $result = null
 $highlighter = null
 $page_number = 1
 $type = self::TYPE_STANDARD

Static Private Attributes

static $instance = null

Detailed Description

Reads and parses lucene search results.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 35 of file class.ilLuceneSearcher.php.

Constructor & Destructor Documentation

ilLuceneSearcher::__construct (   $qp)
private

Constructor.

Parameters
objectilLuceneQueryParser
Returns
ilLuceneSearcher

Definition at line 53 of file class.ilLuceneSearcher.php.

{
$this->result = new ilLuceneSearchResult();
$this->result->setCallback(array($this,'nextResultPage'));
$this->query_parser = $qp;
}

Member Function Documentation

ilLuceneSearcher::getHighlighter ( )

get highlighter

Returns

Definition at line 171 of file class.ilLuceneSearcher.php.

References $highlighter.

{
}
static ilLuceneSearcher::getInstance ( ilLuceneQueryParser  $qp)
static
ilLuceneSearcher::getPageNumber ( )

get current page number

Parameters
@return

Definition at line 195 of file class.ilLuceneSearcher.php.

References $page_number.

Referenced by performSearch().

{
}

+ Here is the caller graph for this function:

ilLuceneSearcher::getResult ( )

Get result.

Parameters
@returnilLuceneSearchResult

Definition at line 181 of file class.ilLuceneSearcher.php.

References $result.

{
if($this->result instanceof ilLuceneSearchResult)
{
return $this->result;
}
// TODO Error handling
}
ilLuceneSearcher::getType ( )

Get type.

Returns
int

Definition at line 89 of file class.ilLuceneSearcher.php.

References $type.

Referenced by performSearch().

{
return $this->type;
}

+ Here is the caller graph for this function:

ilLuceneSearcher::highlight (   $a_obj_ids)

Highlight/Detail query.

Parameters
array$a_obj_idsArry of obj_ids
Returns
object ilLuceneHighlightResultParser

Definition at line 109 of file class.ilLuceneSearcher.php.

References $highlighter, $ilBench, $ilLog, $ilSetting, $res, and ilRpcClientFactory\factory().

{
include_once './Services/Search/classes/Lucene/class.ilLuceneHighlighterResultParser.php';
// TODO error handling
if(!$this->query_parser->getQuery())
{
return;
}
// Search in combined index
$ilBench->start('Lucene','SearchHighlight');
try
{
include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
$res = ilRpcClientFactory::factory('RPCSearchHandler')->highlight(
CLIENT_ID.'_'.$ilSetting->get('inst_id',0),
$a_obj_ids,
$this->query_parser->getQuery()
);
}
{
// TODO: better error handling
$ilLog->write(__METHOD__.': '.$e->getMessage());
}
catch(Exception $e)
{
$ilLog->write(__METHOD__.': '.$e->getMessage());
}
$ilBench->stop('Lucene','SearchHighlight');
$ilBench->start('Lucene','SearchHighlightParser');
include_once './Services/Search/classes/Lucene/class.ilLuceneHighlighterResultParser.php';
$this->highlighter = new ilLuceneHighlighterResultParser();
#$GLOBALS['ilLog']->write(__METHOD__.' Result is '. $res);
$this->highlighter->setResultString($res);
$this->highlighter->parse();
$ilBench->stop('Lucene','SearchHighlightParser');
}

+ Here is the call graph for this function:

ilLuceneSearcher::nextResultPage ( )

get next result page

Parameters
@return

Definition at line 161 of file class.ilLuceneSearcher.php.

References performSearch().

{
$this->page_number++;
$this->performSearch();
}

+ Here is the call graph for this function:

ilLuceneSearcher::performSearch ( )
protected

search lucene

Returns

Definition at line 204 of file class.ilLuceneSearcher.php.

References $ilBench, $ilLog, $ilSetting, $res, ilRpcClientFactory\factory(), getPageNumber(), and getType().

Referenced by nextResultPage(), and search().

{
// TODO error handling
if(!$this->query_parser->getQuery())
{
return;
}
$ilBench->start('Lucene','SearchCombinedIndex');
try
{
switch($this->getType())
{
case self::TYPE_USER:
include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
$res = ilRpcClientFactory::factory('RPCSearchHandler')->searchUsers(
CLIENT_ID.'_'.$ilSetting->get('inst_id',0),
(string) $this->query_parser->getQuery()
);
break;
case self::TYPE_STANDARD:
default:
include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
$res = ilRpcClientFactory::factory('RPCSearchHandler')->search(
CLIENT_ID.'_'.$ilSetting->get('inst_id',0),
(string) $this->query_parser->getQuery(),
$this->getPageNumber()
);
break;
}
}
{
// TODO: better error handling
$ilBench->stop('Lucene','SearchCombinedIndex');
$ilLog->write(__METHOD__.': '.$e->getMessage());
return;
}
catch(Exception $e)
{
$ilBench->stop('Lucene','SearchCombinedIndex');
$ilLog->write(__METHOD__.': '.$e->getMessage());
return;
}
$ilBench->stop('Lucene','SearchCombinedIndex');
// Parse results
$ilBench->start('Lucene','ParseSearchResult');
include_once './Services/Search/classes/Lucene/class.ilLuceneSearchResultParser.php';
#$GLOBALS['ilLog']->write(__METHOD__.' Result is: ' . $res);
$parser->parse($this->result);
$ilBench->stop('Lucene','ParseSearchResult');
return;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLuceneSearcher::search ( )

Search.

Returns

Definition at line 99 of file class.ilLuceneSearcher.php.

References performSearch().

{
$this->performSearch();
}

+ Here is the call graph for this function:

ilLuceneSearcher::setType (   $a_type)

Set search type.

Parameters
type$a_type

Definition at line 80 of file class.ilLuceneSearcher.php.

{
$this->type = $a_type;
}

Field Documentation

ilLuceneSearcher::$highlighter = null
private

Definition at line 44 of file class.ilLuceneSearcher.php.

Referenced by getHighlighter(), and highlight().

ilLuceneSearcher::$instance = null
staticprivate

Definition at line 40 of file class.ilLuceneSearcher.php.

Referenced by getInstance().

ilLuceneSearcher::$page_number = 1
private

Definition at line 45 of file class.ilLuceneSearcher.php.

Referenced by getPageNumber().

ilLuceneSearcher::$query_parser = null
private

Definition at line 42 of file class.ilLuceneSearcher.php.

ilLuceneSearcher::$result = null
private

Definition at line 43 of file class.ilLuceneSearcher.php.

Referenced by getResult().

ilLuceneSearcher::$type = self::TYPE_STANDARD
private

Definition at line 46 of file class.ilLuceneSearcher.php.

Referenced by getType().

const ilLuceneSearcher::TYPE_STANDARD = 1

Definition at line 37 of file class.ilLuceneSearcher.php.

Referenced by ilSearchAutoComplete\getLuceneList().

const ilLuceneSearcher::TYPE_USER = 2

Definition at line 38 of file class.ilLuceneSearcher.php.

Referenced by ilLuceneUserSearchGUI\performSearch().


The documentation for this class was generated from the following file: