ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilLuceneSearchResult Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilLuceneSearchResult:
+ Collaboration diagram for ilLuceneSearchResult:

Public Member Functions

 setCallback (array $a_callback)
 set search callback More...
 
 rewind ()
 Iterator rewind. More...
 
 valid ()
 Iterator valid. More...
 
 key ()
 Iterator key. More...
 
 current ()
 Iterator current. More...
 
 next ()
 Iterator next. More...
 
 getCandidates ()
 
 addObject (int $a_value, float $a_relevance=0)
 
 getRelevance (int $a_obj_id)
 
 setLimit (int $a_limit)
 
 getLimit ()
 
 setMaxScore (float $a_score)
 
 getMaxScore ()
 
 setTotalHits (int $a_hits)
 
 getTotalHits ()
 

Private Attributes

array $listener = []
 
int $position = 0
 
int $limit = 0
 
int $total_hits = 0
 
float $max_score = 0
 
array $objects = []
 
array $relevance = []
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Search result implementing iterator interface.

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

Definition at line 27 of file class.ilLuceneSearchResult.php.

Member Function Documentation

◆ addObject()

ilLuceneSearchResult::addObject ( int  $a_value,
float  $a_relevance = 0 
)

Definition at line 117 of file class.ilLuceneSearchResult.php.

Referenced by ilLuceneSearchResultParser\parse().

117  : void
118  {
119  $this->objects[] = $a_value;
120  $this->relevance[$a_value] = $a_relevance;
121  }
+ Here is the caller graph for this function:

◆ current()

ilLuceneSearchResult::current ( )

Iterator current.

Returns

Definition at line 97 of file class.ilLuceneSearchResult.php.

References $position.

98  {
99  return $this->objects[$this->position];
100  }

◆ getCandidates()

ilLuceneSearchResult::getCandidates ( )

Definition at line 112 of file class.ilLuceneSearchResult.php.

References $objects.

112  : array
113  {
114  return $this->objects;
115  }

◆ getLimit()

ilLuceneSearchResult::getLimit ( )

Definition at line 137 of file class.ilLuceneSearchResult.php.

References $limit.

Referenced by ilLuceneSearchResultParser\parse().

137  : int
138  {
139  return $this->limit;
140  }
+ Here is the caller graph for this function:

◆ getMaxScore()

ilLuceneSearchResult::getMaxScore ( )

Definition at line 148 of file class.ilLuceneSearchResult.php.

References $max_score.

Referenced by getRelevance().

148  : float
149  {
150  return $this->max_score;
151  }
+ Here is the caller graph for this function:

◆ getRelevance()

ilLuceneSearchResult::getRelevance ( int  $a_obj_id)

Definition at line 123 of file class.ilLuceneSearchResult.php.

References getMaxScore().

123  : float
124  {
125  if (!$this->getMaxScore()) {
126  return 0;
127  }
128  return isset($this->relevance[$a_obj_id]) ? $this->relevance[$a_obj_id] / $this->getMaxScore() * 100 : 0;
129  }
+ Here is the call graph for this function:

◆ getTotalHits()

ilLuceneSearchResult::getTotalHits ( )

Definition at line 158 of file class.ilLuceneSearchResult.php.

References $total_hits.

Referenced by valid().

158  : int
159  {
160  return $this->total_hits;
161  }
+ Here is the caller graph for this function:

◆ key()

ilLuceneSearchResult::key ( )

Iterator key.

Returns

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

References $position.

89  {
90  return $this->position;
91  }

◆ next()

ilLuceneSearchResult::next ( )

Iterator next.

Definition at line 105 of file class.ilLuceneSearchResult.php.

106  {
107  $this->position++;
108  }

◆ rewind()

ilLuceneSearchResult::rewind ( )

Iterator rewind.

Definition at line 56 of file class.ilLuceneSearchResult.php.

57  {
58  $this->position = 0;
59  }

◆ setCallback()

ilLuceneSearchResult::setCallback ( array  $a_callback)

set search callback

Parameters
Closure[]

Definition at line 48 of file class.ilLuceneSearchResult.php.

48  : void
49  {
50  $this->listener = $a_callback;
51  }

◆ setLimit()

ilLuceneSearchResult::setLimit ( int  $a_limit)

Definition at line 132 of file class.ilLuceneSearchResult.php.

Referenced by ilLuceneSearchResultParser\parse().

132  : void
133  {
134  $this->limit = $a_limit;
135  }
+ Here is the caller graph for this function:

◆ setMaxScore()

ilLuceneSearchResult::setMaxScore ( float  $a_score)

Definition at line 143 of file class.ilLuceneSearchResult.php.

Referenced by ilLuceneSearchResultParser\parse().

143  : void
144  {
145  $this->max_score = $a_score;
146  }
+ Here is the caller graph for this function:

◆ setTotalHits()

ilLuceneSearchResult::setTotalHits ( int  $a_hits)

Definition at line 153 of file class.ilLuceneSearchResult.php.

Referenced by ilLuceneSearchResultParser\parse().

153  : void
154  {
155  $this->total_hits = $a_hits;
156  }
+ Here is the caller graph for this function:

◆ valid()

ilLuceneSearchResult::valid ( )

Iterator valid.

Parameters

Definition at line 66 of file class.ilLuceneSearchResult.php.

References ilLoggerFactory\getLogger(), and getTotalHits().

67  {
68  if ($this->position < count($this->objects)) {
69  return true;
70  }
71  // if the number of candidates is smaller than the total number of hits
72  // get next result page
73  if (count($this->objects) < $this->getTotalHits()) {
74  ilLoggerFactory::getLogger('src')->debug("Trying to get next result page...");
75  @call_user_func($this->listener);
76  }
77  // Check again
78  if ($this->position < count($this->objects)) {
79  return true;
80  }
81  return false;
82  }
static getLogger(string $a_component_id)
Get component logger.
+ Here is the call graph for this function:

Field Documentation

◆ $limit

int ilLuceneSearchResult::$limit = 0
private

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

Referenced by getLimit().

◆ $listener

array ilLuceneSearchResult::$listener = []
private

Definition at line 32 of file class.ilLuceneSearchResult.php.

◆ $max_score

float ilLuceneSearchResult::$max_score = 0
private

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

Referenced by getMaxScore().

◆ $objects

array ilLuceneSearchResult::$objects = []
private

Definition at line 39 of file class.ilLuceneSearchResult.php.

Referenced by getCandidates().

◆ $position

int ilLuceneSearchResult::$position = 0
private

Definition at line 33 of file class.ilLuceneSearchResult.php.

Referenced by current(), and key().

◆ $relevance

array ilLuceneSearchResult::$relevance = []
private

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

◆ $total_hits

int ilLuceneSearchResult::$total_hits = 0
private

Definition at line 36 of file class.ilLuceneSearchResult.php.

Referenced by getTotalHits().


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