ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
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 150 of file class.ilLuceneSearchResult.php.

Referenced by ilLuceneSearchResultParser\parse().

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

◆ current()

ilLuceneSearchResult::current ( )

Iterator current.

Returns

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

References $position.

118  {
119  return $this->objects[$this->position];
120  }

◆ getCandidates()

ilLuceneSearchResult::getCandidates ( )

get candidates

Parameters

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

139  {
140  return $this->objects ? $this->objects : array();
141  }

◆ getLimit()

ilLuceneSearchResult::getLimit ( )
Parameters

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

References $limit.

Referenced by ilLuceneSearchResultParser\parse().

187  {
188  return $this->limit;
189  }
+ Here is the caller graph for this function:

◆ getMaxScore()

ilLuceneSearchResult::getMaxScore ( )
Parameters

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

References $max_score.

Referenced by getRelevance().

208  {
209  return $this->max_score;
210  }
+ 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 161 of file class.ilLuceneSearchResult.php.

References getMaxScore().

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

◆ getTotalHits()

ilLuceneSearchResult::getTotalHits ( )

get total hits

Parameters

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

References $total_hits.

Referenced by valid().

227  {
228  return $this->total_hits;
229  }
+ Here is the caller graph for this function:

◆ key()

ilLuceneSearchResult::key ( )

Iterator key.

Returns

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

References $position.

109  {
110  return $this->position;
111  }

◆ next()

ilLuceneSearchResult::next ( )

Iterator next.

Returns

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

127  {
128  $this->position++;
129  }

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

Referenced by ilLuceneSearchResultParser\parse().

177  {
178  $this->limit = $a_limit;
179  }
+ Here is the caller graph for this function:

◆ setMaxScore()

ilLuceneSearchResult::setMaxScore (   $a_score)
Parameters

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

Referenced by ilLuceneSearchResultParser\parse().

198  {
199  $this->max_score = $a_score;
200  }
+ Here is the caller graph for this function:

◆ setTotalHits()

ilLuceneSearchResult::setTotalHits (   $a_hits)

set total hits

Returns

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

Referenced by ilLuceneSearchResultParser\parse().

217  {
218  $this->total_hits = $a_hits;
219  }
+ Here is the caller graph for this function:

◆ valid()

ilLuceneSearchResult::valid ( )

Iterator valid.

Parameters

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

References $ilLog, and getTotalHits().

81  {
82  global $ilLog;
83 
84  $ilLog->write(__METHOD__.': Iterator valid called '. count($this->objects).' '. $this->position);
85  if($this->position < count($this->objects))
86  {
87  return true;
88  }
89  // if the number of candidates is smaller than the total number of hits
90  // get next result page
91  if(count($this->objects) < $this->getTotalHits())
92  {
93  $ilLog->write("Trying to get next result page...");
94  @call_user_func($this->listener);
95  }
96  // Check again
97  if($this->position < count($this->objects))
98  {
99  return true;
100  }
101  return false;
102  }
+ 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: