ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 147 of file class.ilLuceneSearchResult.php.

Referenced by ilLuceneSearchResultParser\parse().

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

◆ current()

ilLuceneSearchResult::current ( )

Iterator current.

Returns

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

References $position.

115  {
116  return $this->objects[$this->position];
117  }

◆ getCandidates()

ilLuceneSearchResult::getCandidates ( )

get candidates

Parameters

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

References array.

136  {
137  return $this->objects ? $this->objects : array();
138  }
Create styles array
The data for the language used.

◆ getLimit()

ilLuceneSearchResult::getLimit ( )
Parameters

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

References $limit.

Referenced by ilLuceneSearchResultParser\parse().

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

◆ getMaxScore()

ilLuceneSearchResult::getMaxScore ( )
Parameters

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

References $max_score.

Referenced by getRelevance().

205  {
206  return $this->max_score;
207  }
+ 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 158 of file class.ilLuceneSearchResult.php.

References getMaxScore().

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

◆ getTotalHits()

ilLuceneSearchResult::getTotalHits ( )

get total hits

Parameters

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

References $total_hits.

Referenced by valid().

224  {
225  return $this->total_hits;
226  }
+ Here is the caller graph for this function:

◆ key()

ilLuceneSearchResult::key ( )

Iterator key.

Returns

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

References $position.

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

◆ next()

ilLuceneSearchResult::next ( )

Iterator next.

Returns

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

124  {
125  $this->position++;
126  }

◆ 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 173 of file class.ilLuceneSearchResult.php.

Referenced by ilLuceneSearchResultParser\parse().

174  {
175  $this->limit = $a_limit;
176  }
+ Here is the caller graph for this function:

◆ setMaxScore()

ilLuceneSearchResult::setMaxScore (   $a_score)
Parameters

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

Referenced by ilLuceneSearchResultParser\parse().

195  {
196  $this->max_score = $a_score;
197  }
+ Here is the caller graph for this function:

◆ setTotalHits()

ilLuceneSearchResult::setTotalHits (   $a_hits)

set total hits

Returns

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

Referenced by ilLuceneSearchResultParser\parse().

214  {
215  $this->total_hits = $a_hits;
216  }
+ 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  {
84  return true;
85  }
86  // if the number of candidates is smaller than the total number of hits
87  // get next result page
88  if(count($this->objects) < $this->getTotalHits())
89  {
90  ilLoggerFactory::getLogger('src')->debug("Trying to get next result page...");
91  @call_user_func($this->listener);
92  }
93  // Check again
94  if($this->position < count($this->objects))
95  {
96  return true;
97  }
98  return false;
99  }
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.

◆ $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: