mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00

- Quoted text do not hit the thesaurus anymore - getTextNodes() was misleading, renamed to getTermNodes()
56 lines
1.2 KiB
PHP
56 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Alchemy\Phrasea\SearchEngine\Elastic\AST;
|
|
|
|
use Alchemy\Phrasea\SearchEngine\Elastic\Search\QueryContext;
|
|
use Alchemy\Phrasea\SearchEngine\Elastic\Thesaurus\Concept;
|
|
use Alchemy\Phrasea\SearchEngine\Elastic\Thesaurus\TermInterface;
|
|
|
|
abstract class AbstractTermNode extends Node implements TermInterface
|
|
{
|
|
protected $text;
|
|
protected $context;
|
|
private $concepts = array();
|
|
|
|
public function __construct($text, Context $context = null)
|
|
{
|
|
$this->text = $text;
|
|
$this->context = $context;
|
|
}
|
|
|
|
public function setConcepts(array $concepts)
|
|
{
|
|
$this->concepts = $concepts;
|
|
}
|
|
|
|
protected function buildConceptQueries(QueryContext $context)
|
|
{
|
|
$queries = array();
|
|
foreach (Concept::pruneNarrowConcepts($this->concepts) as $concept) {
|
|
$queries[]['term']['concept_paths'] = $concept->getPath();
|
|
}
|
|
|
|
return $queries;
|
|
}
|
|
|
|
public function getValue()
|
|
{
|
|
return $this->text;
|
|
}
|
|
|
|
public function hasContext()
|
|
{
|
|
return $this->context !== null;
|
|
}
|
|
|
|
public function getContext()
|
|
{
|
|
return $this->context->getValue();
|
|
}
|
|
|
|
public function getTermNodes()
|
|
{
|
|
return array($this);
|
|
}
|
|
}
|