public function getSearchQuery(ProductCondition $productCondition)
    {
        $query = null;

        $query = $this->getSpecialAttributesSearchQuery($productCondition);

        if ($query === null && !empty($productCondition->getValue())) {
            $this->prepareFieldValue($productCondition);
            $queryType   = QueryInterface::TYPE_TERMS;
            $queryParams = $this->getTermsQueryParams($productCondition);

            if ($productCondition->getInputType() === 'string' && !in_array($productCondition->getOperator(), ['()', '!()'])) {
                $queryType   = QueryInterface::TYPE_MATCH;
                $queryParams = $this->getMatchQueryParams($productCondition);
            } elseif (in_array($productCondition->getOperator(), ['>=', '>', '<=', '<'])) {
                $queryType   = QueryInterface::TYPE_RANGE;
                $queryParams = $this->getRangeQueryParams($productCondition);
            }

            $query = $this->prepareQuery($queryType, $queryParams);

            if (substr($productCondition->getOperator(), 0, 1) === '!') {
                $query = $this->applyNegation($query);
            }

            $field = $this->getSearchField($productCondition);

            if ($field->isNested()) {
                $nestedPath        = $field->getNestedPath();
                $nestedQueryParams = ['query' => $query, 'path' => $nestedPath];

                if (isset($this->nestedFilters[$nestedPath])) {
                    $nestedFilterClauses           = [];
                    $nestedFilterClauses['must'][] = $this->nestedFilters[$nestedPath]->getFilter();
                    $nestedFilterClauses['must'][] = $nestedQueryParams['query'];

                    $nestedFilter = $this->queryFactory->create(QueryInterface::TYPE_BOOL, $nestedFilterClauses);

                    $nestedQueryParams['query'] = $nestedFilter;
                }

                $query = $this->queryFactory->create(QueryInterface::TYPE_NESTED, $nestedQueryParams);
            }
        }

        return $query;
    }
public function getSearchQuery(ProductCondition $productCondition)
    {
        $query = null;

        $query = $this->getSpecialAttributesSearchQuery($productCondition);

        if ($query === null && !empty($productCondition->getValue())) {
            $this->prepareFieldValue($productCondition);
            $queryType   = QueryInterface::TYPE_TERMS;
            $queryParams = $this->getTermsQueryParams($productCondition);

            if ($productCondition->getInputType() === 'string' && !in_array($productCondition->getOperator(), ['()', '!()'])) {
                $queryType   = QueryInterface::TYPE_MATCH;
                $queryParams = $this->getMatchQueryParams($productCondition);
            } elseif (in_array($productCondition->getOperator(), ['>=', '>', '<=', '<'])) {
                $queryType   = QueryInterface::TYPE_RANGE;
                $queryParams = $this->getRangeQueryParams($productCondition);
            }

            $query = $this->prepareQuery($queryType, $queryParams);

            if (substr($productCondition->getOperator(), 0, 1) === '!') {
                $query = $this->applyNegation($query);
            }

            $field = $this->getSearchField($productCondition);

            if ($field->isNested()) {
                $nestedPath        = $field->getNestedPath();
                $nestedQueryParams = ['query' => $query, 'path' => $nestedPath];

                if (isset($this->nestedFilters[$nestedPath])) {
                    $nestedFilterClauses           = [];
                    $nestedFilterClauses['must'][] = $this->nestedFilters[$nestedPath]->getFilter();
                    $nestedFilterClauses['must'][] = $nestedQueryParams['query'];

                    $nestedFilter = $this->queryFactory->create(QueryInterface::TYPE_BOOL, $nestedFilterClauses);

                    $nestedQueryParams['query'] = $nestedFilter;
                }

                $query = $this->queryFactory->create(QueryInterface::TYPE_NESTED, $nestedQueryParams);
            }
        }

        return $query;
    }
public function getSearchQuery ( ProductCondition $ productCondition ) { $ query = null ; $ query = $ this -> getSpecialAttributesSearchQuery ( $ productCondition ) ; if ( $ query === null && ! empty ( $ productCondition -> getValue ( ) ) ) { $ this -> prepareFieldValue ( $ productCondition ) ; $ queryType = QueryInterface :: TYPE_TERMS ; $ queryParams = $ this -> getTermsQueryParams ( $ productCondition ) ; if ( $ productCondition -> getInputType ( ) === 'string' && ! in_array ( $ productCondition -> getOperator ( ) , [ '()' , '!()' ] ) ) { $ queryType = QueryInterface :: TYPE_MATCH ; $ queryParams = $ this -> getMatchQueryParams ( $ productCondition ) ; } elseif ( in_array ( $ productCondition -> getOperator ( ) , [ '>=' , '>' , '<=' , '<' ] ) ) { $ queryType = QueryInterface :: TYPE_RANGE ; $ queryParams = $ this -> getRangeQueryParams ( $ productCondition ) ; } $ query = $ this -> prepareQuery ( $ queryType , $ queryParams ) ; if ( substr ( $ productCondition -> getOperator ( ) , 0 , 1 ) === '!' ) { $ query = $ this -> applyNegation ( $ query ) ; } $ field = $ this -> getSearchField ( $ productCondition ) ; if ( $ field -> isNested ( ) ) { $ nestedPath = $ field -> getNestedPath ( ) ; $ nestedQueryParams = [ 'query' => $ query , 'path' => $ nestedPath ] ; if ( isset ( $ this -> nestedFilters [ $ nestedPath ] ) ) { $ nestedFilterClauses = [ ] ; $ nestedFilterClauses [ 'must' ] [ ] = $ this -> nestedFilters [ $ nestedPath ] -> getFilter ( ) ; $ nestedFilterClauses [ 'must' ] [ ] = $ nestedQueryParams [ 'query' ] ; $ nestedFilter = $ this -> queryFactory -> create ( QueryInterface :: TYPE_BOOL , $ nestedFilterClauses ) ; $ nestedQueryParams [ 'query' ] = $ nestedFilter ; } $ query = $ this -> queryFactory -> create ( QueryInterface :: TYPE_NESTED , $ nestedQueryParams ) ; } } return $ query ; }
Build the query for a condition.

@param ProductCondition $productCondition Product condition.

@return \Smile\ElasticsuiteCore\Search\Request\QueryInterface
Build the query for a condition .