ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilLuceneSearcher Class Reference

Reads and parses lucene search results. More...

+ Collaboration diagram for ilLuceneSearcher:

Public Member Functions

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

Static Public Member Functions

static getInstance (ilLuceneQueryParser $qp)
 Get singleton instance. More...
 

Data Fields

const TYPE_STANDARD = 1
 
const TYPE_USER = 2
 

Protected Member Functions

 performSearch ()
 search lucene More...
 

Private Member Functions

 __construct ($qp)
 Constructor. More...
 

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

◆ __construct()

ilLuceneSearcher::__construct (   $qp)
private

Constructor.

Parameters
objectilLuceneQueryParser
Returns
ilLuceneSearcher

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

References array.

54  {
55  $this->result = new ilLuceneSearchResult();
56  $this->result->setCallback(array($this,'nextResultPage'));
57  $this->query_parser = $qp;
58  }
Search result implementing iterator interface.
Create styles array
The data for the language used.

Member Function Documentation

◆ getHighlighter()

ilLuceneSearcher::getHighlighter ( )

get highlighter

Returns
ilLuceneHighlightResultParser

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

References $highlighter.

162  {
163  return $this->highlighter;
164  }

◆ getInstance()

static ilLuceneSearcher::getInstance ( ilLuceneQueryParser  $qp)
static

Get singleton instance.

Parameters
objectilLuceneQueryParser
Returns
ilLuceneSearcher

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

Referenced by ilSearchAutoComplete\getLuceneList(), ilRepositoryObjectDetailSearch\performLuceneSearch(), ilLuceneUserSearchGUI\performSearch(), ilLuceneAdvancedSearchGUI\performSearch(), ilLuceneSearchGUI\performSearch(), ilSoapObjectAdministration\searchObjects(), ilLuceneAdvancedSearchGUI\showSavedResults(), and ilLuceneSearchGUI\showSavedResults().

68  {
69  if(self::$instance)
70  {
71  return self::$instance;
72  }
73  return self::$instance = new ilLuceneSearcher($qp);
74  }
Reads and parses lucene search results.
+ Here is the caller graph for this function:

◆ getPageNumber()

ilLuceneSearcher::getPageNumber ( )

get current page number

Parameters

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

References $page_number.

Referenced by performSearch().

186  {
187  return $this->page_number;
188  }
+ Here is the caller graph for this function:

◆ getResult()

ilLuceneSearcher::getResult ( )

Get result.

Parameters

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

References $result.

172  {
173  if($this->result instanceof ilLuceneSearchResult)
174  {
175  return $this->result;
176  }
177  // TODO Error handling
178  }
Search result implementing iterator interface.

◆ getType()

ilLuceneSearcher::getType ( )

Get type.

Returns
int

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

References $type.

Referenced by performSearch().

90  {
91  return $this->type;
92  }
+ Here is the caller graph for this function:

◆ highlight()

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, $ilSetting, $res, ilRpcClientFactory\factory(), and ilLoggerFactory\getLogger().

110  {
111  global $ilBench,$ilSetting;
112 
113  include_once './Services/Search/classes/Lucene/class.ilLuceneHighlighterResultParser.php';
114 
115  // TODO error handling
116  if(!$this->query_parser->getQuery())
117  {
118  return;
119  }
120 
121  // Search in combined index
122  $ilBench->start('Lucene','SearchHighlight');
123  try
124  {
125  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
126  $res = ilRpcClientFactory::factory('RPCSearchHandler')->highlight(
127  CLIENT_ID.'_'.$ilSetting->get('inst_id',0),
128  $a_obj_ids,
129  $this->query_parser->getQuery()
130  );
131  }
132  catch(Exception $e)
133  {
134  ilLoggerFactory::getLogger('src')->error('Highlighting failed with message: ' . $e->getMessage());
135  return new ilLuceneHighlighterResultParser();
136  }
137 
138  include_once './Services/Search/classes/Lucene/class.ilLuceneHighlighterResultParser.php';
139  $this->highlighter = new ilLuceneHighlighterResultParser();
140  $this->highlighter->setResultString($res);
141  $this->highlighter->parse();
142 
143  return $this->highlighter;
144  }
Parses result XML from lucene search highlight.
static factory($a_package, $a_timeout=0)
Creates an ilRpcClient instance to our ilServer.
global $ilSetting
Definition: privfeed.php:17
global $ilBench
Definition: ilias.php:18
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

◆ nextResultPage()

ilLuceneSearcher::nextResultPage ( )

get next result page

Parameters

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

References performSearch().

152  {
153  $this->page_number++;
154  $this->performSearch();
155  }
performSearch()
search lucene
+ Here is the call graph for this function:

◆ performSearch()

ilLuceneSearcher::performSearch ( )
protected

search lucene

Returns

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

References $ilBench, $ilSetting, $parser, $res, ilRpcClientFactory\factory(), ilLoggerFactory\getLogger(), getPageNumber(), getType(), and string.

Referenced by nextResultPage(), and search().

195  {
196  global $ilBench,$ilSetting;
197 
198  // TODO error handling
199  if(!$this->query_parser->getQuery())
200  {
201  return;
202  }
203  $ilBench->start('Lucene','SearchCombinedIndex');
204  try
205  {
206  switch($this->getType())
207  {
208 
209  case self::TYPE_USER:
210  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
211  $res = ilRpcClientFactory::factory('RPCSearchHandler')->searchUsers(
212  CLIENT_ID.'_'.$ilSetting->get('inst_id',0),
213  (string) $this->query_parser->getQuery()
214  );
215  break;
216 
217  case self::TYPE_STANDARD:
218  default:
219  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
220  $res = ilRpcClientFactory::factory('RPCSearchHandler')->search(
221  CLIENT_ID.'_'.$ilSetting->get('inst_id',0),
222  (string) $this->query_parser->getQuery(),
223  $this->getPageNumber()
224  );
225  break;
226 
227  }
228  ilLoggerFactory::getLogger('src')->debug('Searching for: ' . $this->query_parser->getQuery());
229  }
230  catch(Exception $e)
231  {
232  ilLoggerFactory::getLogger('src')->error('Searching failed with message: ' . $e->getMessage());
233  return;
234  }
235 
236  // Parse results
237  include_once './Services/Search/classes/Lucene/class.ilLuceneSearchResultParser.php';
239  $parser->parse($this->result);
240  return;
241  }
static factory($a_package, $a_timeout=0)
Creates an ilRpcClient instance to our ilServer.
Add rich text string
The name of the decorator.
getPageNumber()
get current page number
$parser
Definition: BPMN2Parser.php:24
global $ilSetting
Definition: privfeed.php:17
global $ilBench
Definition: ilias.php:18
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ search()

ilLuceneSearcher::search ( )

Search.

Returns

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

References performSearch().

100  {
101  $this->performSearch();
102  }
performSearch()
search lucene
+ Here is the call graph for this function:

◆ setType()

ilLuceneSearcher::setType (   $a_type)

Set search type.

Parameters
type$a_type

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

References $a_type.

81  {
82  $this->type = $a_type;
83  }
$a_type
Definition: workflow.php:93

Field Documentation

◆ $highlighter

ilLuceneSearcher::$highlighter = null
private

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

Referenced by getHighlighter(), and highlight().

◆ $instance

ilLuceneSearcher::$instance = null
staticprivate

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

◆ $page_number

ilLuceneSearcher::$page_number = 1
private

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

Referenced by getPageNumber().

◆ $query_parser

ilLuceneSearcher::$query_parser = null
private

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

◆ $result

ilLuceneSearcher::$result = null
private

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

Referenced by getResult().

◆ $type

ilLuceneSearcher::$type = self::TYPE_STANDARD
private

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

Referenced by getType().

◆ TYPE_STANDARD

const ilLuceneSearcher::TYPE_STANDARD = 1

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

Referenced by ilSearchAutoComplete\getLuceneList().

◆ TYPE_USER

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: