ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilLuceneSearchResult Class Reference

Search result implementing iterator interface. More...

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

Public Member Functions

 __construct ()
 Constructor.
 setCallback ($a_callback)
 set search callback
 rewind ()
 Iterator rewind.
 valid ()
 Iterator valid.
 key ()
 Iterator key.
 current ()
 Iterator current.
 next ()
 Iterator next.
 getCandidates ()
 get candidates
 addObject ($a_value, $a_relevance=0)
 Add object entry.
 getRelevance ($a_obj_id)
 get relevance
 setLimit ($a_limit)
 getLimit ()
 setMaxScore ($a_score)
 getMaxScore ()
 setTotalHits ($a_hits)
 set total hits
 getTotalHits ()
 get total hits

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

ilLuceneSearchResult::__construct ( )

Constructor.

Parameters
stringsearch result
Returns

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

{
}

Member Function Documentation

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().

{
$this->objects[] = $a_value;
$this->relevance[$a_value] = $a_relevance;
}

+ Here is the caller graph for this function:

ilLuceneSearchResult::current ( )

Iterator current.

Returns

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

References $position.

{
return $this->objects[$this->position];
}
ilLuceneSearchResult::getCandidates ( )

get candidates

Parameters
@return

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

{
return $this->objects ? $this->objects : array();
}
ilLuceneSearchResult::getLimit ( )
Parameters
@return

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

References $limit.

Referenced by ilLuceneSearchResultParser\parse().

{
return $this->limit;
}

+ Here is the caller graph for this function:

ilLuceneSearchResult::getMaxScore ( )
Parameters
@return

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

References $max_score.

Referenced by getRelevance().

{
}

+ Here is the caller graph for this function:

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().

{
if(!$this->getMaxScore())
{
return 0;
}
return isset($this->relevance[$a_obj_id]) ? $this->relevance[$a_obj_id] / $this->getMaxScore() * 100 : 0;
}

+ Here is the call graph for this function:

ilLuceneSearchResult::getTotalHits ( )

get total hits

Parameters
@return

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

References $total_hits.

Referenced by valid().

{
}

+ Here is the caller graph for this function:

ilLuceneSearchResult::key ( )

Iterator key.

Returns

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

References $position.

{
return $this->position;
}
ilLuceneSearchResult::next ( )

Iterator next.

Returns

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

{
$this->position++;
}
ilLuceneSearchResult::rewind ( )

Iterator rewind.

Returns

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

{
$this->position = 0;
}
ilLuceneSearchResult::setCallback (   $a_callback)

set search callback

Parameters
@return

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

{
$this->listener = $a_callback;
}
ilLuceneSearchResult::setLimit (   $a_limit)
Parameters
@return

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

Referenced by ilLuceneSearchResultParser\parse().

{
$this->limit = $a_limit;
}

+ Here is the caller graph for this function:

ilLuceneSearchResult::setMaxScore (   $a_score)
Parameters
@return

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

Referenced by ilLuceneSearchResultParser\parse().

{
$this->max_score = $a_score;
}

+ Here is the caller graph for this function:

ilLuceneSearchResult::setTotalHits (   $a_hits)

set total hits

Returns

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

Referenced by ilLuceneSearchResultParser\parse().

{
$this->total_hits = $a_hits;
}

+ Here is the caller graph for this function:

ilLuceneSearchResult::valid ( )

Iterator valid.

Parameters
@return

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

References $ilLog, and getTotalHits().

{
global $ilLog;
$ilLog->write(__METHOD__.': Iterator valid called '. count($this->objects).' '. $this->position);
if($this->position < count($this->objects))
{
return true;
}
// if the number of candidates is smaller than the total number of hits
// get next result page
if(count($this->objects) < $this->getTotalHits())
{
$ilLog->write("Trying to get next result page...");
@call_user_func($this->listener);
}
// Check again
if($this->position < count($this->objects))
{
return true;
}
return false;
}

+ Here is the call graph for this function:

Field Documentation

ilLuceneSearchResult::$limit = 0
private

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

Referenced by getLimit().

ilLuceneSearchResult::$listener
private

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

ilLuceneSearchResult::$max_score = 0
private

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

Referenced by getMaxScore().

ilLuceneSearchResult::$objects
private

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

ilLuceneSearchResult::$position = 0
private

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

Referenced by current(), and key().

ilLuceneSearchResult::$relevance
private

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

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: