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

Parses Lucene search results. More...

+ Collaboration diagram for ilLuceneSearchResultParser:

Public Member Functions

 __construct ($a_xml)
 Constructor. More...
 
 getXML ()
 get xml More...
 
 parse (ilLuceneSearchResult $result)
 Parse XML. More...
 

Private Attributes

 $xml
 

Detailed Description

Parses Lucene search results.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilLuceneSearchResultParser::__construct (   $a_xml)

Constructor.

Parameters
stringsearch result
Returns

Definition at line 42 of file class.ilLuceneSearchResultParser.php.

43  {
44  $this->xml = $a_xml;
45  }

Member Function Documentation

◆ getXML()

ilLuceneSearchResultParser::getXML ( )

get xml

Parameters

Definition at line 53 of file class.ilLuceneSearchResultParser.php.

References $xml.

Referenced by parse().

+ Here is the caller graph for this function:

◆ parse()

ilLuceneSearchResultParser::parse ( ilLuceneSearchResult  $result)

Parse XML.

Parameters
objectilLuceneSearchResult
Returns

Definition at line 63 of file class.ilLuceneSearchResultParser.php.

References $result, ilLuceneSearchResult\addObject(), ilLuceneSearchResult\getLimit(), getXML(), ilLuceneSearchResult\setLimit(), ilLuceneSearchResult\setMaxScore(), and ilLuceneSearchResult\setTotalHits().

64  {
65  if (!strlen($this->getXML())) {
66  return $result;
67  }
68  $hits = new SimpleXMLElement($this->getXML());
69  $result->setLimit($result->getLimit() + (int) ((string) $hits['limit']));
70  $result->setMaxScore((string) $hits['maxScore']);
71  $result->setTotalHits((string) $hits['totalHits']);
72 
73  foreach ($hits->children() as $object) {
74  if (isset($object['absoluteScore'])) {
75  $result->addObject((string) $object['id'], (float) $object['absoluteScore']);
76  } else {
77  $result->addObject((string) $object['id'], (float) $object->Item[0]['absoluteScore']);
78  }
79  }
80  return $result;
81  }
$result
setTotalHits($a_hits)
set total hits
addObject($a_value, $a_relevance=0)
Add object entry.
+ Here is the call graph for this function:

Field Documentation

◆ $xml

ilLuceneSearchResultParser::$xml
private

Definition at line 35 of file class.ilLuceneSearchResultParser.php.

Referenced by getXML().


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