ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilLuceneSearchResult Class Reference

Search result implementing iterator interface. More...

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

Public Member Functions

 __construct ()
 Constructor. More...
 
 setCallback ($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 ()
 get candidates More...
 
 addObject ($a_value, $a_relevance=0)
 Add object entry. More...
 
 getRelevance ($a_obj_id)
 get relevance More...
 
 setLimit ($a_limit)
 
 getLimit ()
 
 setMaxScore ($a_score)
 
 getMaxScore ()
 
 setTotalHits ($a_hits)
 set total hits More...
 
 getTotalHits ()
 get total hits More...
 

Private Attributes

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

Detailed Description

Search result implementing iterator interface.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilLuceneSearchResult::__construct ( )

Constructor.

Parameters
stringsearch result
Returns

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

53  {
54  }

Member Function Documentation

◆ addObject()

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

Add object entry.

Parameters
intkey
intvalue
Returns

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

Referenced by ilLuceneSearchResultParser\parse().

145  {
146  $this->objects[] = $a_value;
147  $this->relevance[$a_value] = $a_relevance;
148  }
+ Here is the caller graph for this function:

◆ current()

ilLuceneSearchResult::current ( )

Iterator current.

Returns

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

References $position.

112  {
113  return $this->objects[$this->position];
114  }

◆ getCandidates()

ilLuceneSearchResult::getCandidates ( )

get candidates

Parameters

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

References $objects.

133  {
134  return $this->objects;
135  }

◆ getLimit()

ilLuceneSearchResult::getLimit ( )
Parameters

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

References $limit.

Referenced by ilLuceneSearchResultParser\parse().

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

◆ getMaxScore()

ilLuceneSearchResult::getMaxScore ( )
Parameters

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

References $max_score.

Referenced by getRelevance().

201  {
202  return $this->max_score;
203  }
+ Here is the caller graph for this function:

◆ getRelevance()

ilLuceneSearchResult::getRelevance (   $a_obj_id)

get relevance

Parameters
intobj_id
Returns
int relevance in percent

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

References getMaxScore().

156  {
157  if (!$this->getMaxScore()) {
158  return 0;
159  }
160  return isset($this->relevance[$a_obj_id]) ? $this->relevance[$a_obj_id] / $this->getMaxScore() * 100 : 0;
161  }
+ Here is the call graph for this function:

◆ getTotalHits()

ilLuceneSearchResult::getTotalHits ( )

get total hits

Parameters

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

References $total_hits.

Referenced by valid().

220  {
221  return $this->total_hits;
222  }
+ Here is the caller graph for this function:

◆ key()

ilLuceneSearchResult::key ( )

Iterator key.

Returns

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

References $position.

103  {
104  return $this->position;
105  }

◆ next()

ilLuceneSearchResult::next ( )

Iterator next.

Returns

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

121  {
122  $this->position++;
123  }

◆ rewind()

ilLuceneSearchResult::rewind ( )

Iterator rewind.

Returns

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

71  {
72  $this->position = 0;
73  }

◆ setCallback()

ilLuceneSearchResult::setCallback (   $a_callback)

set search callback

Parameters

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

62  {
63  $this->listener = $a_callback;
64  }

◆ setLimit()

ilLuceneSearchResult::setLimit (   $a_limit)
Parameters

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

Referenced by ilLuceneSearchResultParser\parse().

170  {
171  $this->limit = $a_limit;
172  }
+ Here is the caller graph for this function:

◆ setMaxScore()

ilLuceneSearchResult::setMaxScore (   $a_score)
Parameters

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

Referenced by ilLuceneSearchResultParser\parse().

191  {
192  $this->max_score = $a_score;
193  }
+ Here is the caller graph for this function:

◆ setTotalHits()

ilLuceneSearchResult::setTotalHits (   $a_hits)

set total hits

Returns

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

Referenced by ilLuceneSearchResultParser\parse().

210  {
211  $this->total_hits = $a_hits;
212  }
+ Here is the caller graph for this function:

◆ valid()

ilLuceneSearchResult::valid ( )

Iterator valid.

Parameters

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

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

81  {
82  if ($this->position < count($this->objects)) {
83  return true;
84  }
85  // if the number of candidates is smaller than the total number of hits
86  // get next result page
87  if (count($this->objects) < $this->getTotalHits()) {
88  ilLoggerFactory::getLogger('src')->debug("Trying to get next result page...");
89  @call_user_func($this->listener);
90  }
91  // Check again
92  if ($this->position < count($this->objects)) {
93  return true;
94  }
95  return false;
96  }
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

Field Documentation

◆ $limit

ilLuceneSearchResult::$limit = 0
private

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

Referenced by getLimit().

◆ $listener

ilLuceneSearchResult::$listener
private

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

◆ $max_score

ilLuceneSearchResult::$max_score = 0
private

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

Referenced by getMaxScore().

◆ $objects

ilLuceneSearchResult::$objects = []
private

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

Referenced by getCandidates().

◆ $position

ilLuceneSearchResult::$position = 0
private

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

Referenced by current(), and key().

◆ $relevance

ilLuceneSearchResult::$relevance
private

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

◆ $total_hits

ilLuceneSearchResult::$total_hits = 0
private

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

Referenced by getTotalHits().


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