meilisearch/Classes/Domain/Search/ResultSet/Result/SearchResult.php

243 lines
4.9 KiB
PHP
Raw Permalink Normal View History

2021-04-17 00:26:33 +02:00
<?php
namespace WapplerSystems\Meilisearch\Domain\Search\ResultSet\Result;
/***************************************************************
* Copyright notice
*
* (c) 2015-2016 Timo Schmidt <timo.schmidt@dkd.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\Grouping\GroupItem;
2021-04-17 21:20:54 +02:00
use WapplerSystems\Meilisearch\System\Meilisearch\Document\Document;
2021-04-17 00:26:33 +02:00
/**
2021-04-17 21:20:54 +02:00
* Meilisearch document class that should be used in the frontend in the search context.
2021-04-17 00:26:33 +02:00
*
* @author Timo Schmidt <timo.schmidt@dkd.de>
*/
class SearchResult extends Document
{
/**
* The variant field value
*
2021-04-17 21:20:54 +02:00
* Value of Meilisearch collapse field, which is defined via
2021-04-17 00:26:33 +02:00
* TypoScript variable "variants.variantField"
*
* @var string
*/
protected $variantFieldValue = '';
/**
* Number of variants found
*
* May differ from documents in variants as
* returned variants are limited by expand.rows
*
* @var int
*/
protected $variantsNumFound = 0;
/**
* @var SearchResult[]
*/
protected $variants = [];
/**
* Indicates if an instance of this document is a variant (a sub document of another).
*
* @var bool
*/
protected $isVariant = false;
/**
* References the parent document of the document is a variant.
*
* @var SearchResult|null
*/
protected $variantParent = null;
/**
* @var GroupItem
*/
protected $groupItem = null;
/**
* @return GroupItem
*/
public function getGroupItem(): GroupItem
{
return $this->groupItem;
}
/**
* @return bool
*/
public function getHasGroupItem()
{
return $this->groupItem !== null;
}
/**
* @param GroupItem $group
*/
public function setGroupItem(GroupItem $group)
{
$this->groupItem = $group;
}
/**
* @return string
*/
public function getVariantFieldValue(): string
{
return $this->variantFieldValue;
}
/**
* @param string $variantFieldValue
*/
public function setVariantFieldValue(string $variantFieldValue)
{
$this->variantFieldValue = $variantFieldValue;
}
/**
* @return int
*/
public function getVariantsNumFound(): int
{
return $this->variantsNumFound;
}
/**
* @param int $numFound
*/
public function setVariantsNumFound(int $numFound)
{
$this->variantsNumFound = $numFound;
}
/**
* @return SearchResult[]
*/
public function getVariants()
{
return $this->variants;
}
/**
* @param SearchResult $expandedResult
*/
public function addVariant(SearchResult $expandedResult)
{
$this->variants[] = $expandedResult;
}
/**
* @return bool
*/
public function getIsVariant()
{
return $this->isVariant;
}
/**
* @param bool $isVariant
*/
public function setIsVariant($isVariant)
{
$this->isVariant = $isVariant;
}
/**
* @return SearchResult
*/
public function getVariantParent()
{
return $this->variantParent;
}
/**
* @param SearchResult $variantParent
*/
public function setVariantParent(SearchResult $variantParent)
{
$this->variantParent = $variantParent;
}
/**
* @return string
*/
public function getContent()
{
return $this->fields['content'];
}
/**
* @return boolean
*/
public function getIsElevated()
{
return $this->fields['isElevated'];
}
/**
* @return string
*/
public function getType()
{
return $this->fields['type'];
}
/**
* @return integer
*/
public function getId()
{
return $this->fields['id'];
}
/**
* @return float
*/
public function getScore()
{
return $this->fields['score'];
}
/**
* @return string
*/
public function getUrl()
{
return $this->fields['url'];
}
/**
* @return string
*/
public function getTitle()
{
return $this->fields['title'];
}
}