PHP Class Sleimanx2\Plastic\DSL\SearchBuilder

Show file Open project: sleimanx2/plastic

Public Properties

Property Type Description
$index string The elastic index to query against.
$query ONGR\ElasticsearchDSL\Search An instance of DSL query.
$type string The elastic type to query against.

Protected Properties

Property Type Description
$boolState string Query bool state.
$connection Sleimanx2\Plastic\Connection An instance of plastic Connection.
$filtering boolean Query filtering state.
$model Illuminate\Database\Eloquent\Model The model to use when querying elastic search.
$modelFiller Sleimanx2\Plastic\Fillers\FillerInterface The model filler to use after retrieving the results.

Public Methods

Method Description
__construct ( Connection $connection, ONGR\ElasticsearchDSL\Search $grammar = null ) Builder constructor.
aggregate ( Closure $closure ) Add aggregation.
append ( $query ) Append a query.
commonTerm ( $field, $term, array $attributes = [] ) Add a common term query.
exists ( string | array $fields ) Add an exists query.
filter ( ) Switch to a filter query.
from ( integer $offset ) Set the query from/offset value.
fuzzy ( $field, $term, array $attributes = [] ) Add a fuzzy query.
geoBoundingBox ( string $field, array $values, array $parameters = [] ) Add a geo bounding box query.
geoDistance ( string $field, string $distance, mixed $location, array $attributes = [] ) Add a geo distance query.
geoDistanceRange ( string $field, $from, $to, array $location, array $attributes = [] ) Add a geo distance range query.
geoHash ( string $field, mixed $location, array $attributes = [] ) Add a geo hash query.
geoPolygon ( string $field, array $points = [], array $attributes = [] ) Add a geo polygon query.
get ( ) : PlasticResult Execute the search query against elastic and return the raw result if the model is not set.
getBoolState ( ) : string Return the boolean query state.
getConnection ( ) : Connection Return the current plastic connection.
getFilteringState ( ) : string Return the filtering state.
getIndex ( ) : string Return the current elastic index.
getModelFiller ( ) : Sleimanx2\Plastic\Fillers\FillerInterface get the model filler to use after retrieving the results.
getRaw ( ) : array Execute the search query against elastic and return the raw result.
getType ( ) : string Return the current elastic type.
ids ( array | string $ids ) Add an ids query.
index ( string $index ) Set the elastic index to query against.
match ( string $field, string $term, array $attributes = [] ) Add a match query.
matchAll ( float | null $boost = 1 ) Add a boost query.
minScore ( $score ) Set the query min score value.
model ( Model $model ) Set the eloquent model to use when querying elastic search.
multiMatch ( array $fields, string $term, array $attributes = [] ) Add a multi match query.
must ( ) Switch to a must statement.
mustNot ( ) Switch to a must not statement.
nested ( $field, Closure $closure, string $score_mode = 'avg' ) Add a nested query.
paginate ( integer $limit = 25 ) : PlasticPaginator Paginate result hits.
prefix ( string $field, string $term, array $attributes = [] ) Add a prefix query.
query ( ) Switch to a regular query.
queryString ( string $query, array $attributes = [] ) Add a query string query.
range ( string $field, array $attributes = [] ) Add a range query.
regexp ( string $field, $regex, array $attributes = [] ) Add a regexp query.
setModelFiller ( Sleimanx2\Plastic\Fillers\FillerInterface $filler ) Set the model filler to use after retrieving the results.
should ( ) Switch to a should statement.
simpleQueryString ( string $query, array $attributes = [] ) Add a simple query string query.
size ( integer $limit ) Set the query limit/size value.
sortBy ( string | array $fields, null $order = null, array $parameters = [] ) Set the query sort values values.
term ( string $field, string $term, array $attributes = [] ) Add an term query.
terms ( string $field, array $terms, array $attributes = [] ) Add an terms query.
toDSL ( ) : array Return the DSL query.
type ( string $type ) Set the elastic type to query against.
wildcard ( string $field, string $value, float $boost = 1 ) Add a wildcard query.

Protected Methods

Method Description
getCurrentPage ( ) : integer return the current query string value.

Method Details

__construct() public method

Builder constructor.
public __construct ( Connection $connection, ONGR\ElasticsearchDSL\Search $grammar = null )
$connection Sleimanx2\Plastic\Connection
$grammar ONGR\ElasticsearchDSL\Search

aggregate() public method

Add aggregation.
public aggregate ( Closure $closure )
$closure Closure

append() public method

Append a query.
public append ( $query )
$query

commonTerm() public method

Add a common term query.
public commonTerm ( $field, $term, array $attributes = [] )
$field
$term
$attributes array

exists() public method

Add an exists query.
public exists ( string | array $fields )
$fields string | array

filter() public method

Switch to a filter query.
public filter ( )

from() public method

Set the query from/offset value.
public from ( integer $offset )
$offset integer

fuzzy() public method

Add a fuzzy query.
public fuzzy ( $field, $term, array $attributes = [] )
$field
$term
$attributes array

geoBoundingBox() public method

Add a geo bounding box query.
public geoBoundingBox ( string $field, array $values, array $parameters = [] )
$field string
$values array
$parameters array

geoDistance() public method

Add a geo distance query.
public geoDistance ( string $field, string $distance, mixed $location, array $attributes = [] )
$field string
$distance string
$location mixed
$attributes array

geoDistanceRange() public method

Add a geo distance range query.
public geoDistanceRange ( string $field, $from, $to, array $location, array $attributes = [] )
$field string
$from
$to
$location array
$attributes array

geoHash() public method

Add a geo hash query.
public geoHash ( string $field, mixed $location, array $attributes = [] )
$field string
$location mixed
$attributes array

geoPolygon() public method

Add a geo polygon query.
public geoPolygon ( string $field, array $points = [], array $attributes = [] )
$field string
$points array
$attributes array

get() public method

Execute the search query against elastic and return the raw result if the model is not set.
public get ( ) : PlasticResult
return Sleimanx2\Plastic\PlasticResult

getBoolState() public method

Return the boolean query state.
public getBoolState ( ) : string
return string

getConnection() public method

Return the current plastic connection.
public getConnection ( ) : Connection
return Sleimanx2\Plastic\Connection

getCurrentPage() protected method

return the current query string value.
protected getCurrentPage ( ) : integer
return integer

getFilteringState() public method

Return the filtering state.
public getFilteringState ( ) : string
return string

getIndex() public method

Return the current elastic index.
public getIndex ( ) : string
return string

getModelFiller() public method

get the model filler to use after retrieving the results.
public getModelFiller ( ) : Sleimanx2\Plastic\Fillers\FillerInterface
return Sleimanx2\Plastic\Fillers\FillerInterface

getRaw() public method

Execute the search query against elastic and return the raw result.
public getRaw ( ) : array
return array

getType() public method

Return the current elastic type.
public getType ( ) : string
return string

ids() public method

Add an ids query.
public ids ( array | string $ids )
$ids array | string

index() public method

Set the elastic index to query against.
public index ( string $index )
$index string

match() public method

Add a match query.
public match ( string $field, string $term, array $attributes = [] )
$field string
$term string
$attributes array

matchAll() public method

Add a boost query.
public matchAll ( float | null $boost = 1 )
$boost float | null

minScore() public method

Set the query min score value.
public minScore ( $score )
$score

model() public method

Set the eloquent model to use when querying elastic search.
public model ( Model $model )
$model Illuminate\Database\Eloquent\Model

multiMatch() public method

Add a multi match query.
public multiMatch ( array $fields, string $term, array $attributes = [] )
$fields array
$term string
$attributes array

must() public method

Switch to a must statement.
public must ( )

mustNot() public method

Switch to a must not statement.
public mustNot ( )

nested() public method

Add a nested query.
public nested ( $field, Closure $closure, string $score_mode = 'avg' )
$field
$closure Closure
$score_mode string

paginate() public method

Paginate result hits.
public paginate ( integer $limit = 25 ) : PlasticPaginator
$limit integer
return Sleimanx2\Plastic\PlasticPaginator

prefix() public method

Add a prefix query.
public prefix ( string $field, string $term, array $attributes = [] )
$field string
$term string
$attributes array

query() public method

Switch to a regular query.
public query ( )

queryString() public method

Add a query string query.
public queryString ( string $query, array $attributes = [] )
$query string
$attributes array

range() public method

Add a range query.
public range ( string $field, array $attributes = [] )
$field string
$attributes array

regexp() public method

Add a regexp query.
public regexp ( string $field, $regex, array $attributes = [] )
$field string
$attributes array

setModelFiller() public method

Set the model filler to use after retrieving the results.
public setModelFiller ( Sleimanx2\Plastic\Fillers\FillerInterface $filler )
$filler Sleimanx2\Plastic\Fillers\FillerInterface

should() public method

Switch to a should statement.
public should ( )

simpleQueryString() public method

Add a simple query string query.
public simpleQueryString ( string $query, array $attributes = [] )
$query string
$attributes array

size() public method

Set the query limit/size value.
public size ( integer $limit )
$limit integer

sortBy() public method

Set the query sort values values.
public sortBy ( string | array $fields, null $order = null, array $parameters = [] )
$fields string | array
$order null
$parameters array

term() public method

Add an term query.
public term ( string $field, string $term, array $attributes = [] )
$field string
$term string
$attributes array

terms() public method

Add an terms query.
public terms ( string $field, array $terms, array $attributes = [] )
$field string
$terms array
$attributes array

toDSL() public method

Return the DSL query.
public toDSL ( ) : array
return array

type() public method

Set the elastic type to query against.
public type ( string $type )
$type string

wildcard() public method

Add a wildcard query.
public wildcard ( string $field, string $value, float $boost = 1 )
$field string
$value string
$boost float

Property Details

$boolState protected property

Query bool state.
protected string $boolState
return string

$connection protected property

An instance of plastic Connection.
protected Connection,Sleimanx2\Plastic $connection
return Sleimanx2\Plastic\Connection

$filtering protected property

Query filtering state.
protected bool $filtering
return boolean

$index public property

The elastic index to query against.
public string $index
return string

$model protected property

The model to use when querying elastic search.
protected Model,Illuminate\Database\Eloquent $model
return Illuminate\Database\Eloquent\Model

$modelFiller protected property

The model filler to use after retrieving the results.
protected FillerInterface,Sleimanx2\Plastic\Fillers $modelFiller
return Sleimanx2\Plastic\Fillers\FillerInterface

$query public property

An instance of DSL query.
public Search,ONGR\ElasticsearchDSL $query
return ONGR\ElasticsearchDSL\Search

$type public property

The elastic type to query against.
public string $type
return string