Perform the given search on the engine.

@param  \Laravel\Scout\Builder  $builder
@return mixed
774429
public function search(Builder $builder)
    {
        return $this->performSearch($builder, array_filter([
            'numericFilters' => $this->filters($builder),
            'hitsPerPage' => $builder->limit,
        ]));
    }
160030
protected function performSearch(Builder $builder, array $options = [])
    {
        $params = [
            'index' => $this->index,
            'type' => $builder->model->searchableAs(),
            'body' => [
                'query' => [
                    'bool' => [
                        'must' => [['query_string' => [ 'query' => $builder->query]]]
                    ]
                ]
            ]
        ];

        if (isset($options['from'])) {
            $params['body']['from'] = $options['from'];
        }

        if (isset($options['size'])) {
            $params['body']['size'] = $options['size'];
        }

        if (isset($options['numericFilters']) && count($options['numericFilters'])) {
            $params['body']['query']['bool']['must'] = array_merge($params['body']['query']['bool']['must'],
                $options['numericFilters']);
        }

        return $this->elastic->search($params);
    }
686725
public function apply(Builder $builder)
    {
        $this->builder = $builder;

        if (method_exists($this, $this->orderBy())) {
            call_user_func([$this, $this->orderBy()]);
        }

        return $this->builder;
    }
1175587
public function scopeSearch(Builder $query, array $search = [])
    {
        if (empty($search)) {
            return $query;
        }

        if (!array_intersect(array_keys($search), $this->searchable)) {
            return $query;
        }

        return $query->where($search);
    }
592781
public function apply($builder)
    {
        $values = $this->getValues();
        if (empty($values)) {
            return $builder;
        }
        $builder->whereIn('type_id', $values);
    }
641466
protected function performSearch(Builder $builder, array $options = [])
    {
        $algolia = $this->algolia->initIndex(
            $builder->index ?: $builder->model->searchableAs()
        );

        if ($builder->callback) {
            return call_user_func(
                $builder->callback,
                $algolia,
                $builder->query,
                $options
            );
        }

        return $algolia->search($builder->query, $options);
    }
686285
public function setQueryBuilder(\pwf\components\querybuilder\interfaces\SelectBuilder $builder)
    {
        $this->queryBuilder = $builder;
        return $this;
    }
960865
protected function getCache(QueryCacheBuilder $builder)
    {
        return $this->isTaggable() ? Cache::store($this->store)->tags($this->getTag($builder)) : Cache::store($this->store);
    }
229780
private function applyWheres($builder)
    {
        // iterate over given where clauses
        return collect($this->builder->wheres)->map(function ($value, $key) {
            // for reduce function combine key and value into array
            return [$key, $value];
        })->reduce(function ($builder, $where) {
            // separate key, value again
            list($key, $value) = $where;
            return $builder->where($key, $value);
        }, $builder);
    }
701319
public function queryMethods(QueryBuilder $builder)
    {
        $script = '';
        $script .= $this->addArchive($builder);
        if ($this->behavior->isArchiveOnUpdate()) {
            $script .= $this->addSetArchiveOnUpdate($builder);
            $script .= $this->addUpdateWithoutArchive($builder);
        }
        if ($this->behavior->isArchiveOnDelete()) {
            $script .= $this->addSetArchiveOnDelete($builder);
            $script .= $this->addDeleteWithoutArchive($builder);
        }

        return $script;
    }
243300
public function updateQueryBuilder($builder) {

		// Make sure the extension requirements have been met before enabling the custom search index.

		if(SiteTree::has_extension('SolrIndexable') && SiteTree::has_extension('SiteTreePermissionIndexExtension') && ClassInfo::exists('QueuedJob')) {

			// Define the initial user permissions using the general public access flag.

			$groups = array(
				'anyone'
			);

			// Apply the logged in access flag and listing of groups for the current authenticated user.

			$user = Member::currentUser();
			if($user) {

				// Don't restrict the search results for an administrator.

				if(Permission::checkMember($user, array('ADMIN', 'SITETREE_VIEW_ALL'))) {
					return;
				}
				$groups[] = 'logged-in';
				foreach($user->Groups() as $group) {
					$groups[] = (string)$group->ID;
				}
			}

			// Apply this permission filter.

			$builder->andWith('Groups_ms', $groups);
		}
	}
1090736
protected function count($builder)
    {
        $read = NotificationsStackRead::select(['stack_id'])->withTrashed()->where('user_id', user()->id)->pluck('stack_id');
        return $builder->whereNotIn('id', $read)->count();
    }
1198155
public function index($builder = null)
    {
        $models = $this->repository->all([], true);

        return response()->json($models, 200);
    }
257248
public function count(Builder $builder)
    {
        $count = 0;

        $this
            ->buildSearchQueryPayloadCollection($builder, ['highlight' => false])
            ->each(function ($payload) use (&$count) {
                $result = ElasticClient::count($payload);

                $count = $result['count'];

                if ($count > 0) {
                    return false;
                }
            });

        return $count;
    }
1148431
protected function addRejected(Builder $builder)
    {
        $builder->macro('rejected', function (Builder $builder) {
            $model = $builder->getModel();

            $this->remove($builder, $model);

            $builder->where($model->getQualifiedStatusColumn(), '=', Status::REJECTED);

            return $builder;
        });
    }
1167506
protected function addWithRejected(Builder $builder)
    {
        $builder->macro('withRejected', function (Builder $builder) {
            $this->remove($builder, $builder->getModel());

            return $builder->whereIN($this->getStatusColumn($builder),
                [Status::APPROVED, Status::REJECTED]);
        });
    }
626657
public function get(QueryCacheBuilder $builder, $columns = ['*'])
    {
        if (!$this->enabled()) {
            return $this->performQuery($builder, $columns);
        }

        $key = $this->generateKey($builder, $columns);

        $cache = $this->getCache($builder);

        return $cache->remember($key, $this->length, function () use ($builder, $columns) {
            return $this->performQuery($builder, $columns);
        });
    }