ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilLuceneSearchResult Class Reference

Search result implementing iterator interface. 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

Search result implementing iterator interface.

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

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

Member Function Documentation

◆ addObject()

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

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

Referenced by ilLuceneSearchResultParser\parse().

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

◆ current()

ilLuceneSearchResult::current ( )

Iterator current.

Returns

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

References $position.

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

◆ getCandidates()

ilLuceneSearchResult::getCandidates ( )

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

References $objects.

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

◆ getLimit()

ilLuceneSearchResult::getLimit ( )

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

References $limit.

Referenced by ilLuceneSearchResultParser\parse().

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

◆ getMaxScore()

ilLuceneSearchResult::getMaxScore ( )

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

References $max_score.

Referenced by getRelevance().

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

◆ getRelevance()

ilLuceneSearchResult::getRelevance ( int  $a_obj_id)

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

References getMaxScore().

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

◆ getTotalHits()

ilLuceneSearchResult::getTotalHits ( )

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

References $total_hits.

Referenced by valid().

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

◆ key()

ilLuceneSearchResult::key ( )

Iterator key.

Returns

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

References $position.

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

◆ next()

ilLuceneSearchResult::next ( )

Iterator next.

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

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

◆ rewind()

ilLuceneSearchResult::rewind ( )

Iterator rewind.

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

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

◆ setCallback()

ilLuceneSearchResult::setCallback ( array  $a_callback)

set search callback

Parameters
Closure[]

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

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

◆ setLimit()

ilLuceneSearchResult::setLimit ( int  $a_limit)

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

Referenced by ilLuceneSearchResultParser\parse().

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

◆ setMaxScore()

ilLuceneSearchResult::setMaxScore ( float  $a_score)

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

Referenced by ilLuceneSearchResultParser\parse().

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

◆ setTotalHits()

ilLuceneSearchResult::setTotalHits ( int  $a_hits)

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

Referenced by ilLuceneSearchResultParser\parse().

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

◆ valid()

ilLuceneSearchResult::valid ( )

Iterator valid.

Parameters

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

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

67  : bool
68  {
69  if ($this->position < count($this->objects)) {
70  return true;
71  }
72  // if the number of candidates is smaller than the total number of hits
73  // get next result page
74  if (count($this->objects) < $this->getTotalHits()) {
75  ilLoggerFactory::getLogger('src')->debug("Trying to get next result page...");
76  @call_user_func($this->listener);
77  }
78  // Check again
79  if ($this->position < count($this->objects)) {
80  return true;
81  }
82  return false;
83  }
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 36 of file class.ilLuceneSearchResult.php.

Referenced by getLimit().

◆ $listener

array ilLuceneSearchResult::$listener = []
private

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

◆ $max_score

float ilLuceneSearchResult::$max_score = 0
private

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

Referenced by getMaxScore().

◆ $objects

array ilLuceneSearchResult::$objects = []
private

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

Referenced by getCandidates().

◆ $position

int ilLuceneSearchResult::$position = 0
private

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

Referenced by current(), and key().

◆ $relevance

array ilLuceneSearchResult::$relevance = []
private

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

◆ $total_hits

int ilLuceneSearchResult::$total_hits = 0
private

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

Referenced by getTotalHits().


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