Files
Phraseanet/lib/Alchemy/Phrasea/SearchEngine/Elastic/AST/KeyValue/NativeKey.php
Jean-Yves Gaulier 3f785e7ba3 PHRAS-483_SHA-UID_master
add index (not analysed) & search on fields "sha256" and "uuid"
e.g. : uuid:"4d006e01-bc38-4aac-9a5b-2c90ffe3a8a2"
e.g. : sha256:a7f3ec01c4c5efcadc639d494d432006f13b28b9a576afaee4d3b7508c4be074
2018-04-26 17:35:01 +02:00

70 lines
1.5 KiB
PHP

<?php
namespace Alchemy\Phrasea\SearchEngine\Elastic\AST\KeyValue;
use Alchemy\Phrasea\SearchEngine\Elastic\Search\QueryContext;
class NativeKey implements Key
{
const TYPE_DATABASE = 'database';
const TYPE_COLLECTION = 'collection';
const TYPE_SHA256 = 'sha256';
const TYPE_UUID = 'uuid';
const TYPE_MEDIA_TYPE = 'media_type';
const TYPE_RECORD_IDENTIFIER = 'record_identifier';
private $type;
private $key;
public static function database()
{
return new self(self::TYPE_DATABASE, 'databox_name');
}
public static function collection()
{
return new self(self::TYPE_COLLECTION, 'collection_name');
}
public static function sha256()
{
return new self(self::TYPE_SHA256, 'sha256');
}
public static function uuid()
{
return new self(self::TYPE_UUID, 'uuid');
}
public static function mediaType()
{
return new self(self::TYPE_MEDIA_TYPE, 'type');
}
public static function recordIdentifier()
{
return new self(self::TYPE_RECORD_IDENTIFIER, 'record_id');
}
private function __construct($type, $key)
{
$this->type = $type;
$this->key = $key;
}
public function getIndexField(QueryContext $context, $raw = false)
{
return $this->key;
}
public function isValueCompatible($value, QueryContext $context)
{
return true;
}
public function __toString()
{
return $this->type;
}
}