ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLuceneSearchResultParser.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 private string $xml;
29
33 public function __construct(string $a_xml)
34 {
35 $this->xml = $a_xml;
36 }
37
38
44 public function getXML(): string
45 {
46 return $this->xml;
47 }
48
53 {
54 if (!strlen($this->getXML())) {
55 return $result;
56 }
57 $hits = new SimpleXMLElement($this->getXML());
58 $result->setLimit($result->getLimit() + (int) ((string) $hits['limit']));
59 $result->setMaxScore((float) $hits['maxScore']);
60 $result->setTotalHits((int) $hits['totalHits']);
61
62 foreach ($hits->children() as $object) {
63 if (isset($object['absoluteScore'])) {
64 $result->addObject((int) $object['id'], (float) $object['absoluteScore']);
65 } else {
66 $result->addObject((int) $object['id'], (float) $object->Item[0]['absoluteScore']);
67 }
68 }
69 return $result;
70 }
71}
parse(ilLuceneSearchResult $result)
Parse XML.
Search result implementing iterator interface.
addObject(int $a_value, float $a_relevance=0)