PHP Class Isswp101\Persimmon\QueryBuilder\Filters\Filter

Exibir arquivo Open project: isswp101/elasticsearch-eloquent

Protected Properties

Property Type Description
$linkedFilters array This array contains linked instances of current filter.
$logicalOperator string But you can override it and merge them using OR (should).
$mergeType string But you can override it and merge them using OR (should).
$mode Filter mode.
$values mixed Filter values.

Public Methods

Method Description
__construct ( mixed $values = null ) Constructor.
getLinkedFilters ( ) : Filter[] Returns linked instances of current filter.
getLogicalOperator ( ) : string Returns linked filters logical operator.
getMergeType ( ) : string Returns filter merge type.
getMode ( ) : string Returns filter mode.
getValues ( ) : mixed Retuns filter values as array.
hasLinkedFilters ( ) : boolean Returns true if filter has linked filters.
isExclude ( ) : boolean Returns true if mode is exclude.
isInclude ( ) : boolean Returns true if mode is include.
isMergeTypeValid ( ) : boolean Returns true if merge type is valid.
isOff ( ) : boolean Returns true if mode is off.
makeQuery ( ) : array Returns wrapped elasticsearch filter query.
mergeQuery ( array $query ) : array Merges elastcisearch query with current filter query.
query ( mixed $values ) : array Returns the actual elasticsearch query for one filter.
setLogicalOperator ( string $logicalOperator ) Updates linked filters logical operator.
setMergeType ( string $mergeType ) Sets filter merge type.
setOptions ( string $mode = null, string $logicalOperator = null, array $linkedFilters = [] ) Set filter options.

Protected Methods

Method Description
mergeBoolQuery ( array $query1, array $query2, string $type ) : array Merges BOOL elasticsearch queries.

Method Details

__construct() public method

Constructor.
public __construct ( mixed $values = null )
$values mixed Filter values.

getLinkedFilters() public method

Returns linked instances of current filter.
public getLinkedFilters ( ) : Filter[]
return Filter[]

getLogicalOperator() public method

Returns linked filters logical operator.
public getLogicalOperator ( ) : string
return string - "AND" || "OR"

getMergeType() public method

Returns filter merge type.
public getMergeType ( ) : string
return string - "AND" || "OR"

getMode() public method

Returns filter mode.
public getMode ( ) : string
return string Can be as include, exclude or off.

getValues() public method

Retuns filter values as array.
public getValues ( ) : mixed
return mixed

hasLinkedFilters() public method

Returns true if filter has linked filters.
public hasLinkedFilters ( ) : boolean
return boolean

isExclude() public method

Returns true if mode is exclude.
public isExclude ( ) : boolean
return boolean

isInclude() public method

Returns true if mode is include.
public isInclude ( ) : boolean
return boolean

isMergeTypeValid() public method

Returns true if merge type is valid.
public isMergeTypeValid ( ) : boolean
return boolean

isOff() public method

Returns true if mode is off.
public isOff ( ) : boolean
return boolean

makeQuery() public method

{ "bool": { "should": [], "must_not": [] } }
public makeQuery ( ) : array
return array

mergeBoolQuery() protected method

Merges BOOL elasticsearch queries.
protected mergeBoolQuery ( array $query1, array $query2, string $type ) : array
$query1 array
$query2 array
$type string must, must_not, should
return array

mergeQuery() public method

Merges elastcisearch query with current filter query.
public mergeQuery ( array $query ) : array
$query array Elastcisearch query.
return array Merged elasticsearch query.

query() abstract public method

{ "term": { "price": "0" } }
abstract public query ( mixed $values ) : array
$values mixed
return array

setLogicalOperator() public method

Updates linked filters logical operator.
public setLogicalOperator ( string $logicalOperator )
$logicalOperator string - "AND" || "OR"

setMergeType() public method

Sets filter merge type.
public setMergeType ( string $mergeType )
$mergeType string - "AND" || "OR"

setOptions() public method

Set filter options.
public setOptions ( string $mode = null, string $logicalOperator = null, array $linkedFilters = [] )
$mode string
$logicalOperator string
$linkedFilters array

Property Details

$linkedFilters protected_oe property

This array contains linked instances of current filter.
protected array $linkedFilters
return array

$logicalOperator protected_oe property

But you can override it and merge them using OR (should).
protected string $logicalOperator
return string

$mergeType protected_oe property

But you can override it and merge them using OR (should).
protected string $mergeType
return string

$mode protected_oe property

Filter mode.
protected $mode

$values protected_oe property

Filter values.
protected mixed $values
return mixed