private function tagQueryGenerator($section)
{
// if section is not have tags field return false
if (!in_array($section, array_keys($this->getTagQueryParams()))) {
return false;
}
$sectionParams = $this->getSearchParamsBag()[$section];
$sectionTagParams = $this->getTagQueryParams()[$section];
$from = ($this->getPage() - 1) * $this->getSearchSize();
$size = $this->getSearchSize();
$queryArray['from'] = $from;
$queryArray['size'] = $size;
// get tag
$tagQuery = trim(preg_replace('/tag:/', '', $this->query));
/**
* foreach tag search field add should
* term query with specified field
*/
foreach ($sectionTagParams as $tagField) {
$queryArray['query']['filtered']['query']['bool']['should'][] = ['term' => [$section . '.' . $tagField => strtolower($tagQuery)]];
}
// look basicQueryGenerator() function
if (!empty($this->requestAggsBag)) {
foreach ($this->requestAggsBag as $requestAggKey => $requestAgg) {
if (!in_array($requestAggKey, $sectionParams['aggs'])) {
continue;
}
foreach ($requestAgg as $aggValue) {
$queryArray['query']['filtered']['filter']['bool']['must'][] = ['term' => [$section . '.' . $requestAggKey => $aggValue]];
}
}
}
// look basicQueryGenerator() function
if ($this->setupAggs) {
foreach ($sectionParams['aggs'] as $agg) {
$queryArray['aggs'][$agg] = ['terms' => ['field' => $section . '.' . $agg]];
}
}
return $queryArray;
}