public function search($query, array $indexes, array $options = array(), $escapeQuery = true)
    {
        if ($escapeQuery) {
            $query = $this->sphinx->escapeString($query);
        }

        /**
         * Build the list of indexes to be queried.
         */
        $indexNames = '';
        foreach ($indexes as &$label) {
            if (isset($this->indexes[$label])) {
                $indexNames .= $this->indexes[$label] . ' ';
            }
        }

        $indexNames = trim($indexNames);

        /**
         * If no valid indexes were specified, return an empty result set.
         */
        if (empty($indexNames)) {
            return array();
        }

        /**
         * Set the offset and limit for the returned results.
         */
        if (isset($options['result_offset']) && isset($options['result_limit'])) {
            $this->sphinx->setLimits($options['result_offset'], $options['result_limit']);
        }

        /**
         * Weight the individual fields.
         */
        if (isset($options['field_weights'])) {
            $this->sphinx->setFieldWeights($options['field_weights']);
        }

        /**
         * Perform the query.
         */
        $results = $this->sphinx->query($query, $indexNames);
        if ($results === false || $results['status'] !== SEARCHD_OK) {
            if(is_array($results) && $results['status'] === SEARCHD_WARNING) {
                $errorText = $this->sphinx->getLastWarning();
            } else {
                $errorText = $this->sphinx->getLastError();
            }

            throw new \RuntimeException(sprintf(
                'Searching index "%s" for "%s" failed with message "%s".',
                $label,
                $query,
                $errorText
            ));
        }


        return $results;
    }