ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 156 of file class.ilLuceneSearcher.php.

References $highlighter.

157  {
158  return $this->highlighter;
159  }

◆ 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 179 of file class.ilLuceneSearcher.php.

References $page_number.

Referenced by performSearch().

180  {
181  return $this->page_number;
182  }
+ Here is the caller graph for this function:

◆ getResult()

ilLuceneSearcher::getResult ( )

Get result.

Parameters

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

References $result.

167  {
168  if ($this->result instanceof ilLuceneSearchResult) {
169  return $this->result;
170  }
171  // TODO Error handling
172  }
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 $highlighter, $ilBench, $ilSetting, $res, ilRpcClientFactory\factory(), and ilLoggerFactory\getLogger().

109  {
110  global $ilBench,$ilSetting;
111 
112  include_once './Services/Search/classes/Lucene/class.ilLuceneHighlighterResultParser.php';
113 
114  // TODO error handling
115  if (!$this->query_parser->getQuery()) {
116  return;
117  }
118 
119  // Search in combined index
120  $ilBench->start('Lucene', 'SearchHighlight');
121  try {
122  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
123  $res = ilRpcClientFactory::factory('RPCSearchHandler')->highlight(
124  CLIENT_ID . '_' . $ilSetting->get('inst_id', 0),
125  $a_obj_ids,
126  $this->query_parser->getQuery()
127  );
128  } catch (Exception $e) {
129  ilLoggerFactory::getLogger('src')->error('Highlighting failed with message: ' . $e->getMessage());
130  return new ilLuceneHighlighterResultParser();
131  }
132 
133  include_once './Services/Search/classes/Lucene/class.ilLuceneHighlighterResultParser.php';
134  $this->highlighter = new ilLuceneHighlighterResultParser();
135  $this->highlighter->setResultString($res);
136  $this->highlighter->parse();
137 
138  return $this->highlighter;
139  }
Parses result XML from lucene search highlight.
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 146 of file class.ilLuceneSearcher.php.

References performSearch().

147  {
148  $this->page_number++;
149  $this->performSearch();
150  }
performSearch()
search lucene
+ Here is the call graph for this function:

◆ performSearch()

ilLuceneSearcher::performSearch ( )
protected

search lucene

Returns

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

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

Referenced by nextResultPage(), and search().

189  {
190  global $ilBench,$ilSetting;
191 
192  // TODO error handling
193  if (!$this->query_parser->getQuery()) {
194  return;
195  }
196  $ilBench->start('Lucene', 'SearchCombinedIndex');
197  try {
198  switch ($this->getType()) {
199 
200  case self::TYPE_USER:
201  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
202  $res = ilRpcClientFactory::factory('RPCSearchHandler')->searchUsers(
203  CLIENT_ID . '_' . $ilSetting->get('inst_id', 0),
204  (string) $this->query_parser->getQuery()
205  );
206  break;
207 
208  case self::TYPE_STANDARD:
209  default:
210  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
211  $res = ilRpcClientFactory::factory('RPCSearchHandler')->search(
212  CLIENT_ID . '_' . $ilSetting->get('inst_id', 0),
213  (string) $this->query_parser->getQuery(),
214  $this->getPageNumber()
215  );
216  break;
217 
218  }
219  ilLoggerFactory::getLogger('src')->debug('Searching for: ' . $this->query_parser->getQuery());
220  } catch (Exception $e) {
221  ilLoggerFactory::getLogger('src')->error('Searching failed with message: ' . $e->getMessage());
222  return;
223  }
224 
225  // Parse results
226  include_once './Services/Search/classes/Lucene/class.ilLuceneSearchResultParser.php';
228  $parser->parse($this->result);
229  return;
230  }
Add rich text string
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: