QueryBuilder
in package
Table of Contents
Constants
- GEO_FILTER_UNITS = ['m', 'km', 'mi', 'ft']
Properties
- $geoFilters : array<string|int, mixed>
- $highlight : string|null
- $language : string|null
- $numericFilters : array<string|int, mixed>
- $offset : int|null
- $options : array<string|int, mixed>
- $pageSize : int|null
- $payload : string|null
- $query : string
- $return : string|null
- $scorer : string|null
- $sortByField : string|null
- $sortOrder : string
- $summarize : string|null
- $tagFilters : array<string|int, mixed>
- $indexName : string
- $redis : Redis
Methods
- __construct() : mixed
- geoFilter() : self
- Add a geo-spatial filter.
- highlight() : self
- Add highlighting to specific fields.
- limit() : self
- Set result limits for pagination.
- noContent() : self
- noStopWords() : self
- numericFilter() : self
- Add a numeric range filter.
- query() : self
- Set the query string for full-text search.
- returnFields() : self
- Add fields to return in the result.
- search() : SearchResult
- Execute the query.
- sortBy() : self
- Add sorting.
- summarize() : self
- Add summarization to specific fields.
- tagFilter() : self
- Add a tag filter for exact matches.
- withScores() : self
- Add RedisSearch-specific directives.
- buildSearchCommand() : array<string|int, mixed>
- Build the Redis command arguments dynamically.
Constants
GEO_FILTER_UNITS
private
mixed
GEO_FILTER_UNITS
= ['m', 'km', 'mi', 'ft']
Properties
$geoFilters
protected
array<string|int, mixed>
$geoFilters
= []
$highlight
protected
string|null
$highlight
= null
$language
protected
string|null
$language
= null
$numericFilters
protected
array<string|int, mixed>
$numericFilters
= []
$offset
protected
int|null
$offset
= null
$options
protected
array<string|int, mixed>
$options
= []
$pageSize
protected
int|null
$pageSize
= null
$payload
protected
string|null
$payload
= null
$query
protected
string
$query
= '*'
$return
protected
string|null
$return
= null
$scorer
protected
string|null
$scorer
= null
$sortByField
protected
string|null
$sortByField
= null
$sortOrder
protected
string
$sortOrder
= 'ASC'
$summarize
protected
string|null
$summarize
= null
$tagFilters
protected
array<string|int, mixed>
$tagFilters
= []
$indexName
private
string
$indexName
$redis
private
Redis
$redis
Methods
__construct()
public
__construct(Redis $redis, string $indexName) : mixed
Parameters
- $redis : Redis
- $indexName : string
geoFilter()
Add a geo-spatial filter.
public
geoFilter(string $field, float $lon, float $lat, float $radius[, string $unit = 'km' ]) : self
Parameters
- $field : string
- $lon : float
- $lat : float
- $radius : float
- $unit : string = 'km'
Return values
selfhighlight()
Add highlighting to specific fields.
public
highlight(array<string|int, mixed> $fields[, string $openTag = '<strong>' ][, string $closeTag = '</strong>' ]) : self
Parameters
- $fields : array<string|int, mixed>
- $openTag : string = '<strong>'
- $closeTag : string = '</strong>'
Return values
selflimit()
Set result limits for pagination.
public
limit(int $offset[, int $pageSize = 10 ]) : self
Parameters
- $offset : int
- $pageSize : int = 10
Return values
selfnoContent()
public
noContent() : self
Return values
selfnoStopWords()
public
noStopWords() : self
Return values
selfnumericFilter()
Add a numeric range filter.
public
numericFilter(string $field, float|int $min[, float|int|null $max = null ]) : self
Parameters
- $field : string
- $min : float|int
- $max : float|int|null = null
Return values
selfquery()
Set the query string for full-text search.
public
query(string $query) : self
Parameters
- $query : string
Return values
selfreturnFields()
Add fields to return in the result.
public
returnFields(array<string|int, mixed> $fields) : self
Parameters
- $fields : array<string|int, mixed>
Return values
selfsearch()
Execute the query.
public
search() : SearchResult
Return values
SearchResultsortBy()
Add sorting.
public
sortBy(string $field[, string $order = 'ASC' ]) : self
Parameters
- $field : string
- $order : string = 'ASC'
Return values
selfsummarize()
Add summarization to specific fields.
public
summarize(array<string|int, mixed> $fields[, int $fragments = 3 ][, int $length = 50 ][, string $separator = '...' ]) : self
Parameters
- $fields : array<string|int, mixed>
- $fragments : int = 3
- $length : int = 50
- $separator : string = '...'
Return values
selftagFilter()
Add a tag filter for exact matches.
public
tagFilter(string $field, array<string|int, mixed> $values) : self
Parameters
- $field : string
- $values : array<string|int, mixed>
Return values
selfwithScores()
Add RedisSearch-specific directives.
public
withScores() : self
Return values
selfbuildSearchCommand()
Build the Redis command arguments dynamically.
private
buildSearchCommand() : array<string|int, mixed>