Ojs\CoreBundle\Service\Search\NativeQueryGenerator::journalQueryGenerator PHP Метод

journalQueryGenerator() приватный Метод

journal based query generator
private journalQueryGenerator ( $section ) : boolean | array
$section
Результат boolean | array
    private function journalQueryGenerator($section)
    {
        // if journal field not exists for given section return false
        if (!isset($this->getSearchInJournalQueryParams()[$section])) {
            return false;
        }
        $journalId = null;
        $sectionParams = $this->getSearchParamsBag()[$section];
        $from = ($this->getPage() - 1) * $this->getSearchSize();
        $size = $this->getSearchSize();
        $queryArray['from'] = $from;
        $queryArray['size'] = $size;
        // get journal id from query
        $journalId = $this->getJournalIdFromQuery();
        // get journal pure query from requested query
        $journalQuery = trim(preg_replace('/journal:' . $journalId . '/', '', $this->query));
        // get journal id field for given section
        $journalIdField = $this->getSearchInJournalQueryParams()[$section];
        // look basicQueryGenerator() function
        foreach ($sectionParams['fields'] as $field) {
            $searchField = $field;
            $boost = 1;
            if (is_array($field)) {
                $searchField = $field[0];
                $boost = $field[1];
            }
            if (empty($journalQuery)) {
                $queryArray['query']['filtered']['query']['bool']['should'][] = ['match_all' => []];
            } else {
                $queryArray['query']['filtered']['query']['bool']['should'][] = ['query_string' => ['query' => $section . '.' . $searchField . ':' . $journalQuery, 'boost' => $boost]];
            }
        }
        //add journal id filter
        $queryArray['query']['filtered']['filter']['bool']['must'][] = ['term' => [$journalIdField => $journalId]];
        // 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;
    }