public function process(SearchResultSet $resultSet)
    {
        $response = $resultSet->getResponse();
        if (!is_array($response->response->docs)) {
            return $resultSet;
        }

        if (!$this->typoScriptConfiguration->getSearchVariants()) {
            return $resultSet;
        }

        $variantsField = $this->typoScriptConfiguration->getSearchVariantsField();
        foreach ($resultSet->getSearchResults() as $key => $resultDocument) {
            /** @var $resultDocument SearchResult */
            $variantId = $resultDocument[$variantsField] ?? null;

            // when there is no value in the collapsing field, we can return
            if ($variantId === null) {
                continue;
            }

            $variantAccessKey = mb_strtolower($variantId);
            if (!isset($response->{'expanded'}) || !isset($response->{'expanded'}->{$variantAccessKey})) {
                continue;
            }

            $this->buildVariantDocumentAndAssignToParentResult($response, $variantAccessKey, $resultDocument);
        }

        return $resultSet;
    }
public function process(SearchResultSet $resultSet)
    {
        $response = $resultSet->getResponse();
        if (!is_array($response->response->docs)) {
            return $resultSet;
        }

        if (!$this->typoScriptConfiguration->getSearchVariants()) {
            return $resultSet;
        }

        $variantsField = $this->typoScriptConfiguration->getSearchVariantsField();
        foreach ($resultSet->getSearchResults() as $key => $resultDocument) {
            /** @var $resultDocument SearchResult */
            $variantId = $resultDocument[$variantsField] ?? null;

            // when there is no value in the collapsing field, we can return
            if ($variantId === null) {
                continue;
            }

            $variantAccessKey = mb_strtolower($variantId);
            if (!isset($response->{'expanded'}) || !isset($response->{'expanded'}->{$variantAccessKey})) {
                continue;
            }

            $this->buildVariantDocumentAndAssignToParentResult($response, $variantAccessKey, $resultDocument);
        }

        return $resultSet;
    }
public function process ( SearchResultSet $ resultSet ) { $ response = $ resultSet -> getResponse ( ) ; if ( ! is_array ( $ response -> response -> docs ) ) { return $ resultSet ; } if ( ! $ this -> typoScriptConfiguration -> getSearchVariants ( ) ) { return $ resultSet ; } $ variantsField = $ this -> typoScriptConfiguration -> getSearchVariantsField ( ) ; foreach ( $ resultSet -> getSearchResults ( ) as $ key => $ resultDocument ) { /** @var $resultDocument SearchResult */ $ variantId = $ resultDocument [ $ variantsField ] ?? null ; // when there is no value in the collapsing field, we can return if ( $ variantId === null ) { continue ; } $ variantAccessKey = mb_strtolower ( $ variantId ) ; if ( ! isset ( $ response -> { 'expanded' } ) || ! isset ( $ response -> { 'expanded' } -> { $ variantAccessKey } ) ) { continue ; } $ this -> buildVariantDocumentAndAssignToParentResult ( $ response , $ variantAccessKey , $ resultDocument ) ; } return $ resultSet ; }
This method is used to add documents to the expanded documents of the SearchResult
when collapsing is configured.

@param SearchResultSet $resultSet
@return SearchResultSet
This method is used to add documents to the expanded documents of the SearchResult when collapsing is configured .