ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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.

54  {
55  $this->result = new ilLuceneSearchResult();
56  $this->result->setCallback(array($this,'nextResultPage'));
57  $this->query_parser = $qp;
58  }
Search result implementing iterator interface.

Member Function Documentation

◆ getHighlighter()

ilLuceneSearcher::getHighlighter ( )

get highlighter

Returns
ilLuceneHighlightResultParser

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

References $highlighter.

160  {
161  return $this->highlighter;
162  }

◆ 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  return self::$instance;
71  }
72  return self::$instance = new ilLuceneSearcher($qp);
73  }
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 182 of file class.ilLuceneSearcher.php.

References $page_number.

Referenced by performSearch().

183  {
184  return $this->page_number;
185  }
+ Here is the caller graph for this function:

◆ getResult()

ilLuceneSearcher::getResult ( )

Get result.

Parameters

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

References $result.

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

◆ getType()

ilLuceneSearcher::getType ( )

Get type.

Returns
int

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

References $type.

Referenced by performSearch().

89  {
90  return $this->type;
91  }
+ 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 108 of file class.ilLuceneSearcher.php.

References $DIC, $highlighter, $ilBench, $ilSetting, $res, ilRpcClientFactory\factory(), and ilLoggerFactory\getLogger().

109  {
110  global $DIC;
111 
112  $ilBench = $DIC['ilBench'];
113  $ilSetting = $DIC['ilSetting'];
114 
115  include_once './Services/Search/classes/Lucene/class.ilLuceneHighlighterResultParser.php';
116 
117  // TODO error handling
118  if (!$this->query_parser->getQuery()) {
119  return;
120  }
121 
122  // Search in combined index
123  $ilBench->start('Lucene', 'SearchHighlight');
124  try {
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  } catch (Exception $e) {
132  ilLoggerFactory::getLogger('src')->error('Highlighting failed with message: ' . $e->getMessage());
133  return new ilLuceneHighlighterResultParser();
134  }
135 
136  include_once './Services/Search/classes/Lucene/class.ilLuceneHighlighterResultParser.php';
137  $this->highlighter = new ilLuceneHighlighterResultParser();
138  $this->highlighter->setResultString($res);
139  $this->highlighter->parse();
140 
141  return $this->highlighter;
142  }
Parses result XML from lucene search highlight.
global $DIC
Definition: saml.php:7
static factory($a_package, $a_timeout=0)
Creates an ilRpcClient instance to our ilServer.
foreach($_POST as $key=> $value) $res
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 149 of file class.ilLuceneSearcher.php.

References performSearch().

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

◆ performSearch()

ilLuceneSearcher::performSearch ( )
protected

search lucene

Returns

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

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

Referenced by nextResultPage(), and search().

192  {
193  global $DIC;
194 
195  $ilBench = $DIC['ilBench'];
196  $ilSetting = $DIC['ilSetting'];
197 
198  // TODO error handling
199  if (!$this->query_parser->getQuery()) {
200  return;
201  }
202  $ilBench->start('Lucene', 'SearchCombinedIndex');
203  try {
204  switch ($this->getType()) {
205 
206  case self::TYPE_USER:
207  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
208  $res = ilRpcClientFactory::factory('RPCSearchHandler')->searchUsers(
209  CLIENT_ID . '_' . $ilSetting->get('inst_id', 0),
210  (string) $this->query_parser->getQuery()
211  );
212  break;
213 
214  case self::TYPE_STANDARD:
215  default:
216  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
217  $res = ilRpcClientFactory::factory('RPCSearchHandler')->search(
218  CLIENT_ID . '_' . $ilSetting->get('inst_id', 0),
219  (string) $this->query_parser->getQuery(),
220  $this->getPageNumber()
221  );
222  break;
223 
224  }
225  ilLoggerFactory::getLogger('src')->debug('Searching for: ' . $this->query_parser->getQuery());
226  } catch (Exception $e) {
227  ilLoggerFactory::getLogger('src')->error('Searching failed with message: ' . $e->getMessage());
228  return;
229  }
230 
231  // Parse results
232  include_once './Services/Search/classes/Lucene/class.ilLuceneSearchResultParser.php';
234  $parser->parse($this->result);
235  return;
236  }
global $DIC
Definition: saml.php:7
static factory($a_package, $a_timeout=0)
Creates an ilRpcClient instance to our ilServer.
foreach($_POST as $key=> $value) $res
getPageNumber()
get current page number
$parser
Definition: BPMN2Parser.php:23
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 98 of file class.ilLuceneSearcher.php.

References performSearch().

99  {
100  $this->performSearch();
101  }
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 79 of file class.ilLuceneSearcher.php.

References $a_type.

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

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: