Execute the search.

@param string $query
@param callable|null $callback
@return \ScoutElastic\Builders\FilterBuilder|\ScoutElastic\Builders\SearchBuilder
434748
public static function search($query, $callback = null)
    {
        $softDelete = static::usesSoftDelete() && config('scout.soft_delete', false);

        if ($query == '*') {
            return new FilterBuilder(new static, $callback, $softDelete);
        } else {
            return new SearchBuilder(new static, $query, $callback, $softDelete);
        }
    }
758059
public final function doQuery(string $query, array $queryParams = null): BatchInterface
    {
        return $this->queue($query, $queryParams)->do();
    }
889081
public function scopeSearch(Builder $query, ?string $keyword, ?array $columns = null): Builder
    {
        return $this->setupWildcardQueryFilter($query, $keyword ?? '', $columns ?? $this->getSearchableColumns());
    }
517297
public static function search($query, array $searchParameters = null)
    {
        $manager = static::getAlgoliaManager();

        return $manager->search(__CLASS__, $query, $searchParameters);
    }
904586
public function execute(Query $query)
    {
        // Get native query for SimpleExpression
        $nativeQuery = $this->getNativeQuery($query);

        $queryParts = array();
        parse_str($nativeQuery, $queryParts);

        // pass http query parts 
        return $this->getClient()->lookup($queryParts);
    }
290178
public function executeQuery($query = null)
    {
        $connection = $this->getConnection();
        
        $connection->transaction(function (ConnectionInterface $connection) use ($query) {
            $connection->execute($query);
        });
        
        return $connection->affectedRows();
    }
199884
public function maybe_callback( $query, $post_args ) {
		$cmb   = isset( $post_args['cmb_id'] ) ? $post_args['cmb_id'] : '';
		$group = isset( $post_args['group_id'] ) ? $post_args['group_id'] : '';
		$field = isset( $post_args['field_id'] ) ? $post_args['field_id'] : '';

		$cmb = cmb2_get_metabox( $cmb );
		if ( $cmb && $group ) {
			$group = $cmb->get_field( $group );
		}

		if ( $cmb && $field ) {
			$group = $group ? $group : null;
			$field = $cmb->get_field( $field, $group );
		}

		if ( $field && ( $cb = $field->maybe_callback( 'attached_posts_search_query_cb' ) ) ) {
			call_user_func( $cb, $query, $field, $this );
		}
	}
329238
public function search($query)
    {
        if ($this->hasSearch()) {

            $search = $this->search;

            // If it's a anonymous function
            if (!is_string($search) && is_callable($search)) {
                call_user_func($search, $this, $query);
            }
        }

        return $this;
    }
11354
public function execute($query = null)
    {
        $prepare = true;

        if ($query !== null) {
            $this->setQuery($query);

            $prepare = false;
        }

        $this->connect();

        if (!$this->connection) {
            throw new \RuntimeException('Database disconnected.');
        }

        // Increment the query counter.
        $this->count++;

        return $this->doExecute($prepare);
    }
381487
protected function executeQuery($query)
    {
        $query   = null !== $this->getLocale() ? sprintf('%s&language=%s', $query, $this->getLocale()) : $query;
        $content = $this->getAdapter()->get($query)->getBody();

        if (!$data = json_decode($content, true)) {
            throw new NoResult(sprintf('Could not execute query: %s', $query));
        }

        if (!isset($data['Response']) && 'InvalidCredentials' === $data['subtype']) {
            throw new InvalidCredentials(sprintf('Invalid credentials: %s', $data['details']));
        } elseif (!isset($data['Response'])) {
            throw new NoResult(
                sprintf('Error type `%s` returned from api `%s`', $data['subtype'], $data['Details'])
            );
        }

        if (empty($data['Response']['View'])) {
            throw new NoResult(sprintf('Could not find results for given query: %s', $query));
        }

        $locations = $data['Response']['View'][0]['Result'];

        $results = array();
        foreach ($locations as $location) {
            $location       = $location['Location'];
            $coordinates    = isset($location['NavigationPosition'][0]) ? $location['NavigationPosition'][0] : $location['DisplayPosition'];
            $bounds         = $location['MapView'];
            $address        = $location['Address'];
            $additionalData = $location['Address']['AdditionalData'];

            $results[] = array_merge($this->getDefaults(), array(
                'latitude'     => $coordinates['Latitude']  ?: null,
                'longitude'    => $coordinates['Longitude'] ?: null,
                'bounds'       => array(
                    'south' => $bounds['BottomRight']['Latitude']  ?: null,
                    'west'  => $bounds['TopLeft']['Longitude']     ?: null,
                    'north' => $bounds['TopLeft']['Latitude']      ?: null,
                    'east'  => $bounds['BottomRight']['Longitude'] ?: null,
                ),
                'streetNumber' => isset($address['HouseNumber']) ? $address['HouseNumber'] : null,
                'streetName'   => isset($address['Street'])      ? $address['Street']      : null,
                'city'         => isset($address['City'])        ? $address['City']        : null,
                'cityDistrict' => isset($address['District'])    ? $address['District']    : null,
                'zipcode'      => isset($address['PostalCode'])  ? $address['PostalCode']  : null,
                'county'       => isset($address['County'])      ? $address['County']      : null,
                'regionCode'   => isset($address['State'])       ? $address['State']       : null,
                'countryCode'  => isset($address['Country'])     ? $address['Country']     : null,
                'region'       => $this->findByKey('StateName', $additionalData),
                'country'      => $this->findByKey('CountryName', $additionalData),
                'countyCode'   => null,
            ));
        }

        return $results;
    }
584266
protected function doQuery($callback)
    {
        $previousMethod = debug_backtrace(null, 2)[1];
        $methodName = $previousMethod['function'];
        $arguments = $previousMethod['args'];

        $result = $this->doBeforeQuery($callback, $methodName, $arguments);

        return $this->doAfterQuery($result, $methodName, $arguments);
    }
1101520
public function execute($query)
    {
        $context = $this->getCommandContext();

        $context->query = $query;

        if ($this->getCommandChain()->run('before.execute', $context) !== false) {
            $context->result = $this->_adapter->execute(to_str($context->query));
            $this->getCommandChain()->run('after.execute', $context);
        }

        return $context->result;
    }
859185
public function exec($command, $callback = null)
    {
        $this->commandStack[] = [
            'command' => new Command($this->receiveCommand($command)),
            'callback' => $callback,
        ];

        return $this;
    }
590965
public function executeFetchOne(
        $query = null,
        $params = []
    ) {

        $this->execute($query, $params);
        return $this->fetchOne();
    }
873270
public function question($query, callable $callback)
    {
        if (!is_callable($callback)) { return $this; }

        if ($this->questionCallback) {
            $this->prompt();
        } else {
            $this->oldPrompt = $this->prompt;
            $this->setPrompt($query);
            $this->questionCallback = $callback;
            $this->prompt();
        }

        return $this;
    }
553900
public function scopeAdvancedSearch(Builder $query, ?string $search, ?array $columns = null): Builder
    {
        ['basic' => $basic, 'advanced' => $advanced] = $this->resolveSearchKeywords($search ?? '');
        $rules = $this->getSearchableRules();
        $others = [];

        foreach ($rules as $keyword => $callback) {
            if (Str::contains($keyword, ':*') || Str::contains($keyword, ':[]')) {
                [$tag, $type] = \explode(':', $keyword, 2);

                $results = Arr::where($advanced, function ($value) use ($tag) {
                    return Str::startsWith($value, "{$tag}:");
                });

                $query->unless(empty($results), function ($query) use ($callback, $results, $type) {
                    if ($type === '*') {
                        [, $value] = \explode(':', $results[0] ?? null, 2);
                        $value = \trim($value, '"');
                    } else {
                        $value = \array_map(function ($text) {
                            [, $value] = \explode(':', $text, 2);

                            return \trim($value, '"');
                        }, $results);
                    }

                    \call_user_func($callback, $query, $value);

                    return $query;
                });
            } else {
                $query->when(\in_array($keyword, $advanced), function ($query) use ($callback) {
                    \call_user_func($callback, $query);

                    return $query;
                });
            }
        }

        if (\is_null($columns) && \method_exists($this, 'getSearchableColumns')) {
            $columns = $this->getSearchableColumns();
        }

        return $this->setupWildcardQueryFilter($query, $basic, $columns ?? []);
    }
755313
protected function _callQuery($query)
    {
        $query->contain($this->type['contain']);
        $extQuery = $this->type['query'];
        return $extQuery($query);
    }