protected function fetchResults()
    {
        $maxResults = 1000; // limit results
        if (count($this->conf['exportFormats']) > 0) {
            // limit results even more if we are creating export data
            $maxResults = $maxResults / (count($this->conf['exportFormats']) + 1);
        }
        $recordsToFetch = 350;
        $firstRecord = 0;

        // get records in chunks of $recordsToFetch to avoid running out of memory
        // in t3lib_div::xml2tree. We seem to typically need ~100KB per record (?).
        while ($firstRecord < $maxResults) {
            $recordsToFetchNow = min([$recordsToFetch, $maxResults - $firstRecord]);
            $showReplyString = $this->fetchURL($this->pazpar2ShowURL($firstRecord, $recordsToFetchNow));
            $firstRecord += $recordsToFetchNow;

            // need xml2tree here as xml2array fails when dealing with arrays of tags with the same name
            $showReplyTree = GeneralUtility::xml2tree($showReplyString);
            $showReply = $showReplyTree['show'][0]['ch'];

            if ($showReply) {
                $status = $showReply['status'][0]['values'][0];
                if ($status == 'OK') {
                    $this->queryIsRunning = false;
                    $hits = $showReply['hit'];

                    if ($hits) {
                        foreach ($hits as $hit) {
                            $myHit = $hit['ch'];
                            $key = $myHit['recid'][0]['values'][0];

                            // Make sure the 'medium' field exists by setting it to 'other' if necessary.
                            if (!array_key_exists('md-medium', $myHit)) {
                                $myHit['md-medium'] = [0 => ['values' => [0 => 'other']]];
                            }

                            // If there is no title information but series information, use the
                            // first series field for the title.
                            if (!(array_key_exists('md-title', $myHit) || array_key_exists('md-multivolume-title', $myHit))
                                    && array_key_exists('md-series-title', $myHit)
                            ) {
                                $myHit['md-multivolume-title'] = [$myHit['md-series-title'][0]];
                            }

                            // Sort the location array to have the newest item first
                            usort($myHit['location'], [$this, 'yearSort']);

                            $this->results[$key] = $myHit;
                        }
                    }
                } else {
                    GeneralUtility::devLog('pazpar2 show reply status is not "OK" but "' . $status . '"', 'pazpar2', 3);
                }
            } else {
                GeneralUtility::devLog('could not parse pazpar2 show reply', 'pazpar2', 3);
            }
        }
    }