Files
Phraseanet/lib/Alchemy/Phrasea/SearchEngine/Elastic/AST/PrefixNode.php
Mathieu Darse dc2c9f8c7f Refactor thesaurus query build
- Look for text nodes and infer the concepts behind term using thesaurus
- Use value objects for thesaurus terms and concepts
- Pass a QueryContext holding allowed fields and locales informations when building the Elasticsearch query
- Change type hinting and name of query building method on nodes
- Remove unused method Node#isFullTextOnly()
- Move getFieldsStructure from RecordIndexer to RecordHelper for reusing field structure in SearchEngine
2015-01-20 15:05:15 +01:00

32 lines
674 B
PHP

<?php
namespace Alchemy\Phrasea\SearchEngine\Elastic\AST;
use Alchemy\Phrasea\SearchEngine\Elastic\Search\QueryContext;
class PrefixNode extends Node
{
protected $prefix;
public function __construct($prefix)
{
$this->prefix = $prefix;
}
public function buildQuery(QueryContext $context)
{
return array(
'multi_match' => array(
'fields' => $context->getLocalizedFields(),
'query' => $this->prefix,
'type' => 'phrase_prefix'
)
);
}
public function __toString()
{
return sprintf('prefix("%s")', $this->prefix);
}
}