Manager
extends ContainerAwareObject
in package
Search Manager
Table of Contents
Constants
- INDEX_NAME = 'sitebase_index'
- MAX_ELEMENTS_PER_QUERY = 10000
- RESULTS_PER_PAGE = 10
- SUMMARIZE_MAX_WORDS = 50
Properties
- $translators : array<string|int, mixed>
- $aggregations : array<string|int, mixed>|null
- $client : Client|null
- $container : ContainerInterface
- $index : string|null
- $query : string|array<string|int, mixed>|null
- $sort : array<string|int, mixed>|null
- $source : array<string|int, mixed>|null
Methods
- __call() : mixed
- Handles dynamic method calls to the Elasticsearch client.
- __construct() : mixed
- constructor
- addAggregation() : static
- Adds an aggregation
- addAndCondition() : static
- Adds a condition for the "filter" clause of the Elasticsearch query.
- addGenericCondition() : static
- Adds a generic condition to the query with a specified boolean type.
- addNotCondition() : static
- Adds a condition for the "must_not" clause of the Elasticsearch query.
- addOrCondition() : static
- Adds a condition for the "should" clause of the Elasticsearch query.
- addSort() : static
- Adds sorting to the query.
- buildAggregation() : array<string|int, mixed>
- Builds an aggregation.
- bulkIndexData() : array<string|int, mixed>
- Indexes multiple data items in bulk.
- checkService() : bool
- Checks elasticsearch service
- clientInfo() : array<string|int, mixed>
- Retrieves information about the Elasticsearch client.
- containerCall() : mixed
- call method through container
- containerMake() : mixed
- create object through container
- continueScroll() : array<string|int, mixed>
- Continues scroll search
- continueSearchAggregateDate() : array<string|int, mixed>
- Continues aggregation search. only composite aggregations can be continued
- countAll() : int
- Counts the total number of documents matching the current query.
- dropIndex() : static
- Drops the elasticsearch index
- ensureIndex() : bool
- Ensures the Elasticsearch index exists, creating it if necessary.
- flushIndex() : array<string|int, mixed>
- Flushes all data in the Elasticsearch index.
- getApp() : App
- gets app object
- getApplicationLogger() : Manager
- gets application_logger service
- getAppRouteInfo() : RouteInfo|null
- gets route info
- getAppWebsite() : Website|null
- gets current website
- getAssets() : Manager
- gets assets manager
- getCache() : Manager
- get cache manager
- getContainer() : ContainerInterface
- gets container object
- getCrudRouter() : Crud
- gets crud service
- getDb() : Database
- gets db object
- getDebugbar() : StandardDebugBar
- gets debugbar object
- getEnv() : mixed
- gets env variable
- getEventManager() : SharedEventEmitter
- gets events manager service
- getGoogleAuthenticator() : PHPGangsta_GoogleAuthenticator
- gets google authenticator service
- getGuzzle() : Client
- gets guzzle service
- getHtmlRenderer() : HtmlPartsRenderer
- gets html renderer service
- getIcons() : Icons
- gets icons service
- getImagine() : Imagine
- gets imagine service
- getIndexDataForFrontendModel() : array<string|int, mixed>
- Prepares data from a frontend model to be indexed in Elasticsearch.
- getLog() : Logger
- gets log object
- getMailer() : Mailer
- gets mailer service
- getPdo() : PDO
- gets PDO object
- getQuery() : string|array<string|int, mixed>|null
- Gets the current query.
- getRedis() : Manager
- gets redis service
- getRequest() : Request
- gets current request object
- getRouters() : array<string|int, mixed>
- gets routers
- getSchema() : Schema
- gets schema object
- getSearch() : Manager
- gets search service
- getSearchParams() : array<string|int, mixed>
- Returns Search Params array
- getSesMailer() : SesClient
- gets SES mailer service
- getSiteData() : SiteData
- gets site data service
- getSmtpMailer() : Swift_Mailer
- gets SMTP mailer service
- getSort() : array<string|int, mixed>|null
- Gets sorting array
- getTemplates() : Engine
- gets plates engine object
- getTranslator() : Translator
- gets translator
- getUtils() : Globals
- gets global utils service
- getWebhooksRouter() : Webhooks
- gets webhooks service
- getWebRouter() : Web
- gets routing service
- getZip() : Zip
- gets zip service
- indexData() : array<string|int, mixed>
- Indexes data into Elasticsearch.
- indexFrontendCollection() : array<string|int, mixed>
- indexes a frontend objects collection
- indexFrontendModel() : array<string|int, mixed>
- indexes a frontend object
- isEnabled() : bool
- Checks if Elasticsearch is enabled.
- requestUrl() : string|bool
- executes an http request
- resetAggregations() : static
- Resets aggregations
- resetQuery() : static
- Resets the query to null.
- resetSort() : static
- Resets the sorting for the query.
- searchAggregatedData() : array<string|int, mixed>
- return aggregated data
- searchData() : array<string|int, mixed>
- Performs a search query on the Elasticsearch index.
- setQuery() : static
- Sets a query.
- setSort() : static
- Sets sorting array
- setSource() : static
- Sets source part for search query
- addCondition() : static
- Adds a condition to the query.
- buildAndGroup() : array<string|int, mixed>
- Builds an AND group for Elasticsearch queries.
- buildCondition() : array<string|int, mixed>
- Build a condition for an Elasticsearch query based on a field and its value.
- buildNestedCondition() : array<string|int, mixed>
- Builds a nested condition for an Elasticsearch/OpenSearch query.
- buildNotGroup() : array<string|int, mixed>
- Builds a NOT group for Elasticsearch queries.
- buildOrGroup() : array<string|int, mixed>
- Builds an OR group for Elasticsearch queries.
- buildScriptCondition() : array<string|int, mixed>
- Builds a script-based condition for Elasticsearch queries.
- getAdjustedBoolType() : string
- Adjusts the boolean type of a condition based on its contents.
- getAggregationsArray() : array<string|int, mixed>
- returns aggregations array
- getClient() : Client
- Retrieves the Elasticsearch client instance.
- getIndexName() : string
- Returns index name
- getQueryArray() : array<string|int, mixed>
- Converts the query into an array format.
- getService() : mixed
- gets registered service
- getSource() : array<string|int, mixed>|null
- Gets source part for search query
- isRangeValue() : bool
- Checks if a value is a range value (from and to).
- isSpatialValue() : bool
- Checks if a value is a spatial value (latitude and longitude).
- normalizeAggregationsResults() : array<string|int, mixed>
- Normalizes the aggregation results from OpenSearch into a structured and simplified format.
- parseCondition() : array<string|int, mixed>
- Parses a condition and determines whether it should be processed as a normal or script condition.
- setIndexName() : static
- Sets index name
Constants
INDEX_NAME
public
mixed
INDEX_NAME
= 'sitebase_index'
MAX_ELEMENTS_PER_QUERY
public
mixed
MAX_ELEMENTS_PER_QUERY
= 10000
RESULTS_PER_PAGE
public
mixed
RESULTS_PER_PAGE
= 10
SUMMARIZE_MAX_WORDS
public
mixed
SUMMARIZE_MAX_WORDS
= 50
Properties
$translators
public
static array<string|int, mixed>
$translators
= []
translators
$aggregations
protected
array<string|int, mixed>|null
$aggregations
= null
$client
protected
Client|null
$client
= null
$container
protected
ContainerInterface
$container
$index
protected
string|null
$index
= null
$query
protected
string|array<string|int, mixed>|null
$query
= null
$sort
protected
array<string|int, mixed>|null
$sort
= null
$source
protected
array<string|int, mixed>|null
$source
= null
Methods
__call()
Handles dynamic method calls to the Elasticsearch client.
public
__call(string $name, mixed $arguments) : mixed
Parameters
- $name : string
-
The name of the method being called.
- $arguments : mixed
-
The arguments passed to the method.
Return values
mixed —The result of the method call.
__construct()
constructor
public
__construct(ContainerInterface $container) : mixed
Parameters
- $container : ContainerInterface
addAggregation()
Adds an aggregation
public
addAggregation(string $name, array<string|int, mixed> $aggregation) : static
Parameters
- $name : string
-
Aggregation name
- $aggregation : array<string|int, mixed>
-
Aggregation definition
Return values
static —Returns the current instance.
addAndCondition()
Adds a condition for the "filter" clause of the Elasticsearch query.
public
addAndCondition(string|array<string|int, mixed> $field[, mixed $value = null ]) : static
Parameters
- $field : string|array<string|int, mixed>
-
The field to apply the condition to. if field parameter is an array, its value will be parsed as a condition and value parameter is ignored
- $value : mixed = null
-
The value to match.
Return values
static —Returns the current instance.
addGenericCondition()
Adds a generic condition to the query with a specified boolean type.
public
addGenericCondition(array<string|int, mixed> $condition, string $boolType) : static
Parameters
- $condition : array<string|int, mixed>
-
The condition to add.
- $boolType : string
-
The boolean type ('filter', 'must', 'must_not', 'should').
Return values
static —Returns the current instance.
addNotCondition()
Adds a condition for the "must_not" clause of the Elasticsearch query.
public
addNotCondition(string|array<string|int, mixed> $field[, mixed $value = null ]) : static
Parameters
- $field : string|array<string|int, mixed>
-
The field to apply the condition to. if field parameter is an array, its value will be parsed as a condition and value parameter is ignored
- $value : mixed = null
-
The value to exclude.
Return values
static —Returns the current instance.
addOrCondition()
Adds a condition for the "should" clause of the Elasticsearch query.
public
addOrCondition(string|array<string|int, mixed> $field[, mixed $value = null ]) : static
Parameters
- $field : string|array<string|int, mixed>
-
The field to apply the condition to. if field parameter is an array, its value will be parsed as a condition and value parameter is ignored
- $value : mixed = null
-
The value to match.
Return values
static —Returns the current instance.
addSort()
Adds sorting to the query.
public
addSort(string $field[, string $order = 'asc' ][, array<string|int, mixed> $additionalSortParams = [] ]) : static
Parameters
- $field : string
-
The field to sort by.
- $order : string = 'asc'
-
The order of sorting ('asc' or 'desc').
- $additionalSortParams : array<string|int, mixed> = []
-
additional parameters
Tags
Return values
static —Returns the current instance.
buildAggregation()
Builds an aggregation.
public
buildAggregation(string $type[, string|array<string|int, mixed>|null $fields = null ][, string|null $script = null ][, array<string|int, mixed>|null $scriptParams = null ]) : array<string|int, mixed>
Parameters
- $type : string
-
Type of aggregation (eg. "terms", "avg", "sum", "min", "max", "value_count", "cardinality")
- $fields : string|array<string|int, mixed>|null = null
-
Field(s) to aggregeate on
- $script : string|null = null
-
Optional script for aggregation
- $scriptParams : array<string|int, mixed>|null = null
Return values
array<string|int, mixed> —Aggregation definition
bulkIndexData()
Indexes multiple data items in bulk.
public
bulkIndexData(array<string|int, mixed> $items) : array<string|int, mixed>
Parameters
- $items : array<string|int, mixed>
-
An array of items to index, each containing '_id' and '_data' keys.
Tags
Return values
array<string|int, mixed> —The response from Elasticsearch after the bulk indexing operation.
checkService()
Checks elasticsearch service
public
checkService() : bool
Return values
boolclientInfo()
Retrieves information about the Elasticsearch client.
public
clientInfo() : array<string|int, mixed>
Return values
array<string|int, mixed> —The information returned by the Elasticsearch client.
containerCall()
call method through container
public
containerCall(callable $callable[, array<string|int, mixed> $arguments = [] ]) : mixed
Parameters
- $callable : callable
- $arguments : array<string|int, mixed> = []
containerMake()
create object through container
public
containerMake(string $className[, array<string|int, mixed> $arguments = [] ]) : mixed
Parameters
- $className : string
- $arguments : array<string|int, mixed> = []
continueScroll()
Continues scroll search
public
continueScroll(string $scrollId) : array<string|int, mixed>
Parameters
- $scrollId : string
Return values
array<string|int, mixed> —An array containing the total count, the documents found and scroll_id.
continueSearchAggregateDate()
Continues aggregation search. only composite aggregations can be continued
public
continueSearchAggregateDate(string $aggregationName, mixed $after) : array<string|int, mixed>
Parameters
- $aggregationName : string
- $after : mixed
Return values
array<string|int, mixed> —An array containing the total count, the documents found and scroll_id.
countAll()
Counts the total number of documents matching the current query.
public
countAll([string|null $aggregationName = null ][, mixed $recursionLevel = 0 ]) : int
Parameters
- $aggregationName : string|null = null
- $recursionLevel : mixed = 0
Return values
int —The count of documents matching the query.
dropIndex()
Drops the elasticsearch index
public
dropIndex() : static
Return values
staticensureIndex()
Ensures the Elasticsearch index exists, creating it if necessary.
public
ensureIndex() : bool
Return values
bool —Returns true if the index exists or was created successfully, otherwise false.
flushIndex()
Flushes all data in the Elasticsearch index.
public
flushIndex() : array<string|int, mixed>
Return values
array<string|int, mixed> —The response from Elasticsearch after flushing the index.
getApp()
gets app object
public
getApp() : App
Tags
Return values
AppgetApplicationLogger()
gets application_logger service
public
getApplicationLogger() : Manager
Tags
Return values
ManagergetAppRouteInfo()
gets route info
public
getAppRouteInfo() : RouteInfo|null
Return values
RouteInfo|nullgetAppWebsite()
gets current website
public
getAppWebsite() : Website|null
Return values
Website|nullgetAssets()
gets assets manager
public
getAssets() : Manager
Tags
Return values
ManagergetCache()
get cache manager
public
getCache() : Manager
Tags
Return values
ManagergetContainer()
gets container object
public
getContainer() : ContainerInterface
Return values
ContainerInterfacegetCrudRouter()
gets crud service
public
getCrudRouter() : Crud
Tags
Return values
CrudgetDb()
gets db object
public
getDb() : Database
Tags
Return values
DatabasegetDebugbar()
gets debugbar object
public
getDebugbar() : StandardDebugBar
Tags
Return values
StandardDebugBargetEnv()
gets env variable
public
getEnv(string $variable[, mixed $default = null ]) : mixed
Parameters
- $variable : string
- $default : mixed = null
Tags
getEventManager()
gets events manager service
public
getEventManager() : SharedEventEmitter
Tags
Return values
SharedEventEmittergetGoogleAuthenticator()
gets google authenticator service
public
getGoogleAuthenticator() : PHPGangsta_GoogleAuthenticator
Tags
Return values
PHPGangsta_GoogleAuthenticatorgetGuzzle()
gets guzzle service
public
getGuzzle() : Client
Tags
Return values
ClientgetHtmlRenderer()
gets html renderer service
public
getHtmlRenderer() : HtmlPartsRenderer
Tags
Return values
HtmlPartsRenderergetIcons()
gets icons service
public
getIcons() : Icons
Tags
Return values
IconsgetImagine()
gets imagine service
public
getImagine() : Imagine
Tags
Return values
ImaginegetIndexDataForFrontendModel()
Prepares data from a frontend model to be indexed in Elasticsearch.
public
getIndexDataForFrontendModel(FrontendModel $object) : array<string|int, mixed>
Parameters
- $object : FrontendModel
-
The model instance containing the data to index.
Return values
array<string|int, mixed> —The data to be indexed.
getLog()
gets log object
public
getLog() : Logger
Tags
Return values
LoggergetMailer()
gets mailer service
public
getMailer() : Mailer
Tags
Return values
MailergetPdo()
gets PDO object
public
getPdo() : PDO
Tags
Return values
PDOgetQuery()
Gets the current query.
public
getQuery() : string|array<string|int, mixed>|null
Return values
string|array<string|int, mixed>|null —The current query, or null if no query is set.
getRedis()
gets redis service
public
getRedis() : Manager
Tags
Return values
ManagergetRequest()
gets current request object
public
getRequest() : Request
Tags
Return values
RequestgetRouters()
gets routers
public
getRouters() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getSchema()
gets schema object
public
getSchema() : Schema
Tags
Return values
SchemagetSearch()
gets search service
public
getSearch() : Manager
Tags
Return values
ManagergetSearchParams()
Returns Search Params array
public
getSearchParams([int $page = 0 ][, int $pageSize = self::RESULTS_PER_PAGE ][, bool $onlyAggregations = false ][, bool $withScroll = false ]) : array<string|int, mixed>
Parameters
- $page : int = 0
-
The page number to retrieve.
- $pageSize : int = self::RESULTS_PER_PAGE
-
The number of results per page.
- $onlyAggregations : bool = false
-
Return only aggregations
- $withScroll : bool = false
-
Use Scroll api
Return values
array<string|int, mixed>getSesMailer()
gets SES mailer service
public
getSesMailer() : SesClient
Tags
Return values
SesClientgetSiteData()
gets site data service
public
getSiteData() : SiteData
Tags
Return values
SiteDatagetSmtpMailer()
gets SMTP mailer service
public
getSmtpMailer() : Swift_Mailer
Tags
Return values
Swift_MailergetSort()
Gets sorting array
public
getSort() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|nullgetTemplates()
gets plates engine object
public
getTemplates() : Engine
Tags
Return values
EnginegetTranslator()
gets translator
public
getTranslator([string|null $locale_code = null ]) : Translator
Parameters
- $locale_code : string|null = null
Tags
Return values
TranslatorgetUtils()
gets global utils service
public
getUtils() : Globals
Tags
Return values
GlobalsgetWebhooksRouter()
gets webhooks service
public
getWebhooksRouter() : Webhooks
Tags
Return values
WebhooksgetWebRouter()
gets routing service
public
getWebRouter() : Web
Tags
Return values
WebgetZip()
gets zip service
public
getZip() : Zip
Tags
Return values
ZipindexData()
Indexes data into Elasticsearch.
public
indexData(string $idx, array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
- $idx : string
-
The index ID.
- $data : array<string|int, mixed>
-
The data to index.
Return values
array<string|int, mixed> —The response from Elasticsearch after indexing.
indexFrontendCollection()
indexes a frontend objects collection
public
indexFrontendCollection(BaseCollection $collection) : array<string|int, mixed>
Parameters
- $collection : BaseCollection
-
collection to index
Return values
array<string|int, mixed> —The response from Elasticsearch after indexing.
indexFrontendModel()
indexes a frontend object
public
indexFrontendModel(FrontendModel $object) : array<string|int, mixed>
Parameters
- $object : FrontendModel
-
object to index
Return values
array<string|int, mixed> —The response from Elasticsearch after indexing.
isEnabled()
Checks if Elasticsearch is enabled.
public
isEnabled() : bool
Return values
bool —Returns true if Elasticsearch is enabled, otherwise false.
requestUrl()
executes an http request
public
requestUrl(string $url[, string $method = 'GET' ][, array<string|int, mixed> $options = [] ]) : string|bool
Parameters
- $url : string
- $method : string = 'GET'
- $options : array<string|int, mixed> = []
Tags
Return values
string|boolresetAggregations()
Resets aggregations
public
resetAggregations() : static
Return values
static —Returns the current instance.
resetQuery()
Resets the query to null.
public
resetQuery() : static
Return values
static —Returns the current instance.
resetSort()
Resets the sorting for the query.
public
resetSort() : static
Return values
static —Returns the current instance.
searchAggregatedData()
return aggregated data
public
searchAggregatedData() : array<string|int, mixed>
Return values
array<string|int, mixed>searchData()
Performs a search query on the Elasticsearch index.
public
searchData([int $page = 0 ][, int $pageSize = self::RESULTS_PER_PAGE ][, bool $onlyAggregations = false ][, bool $withScroll = false ]) : array<string|int, mixed>
Parameters
- $page : int = 0
-
The page number to retrieve.
- $pageSize : int = self::RESULTS_PER_PAGE
-
The number of results per page.
- $onlyAggregations : bool = false
-
Return only aggregations
- $withScroll : bool = false
-
Use Scroll api
Return values
array<string|int, mixed> —An array containing the total count, the documents found and scroll_id if used, if aggregations are used, returns aggragations array
setQuery()
Sets a query.
public
setQuery(string|array<string|int, mixed> $query) : static
Parameters
- $query : string|array<string|int, mixed>
-
The query to set.
Tags
Return values
static —Returns the current instance.
setSort()
Sets sorting array
public
setSort(array<string|int, mixed> $sort) : static
Parameters
- $sort : array<string|int, mixed>
-
Sort array
Return values
staticsetSource()
Sets source part for search query
public
setSource(array<string|int, mixed> $source) : static
Parameters
- $source : array<string|int, mixed>
Return values
staticaddCondition()
Adds a condition to the query.
protected
addCondition(string $field, mixed $value, string $boolType) : static
Parameters
- $field : string
-
The field to apply the condition to.
- $value : mixed
-
The value to match.
- $boolType : string
-
The boolean type ('filter', 'must', 'must_not', 'should').
Return values
static —Returns the current instance.
buildAndGroup()
Builds an AND group for Elasticsearch queries.
protected
buildAndGroup(array<string|int, mixed> $conditions) : array<string|int, mixed>
Each condition must be an array in the format: ['field' => '<field_name>', 'value' => 'a valid value for $value in buildCondition'] or a script condition array returned by buildScriptCondition().
Parameters
- $conditions : array<string|int, mixed>
-
Array of conditions to be combined with AND.
Return values
array<string|int, mixed> —The Elasticsearch AND condition array.
buildCondition()
Build a condition for an Elasticsearch query based on a field and its value.
protected
buildCondition(string $field, mixed $value) : array<string|int, mixed>
The $value
can have different formats depending on the type of query to be built:
-
Array:
-
Spatial Queries: If
$value
is an array containinglat
,lon
, anddistance
, a geo_distance query is built. -
Bounding Box: If
$value
containstop_left
andbottom_right
(both of which must be spatial values), a geo_bounding_box query is built. -
Terms Query: If
$value
is an array of scalars, a terms query is built.
-
Spatial Queries: If
-
String:
-
:isNull
: A query to match documents where the field does not exist. -
:isNotNull
: A query to match documents where the field exists. -
:range(min-max)
: A range query where the field value must fall within the specifiedmin
andmax
range. -
:lte(value)
: A range query where the field value must be less than or equal to the specifiedvalue
. -
:gte(value)
: A range query where the field value must be greater than or equal to the specifiedvalue
. -
prefix(value%)
: A prefix query for values that begin withvalue
. -
wildcard(%value%)
: A wildcard query for values matching the patternvalue
, with%
as a wildcard character. -
:fuzzy|value
: A fuzzy query for a term with a tolerance for misspellings or variations. -
:match|value
: A match query for exact or analyzed text search.
-
-
Other types (e.g., integers, booleans):
- A term query is built for the field and the exact value.
Parameters
- $field : string
-
The field to build the condition for.
- $value : mixed
-
The value that will be used in the condition. The type and structure of
$value
determine the type of query to build.
Tags
Return values
array<string|int, mixed> —The Elasticsearch query condition for the field.
buildNestedCondition()
Builds a nested condition for an Elasticsearch/OpenSearch query.
protected
buildNestedCondition(string $field, mixed $value) : array<string|int, mixed>
If the specified field contains a dot (.), it is treated as a nested field,
and a "nested" query is constructed. If the field is not nested, the condition
is delegated to buildCondition()
.
Parameters
- $field : string
-
The field name, potentially nested (e.g., "user.address.city").
- $value : mixed
-
The value to be used for the condition.
Return values
array<string|int, mixed> —The array structure representing the nested query.
buildNotGroup()
Builds a NOT group for Elasticsearch queries.
protected
buildNotGroup(array<string|int, mixed> $conditions) : array<string|int, mixed>
Each condition must be an array in the format: ['field' => '<field_name>', 'value' => 'a valid value for $value in buildCondition'] or a script condition array returned by buildScriptCondition().
Parameters
- $conditions : array<string|int, mixed>
-
Array of conditions to be negated.
Return values
array<string|int, mixed> —The Elasticsearch NOT condition array.
buildOrGroup()
Builds an OR group for Elasticsearch queries.
protected
buildOrGroup(array<string|int, mixed> $conditions) : array<string|int, mixed>
Each condition must be an array in the format: ['field' => '<field_name>', 'value' => 'a valid value for $value in buildCondition'] or a script condition array returned by buildScriptCondition().
Parameters
- $conditions : array<string|int, mixed>
-
Array of conditions to be combined with OR.
Return values
array<string|int, mixed> —The Elasticsearch OR condition array.
buildScriptCondition()
Builds a script-based condition for Elasticsearch queries.
protected
buildScriptCondition(string $script[, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $script : string
-
The script source code.
- $params : array<string|int, mixed> = []
-
Optional parameters for the script.
Return values
array<string|int, mixed> —The Elasticsearch script condition array.
getAdjustedBoolType()
Adjusts the boolean type of a condition based on its contents.
protected
getAdjustedBoolType(string $boolType, array<string|int, mixed> $condition) : string
Parameters
- $boolType : string
-
The boolean type ('filter', 'must', 'must_not', 'should').
- $condition : array<string|int, mixed>
-
The condition to adjust.
Tags
Return values
string —The adjusted boolean type.
getAggregationsArray()
returns aggregations array
protected
getAggregationsArray() : array<string|int, mixed>
Return values
array<string|int, mixed>getClient()
Retrieves the Elasticsearch client instance.
protected
getClient() : Client
Return values
Client —Returns an instance of the Elasticsearch client.
getIndexName()
Returns index name
protected
getIndexName() : string
Return values
string —index name
getQueryArray()
Converts the query into an array format.
protected
getQueryArray() : array<string|int, mixed>
Return values
array<string|int, mixed> —Returns the query as an array.
getService()
gets registered service
protected
getService(string $service_key) : mixed
Parameters
- $service_key : string
Tags
getSource()
Gets source part for search query
protected
getSource() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|nullisRangeValue()
Checks if a value is a range value (from and to).
protected
isRangeValue(mixed $value) : bool
Parameters
- $value : mixed
-
The value to check.
Return values
bool —Returns true if the value is a valid range value, otherwise false.
isSpatialValue()
Checks if a value is a spatial value (latitude and longitude).
protected
isSpatialValue(mixed $value) : bool
Parameters
- $value : mixed
-
The value to check.
Return values
bool —Returns true if the value is a valid spatial value, otherwise false.
normalizeAggregationsResults()
Normalizes the aggregation results from OpenSearch into a structured and simplified format.
protected
normalizeAggregationsResults(array<string|int, mixed> $aggregations) : array<string|int, mixed>
This function processes OpenSearch aggregations recursively, flattening nested aggregations
and extracting relevant data (e.g., top_hits
values, bucket keys, counts, and after_key
for composite aggregations) into an easier-to-use structure.
Parameters
- $aggregations : array<string|int, mixed>
-
The raw aggregation results from OpenSearch.
Return values
array<string|int, mixed> —A normalized array with structured aggregation data.
parseCondition()
Parses a condition and determines whether it should be processed as a normal or script condition.
protected
parseCondition(array<string|int, mixed> $condition) : array<string|int, mixed>
Parameters
- $condition : array<string|int, mixed>
-
The condition to parse.
Tags
Return values
array<string|int, mixed> —The Elasticsearch condition array.
setIndexName()
Sets index name
protected
setIndexName(string $indexName) : static
Parameters
- $indexName : string
Return values
static —Returns the current instance.