Documentation

SearchTerm
in package

Describes a single search condition.

Provides mappings to SQL queries and REST request parameters.

Tags
author

zozlak

Table of Contents

Constants

COLUMN_STRING  = 'value'
DATETIME_REGEX  = '/^-?[0-9]{4,}-[0-9][0-9]-[0-9][0-9](T[0-9][0-9](:[0-9][0-9])?(:[0-9][0-9])?([.][0-9]+)?Z?)?$/'
OPERATOR_IN  = 'in'
PROPERTY_BINARY  = 'BINARY'
PROPERTY_NEGATE  = '^'
STRING_MAX_LENGTH  = 1000
TYPE_DATE  = 'date'
TYPE_DATETIME  = 'datetime'
TYPE_FTS  = 'fts'
TYPE_ID  = 'id'
TYPE_NUMBER  = 'number'
TYPE_RELATION  = 'relation'
TYPE_SPATIAL  = 'spatial'
TYPE_STRING  = 'string'
URI_REGEX  = '\\w+:(\\/?\\/?)[^\\s]+'

Properties

$language  : string|null
Language to be matched by the RDF triple
$operator  : string|null
Operator to be used for the RDF triple value comparison.
$property  : array<string|int, string>
Property to be matched by the RDF triple.
$type  : string|null
Data type to be matched by the RDF triple.
$value  : array<string|int, scalar>
Value to be matched by the RDF triple (with a given operator)
$operators  : array<string, string|null>
List of operators and data types they enforce
$typesToColumns  : array<string, string>

Methods

__construct()  : mixed
Creates a search term object.
factory()  : SearchTerm
Creates an instance of the SearchTerm class from a given $_POST vars set
getFormData()  : string
Returns the search term formatted as an HTTP query string.
getSqlQuery()  : QueryPart
Returns an SQL query part returning ids of resources matching the search term.
getSqlQueryFts()  : QueryPart
getSqlQueryId()  : QueryPart
getSqlQueryMeta()  : QueryPart
getSqlQueryOr()  : QueryPart
getSqlQuerySpatial()  : QueryPart
getSqlQueryUri()  : QueryPart

Constants

COLUMN_STRING

public mixed COLUMN_STRING = 'value'

DATETIME_REGEX

public mixed DATETIME_REGEX = '/^-?[0-9]{4,}-[0-9][0-9]-[0-9][0-9](T[0-9][0-9](:[0-9][0-9])?(:[0-9][0-9])?([.][0-9]+)?Z?)?$/'

PROPERTY_BINARY

public mixed PROPERTY_BINARY = 'BINARY'

PROPERTY_NEGATE

public mixed PROPERTY_NEGATE = '^'

STRING_MAX_LENGTH

public mixed STRING_MAX_LENGTH = 1000

TYPE_DATETIME

public mixed TYPE_DATETIME = 'datetime'

TYPE_RELATION

public mixed TYPE_RELATION = 'relation'

TYPE_SPATIAL

public mixed TYPE_SPATIAL = 'spatial'

URI_REGEX

public mixed URI_REGEX = '\\w+:(\\/?\\/?)[^\\s]+'

Properties

$language

Language to be matched by the RDF triple

public string|null $language

$operator

Operator to be used for the RDF triple value comparison.

public string|null $operator

One of =, <, <=, >, >=, ~ (regular expresion match), @@ (full text search match),

Tags
see
SearchTerm::$value

$property

Property to be matched by the RDF triple.

public array<string|int, string> $property

| string

$type

Data type to be matched by the RDF triple.

public string|null $type

Should be one of main XSD data types or one of TYPE_... constants defined by this class.

$value

Value to be matched by the RDF triple (with a given operator)

public array<string|int, scalar> $value

| string | int | float | bool

Tags
see
SearchTerm::$operator

$operators

List of operators and data types they enforce

private static array<string, string|null> $operators = ['=' => null, '>' => null, '<' => null, '<=' => null, '>=' => null, '~' => self::TYPE_STRING, '@@' => self::TYPE_FTS, '&&' => self::TYPE_SPATIAL, '&>' => self::TYPE_SPATIAL, '&<' => self::TYPE_SPATIAL]

$typesToColumns

private static array<string, string> $typesToColumns = [\zozlak\RdfConstants::XSD_STRING => 'value', \zozlak\RdfConstants::XSD_BOOLEAN => 'value_n', \zozlak\RdfConstants::XSD_DECIMAL => 'value_n', \zozlak\RdfConstants::XSD_FLOAT => 'value_n', \zozlak\RdfConstants::XSD_DOUBLE => 'value_n', \zozlak\RdfConstants::XSD_DURATION => 'value', \zozlak\RdfConstants::XSD_DATE_TIME => 'value_t', \zozlak\RdfConstants::XSD_TIME => 'value_t::time', \zozlak\RdfConstants::XSD_DATE => 'value_t::date', \zozlak\RdfConstants::XSD_HEX_BINARY => 'value', \zozlak\RdfConstants::XSD_BASE64_BINARY => 'value', \zozlak\RdfConstants::XSD_ANY_URI => 'value', \zozlak\RdfConstants::RDFS_RESOURCE => 'ids', self::TYPE_DATE => 'value_t::date', self::TYPE_DATETIME => 'value_t', self::TYPE_NUMBER => 'value_n', self::TYPE_STRING => 'value', self::TYPE_RELATION => 'ids', self::TYPE_ID => 'id']

Methods

__construct()

Creates a search term object.

public __construct([array<string|int, string>|string|null $property = null ][, array<string|int, scalar>|scalar|null $value = null ][, string $operator = '=' ][, string|null $type = null ][, string|null $language = null ]) : mixed
Parameters
$property : array<string|int, string>|string|null = null

property to be matched by the RDF triple if prefixed with a self::PROPERTY_NEGATE, the rdfs:resource $type is enforced and the $value is evaluated against the triple subject (instead of object)

$value : array<string|int, scalar>|scalar|null = null

value to be matched by the RDF triple (with a given operator)

$operator : string = '='

operator used to compare the RDF triple value

$type : string|null = null

value to be matched by the RDF triple (one of base XSD types or one of TYPE_... constants defined by this class)

$language : string|null = null

language to be matched by the RDF triple

factory()

Creates an instance of the SearchTerm class from a given $_POST vars set

public static factory(int $key) : SearchTerm
Parameters
$key : int
Return values
SearchTerm

getFormData()

Returns the search term formatted as an HTTP query string.

public getFormData([int $n = 0 ]) : string
Parameters
$n : int = 0

term number. It's required for propert serialization of multi-property and multi-values search terms.

Return values
string

getSqlQuery()

Returns an SQL query part returning ids of resources matching the search term.

public getSqlQuery(string $baseUrl, string $idProp, array<string|int, string> $nonRelationProperties) : QueryPart
Parameters
$baseUrl : string

repository base URL

$idProp : string

RDF property denoting identifiers

$nonRelationProperties : array<string|int, string>

list of properties which are internally stored only as literals, even if they are resources in the RDF graph

Return values
QueryPart

getSqlQueryFts()

private getSqlQueryFts() : QueryPart
Return values
QueryPart

getSqlQueryId()

private getSqlQueryId() : QueryPart
Return values
QueryPart

getSqlQueryMeta()

private getSqlQueryMeta(string $type, string $baseUrl, string $idProp) : QueryPart
Parameters
$type : string
$baseUrl : string
$idProp : string
Return values
QueryPart

getSqlQueryOr()

private getSqlQueryOr(string $baseUrl, string $idProp, array<string|int, string> $nonRelationProperties) : QueryPart
Parameters
$baseUrl : string
$idProp : string
$nonRelationProperties : array<string|int, string>
Return values
QueryPart

getSqlQuerySpatial()

private getSqlQuerySpatial() : QueryPart
Return values
QueryPart

getSqlQueryUri()

private getSqlQueryUri(string $property) : QueryPart
Parameters
$property : string
Return values
QueryPart

        
On this page

Search results