Returns an array of index names (or patterns) that should be
queried for the given search request.

@param SearchEventsRequest $request

@return string[]
170663
public function getIndexNamesForSearch(SearchEventsRequest $request): array
    {
        /** @var \DateTime $after */
        /** @var \DateTime $before */
        $after = $request->get('occurred_after');
        $before = $request->get('occurred_before');

        /*
         * when no lower bound is used, we must assume they meant to search
         * all events to the beginning of time.  this could take forever.
         */
        if (null === $after) {
            return [$this->indexPrefix . '*'];
        }

        // if no upper bound is present, make one up
        $end = $before ?: new \DateTime('now', new \DateTimeZone('UTC'));

        /*
         * now, while start is less than end... accumulate the intervals as indices
         * if the span results in too many indices, use a wildcard to prevent urls
         * being too long for a GET request (multi-index searches have index in url)
         */
        $indices = [];
        $start = clone $after;

        do {
            $indices[$this->indexPrefix . $this->getIndexIntervalSuffix($start)] = true;
            $start = $start->modify('+1 week');
        } while ($start < $end);
        $indices[$this->indexPrefix . $this->getIndexIntervalSuffix($start)] = true;

        if (count($indices) > 9) {
            $start = clone $after;
            $indices = [];
            do {
                $indices[$this->indexPrefix . $start->format('Y') . '*'] = true;
                $start = $start->modify('+1 year');
            } while ($start < $end);
        }

        return array_keys($indices);
    }
1074729
protected function getFilters(Request $request)
    {
        $type = $this->getFilterType($request);

        if (!$type) {
            return $request->query->get('search')['value'];
        }

        $filter = new $type();

        $param = $filter->getBlockPrefix();

        return $request->query->get($param);
    }
740940
public function prepareSearchQuery(IndexSearchQueryEvent $event)
    {
        $body = [];
        $query = $event->getQuery();

        if (null !== $limit = $query->getLimit()) {
            $body["size"] = $limit;
        }

        if (null !== $offset = $query->getOffset()) {
            $body["from"] = $offset;
        }

        if (null !== $orderBy = $query->getOrderBy()) {
            foreach ($orderBy as $order) {
                list($orderColumn, $orderType) = $order;

                switch ($orderType) {
                    case Order::ASC:
                        $body["sort"][$orderColumn] = "asc";
                        break;

                    case Order::DESC:
                        $body["sort"][$orderColumn] = "desc";
                        break;
                }
            }
        }

        $groups = $query->getCriterionGroups();
        $totalGroupCount = count($groups);

        $previousGroupLink = null;

        if ($totalGroupCount === 1) {
            // Handle simple group
            $criterionGroup = $query->getCriterionGroups();
            /** @var CriterionGroupInterface $criterionGroup */
            $criterionGroup = array_pop($criterionGroup)[0];

            $body["query"] = $this->transformCriterionGroup($criterionGroup);
        } else {
            // Handle complex group
            $splitGroups = [];
            $i = 0;

            foreach ($groups as $groupTuple) {
                /** @var CriterionGroupInterface $criterionGroup */
                list($criterionGroup, $link) = $groupTuple;
                $splitGroups[$i][] = $criterionGroup;

                if ($link === Link::LINK_OR) {
                    $i++;
                }
            }

            if (count($splitGroups) === 1) {
                // Global query without OR

                /** @var CriterionGroupInterface $criterionGroup */
                foreach ($splitGroups[0] as $criterionGroup) {
                    $body["query"]["filtered"]["filter"]["and"][]["query"] = $this->transformCriterionGroup($criterionGroup);
                }
            } else {
                // Global query with OR
                foreach ($splitGroups as $criterionGroups) {
                    $orNode = &$body["query"]["filtered"]["filter"]["or"][];

                    foreach ($criterionGroups as $criterionGroup) {
                        $orNode["query"]["filtered"]["filter"]["and"][]["query"] = $this->transformCriterionGroup($criterionGroup);
                    }
                }
            }
        }

        $event->setExtraData($body);
    }
1339348
public function index(Request $request)
    {
        $limit = 20;

        $tags = $request->user()->tags()
            ->searchFilter($request->q)
            ->cursorFilter($request->cursor)
            ->orderBy(DB::raw('uuid_v1_timestamp(id)'), 'DESC')->limit($limit)->get();

        $results = fractal()
            ->collection($tags, new TagTransformer())
            ->withCursor(new Cursor($request->cursor, $request->prev, $tags, $limit));

        return $results;
    }
754355
public function get_items( $request ) {

		// Retrieve the list of registered collection query parameters.
		$registered = $this->get_collection_params();

		// This array defines mappings between public API query parameters whose
		// values are accepted as-passed, and their internal WP_Query parameter
		// name equivalents (some are the same). Only values which are also
		// present in $registered will be set.
		$parameter_mappings = array(
			'exclude'    => 'exclude',
			'include'    => 'include',
			'order'      => 'order',
			'orderby'    => 'orderby',
			'post'       => 'post',
			'hide_empty' => 'hide_empty',
			'per_page'   => 'number',
			'search'     => 'search',
			'slug'       => 'slug',
		);

		$prepared_args = array();

		// For each known parameter which is both registered and present in the request,
		// set the parameter's value on the query $prepared_args.
		foreach ( $parameter_mappings as $api_param => $wp_param ) {
			if ( isset( $registered[ $api_param ], $request[ $api_param ] ) ) {
				$prepared_args[ $wp_param ] = $request[ $api_param ];
			}
		}

		if ( isset( $registered['offset'] ) && ! empty( $request['offset'] ) ) {
			$prepared_args['offset'] = $request['offset'];
		} else {
			$prepared_args['offset'] = ( $request['page'] - 1 ) * $prepared_args['number'];
		}

		$taxonomy_obj = get_taxonomy( $this->taxonomy );

		if ( $taxonomy_obj->hierarchical && isset( $registered['parent'], $request['parent'] ) ) {
			if ( 0 === $request['parent'] ) {
				// Only query top-level terms.
				$prepared_args['parent'] = 0;
			} else {
				if ( $request['parent'] ) {
					$prepared_args['parent'] = $request['parent'];
				}
			}
		}

		/**
		 * Filters the query arguments before passing them to get_terms().
		 *
		 * Enables adding extra arguments or setting defaults for a terms
		 * collection request.
		 *
		 * @see https://developer.wordpress.org/reference/functions/get_terms/
		 *
		 * @param array           $prepared_args Array of arguments to be
		 *                                       passed to get_terms().
		 * @param WP_REST_Request $request       The current request.
		 */
		$prepared_args = apply_filters( "rest_{$this->taxonomy}_query", $prepared_args, $request );

		if ( ! empty( $prepared_args['post'] )  ) {
			$query_result = $this->get_terms_for_post( $prepared_args );
			$total_terms = $this->total_terms;
		} else {
			$query_result = get_terms( $this->taxonomy, $prepared_args );

			$count_args = $prepared_args;
			unset( $count_args['number'], $count_args['offset'] );
			$total_terms = wp_count_terms( $this->taxonomy, $count_args );

			// wp_count_terms can return a falsy value when the term has no children
			if ( ! $total_terms ) {
				$total_terms = 0;
			}
		}
		$response = array();
		foreach ( $query_result as $term ) {
			$data = $this->prepare_item_for_response( $term, $request );
			$response[] = $this->prepare_response_for_collection( $data );
		}

		$response = rest_ensure_response( $response );

		// Store pagination values for headers.
		$per_page = (int) $prepared_args['number'];
		$page = ceil( ( ( (int) $prepared_args['offset'] ) / $per_page ) + 1 );

		$response->header( 'X-WP-Total', (int) $total_terms );
		$max_pages = ceil( $total_terms / $per_page );
		$response->header( 'X-WP-TotalPages', (int) $max_pages );

		$base = add_query_arg( $request->get_query_params(), rest_url( $this->namespace . '/' . $this->rest_base ) );
		if ( $page > 1 ) {
			$prev_page = $page - 1;
			if ( $prev_page > $max_pages ) {
				$prev_page = $max_pages;
			}
			$prev_link = add_query_arg( 'page', $prev_page, $base );
			$response->link_header( 'prev', $prev_link );
		}
		if ( $max_pages > $page ) {
			$next_page = $page + 1;
			$next_link = add_query_arg( 'page', $next_page, $base );
			$response->link_header( 'next', $next_link );
		}

		return $response;
	}
94424
public static function getHeadersFromRequest(Request $request)
    {
        $headers = array();
        foreach($request->headers as $key => $value)
        {
            if(isset($key) && isset($value) && isset($value[0]))
            {
                $headers[$key] = $value[0];
            }
        }
        return $headers;
    }
39857
public function indexAction(Request $request)
    {
        $channel = $this->getSelectedChannel();

        $builder = $this->getDocumentManager()->createQueryBuilder(ContentTypePage::class)
            ->field('channel.$id')->equals($channel->getId());

        $pagination = $this->getPaginator()->paginate(
            $builder,
            $request->query->get('page', 1),
            20
        );

        return [
            'pages' => $pagination,
            'channels' => $this->getChannels(),
            'selectedChannel' => $channel,
        ];
    }
797988
public function searchTagsAction(Request $request)
    {
        $q = $request->get('q');
        $response = [];
        $query = $this->admin->getModelManager()->createQuery($this->admin->getClass(), 't');
        $query->select('t.id, t.path AS text');
        $query->andWhere('t.path LIKE :q');
        $query->orderBy('text', 'ASC');
        $query->setParameter(':q', '%'.$q.'%');
        $response = $query->execute([], Query::HYDRATE_ARRAY);

        return $this->renderJson($response);
    }
845392
protected function paginationInformation($request)
    {
        $paginated = $this->resource->resource->toArray();

        return [
            'links' => $this->paginationLinks($paginated),
            'meta' => $this->meta($paginated),
        ];
    }
923959
public function get_items( $request ) {

		// Retrieve the list of registered collection query parameters.
		$registered = $this->get_collection_params();

		// This array defines mappings between public API query parameters whose
		// values are accepted as-passed, and their internal WP_Query parameter
		// name equivalents (some are the same). Only values which are also
		// present in $registered will be set.
		$parameter_mappings = array(
			'exclude'  => 'exclude',
			'include'  => 'include',
			'order'    => 'order',
			'per_page' => 'number',
			'search'   => 'search',
			'roles'    => 'role__in',
		);

		$prepared_args = array();

		// For each known parameter which is both registered and present in the request,
		// set the parameter's value on the query $prepared_args.
		foreach ( $parameter_mappings as $api_param => $wp_param ) {
			if ( isset( $registered[ $api_param ], $request[ $api_param ] ) ) {
				$prepared_args[ $wp_param ] = $request[ $api_param ];
			}
		}

		if ( isset( $registered['offset'] ) && ! empty( $request['offset'] ) ) {
			$prepared_args['offset'] = $request['offset'];
		} else {
			$prepared_args['offset']  = ( $request['page'] - 1 ) * $prepared_args['number'];
		}

		if ( isset( $registered['orderby'] ) ) {
			$orderby_possibles = array(
				'id'              => 'ID',
				'include'         => 'include',
				'name'            => 'display_name',
				'registered_date' => 'registered',
				'slug'            => 'user_nicename',
				'email'           => 'user_email',
				'url'             => 'user_url',
			);
			$prepared_args['orderby'] = $orderby_possibles[ $request['orderby'] ];
		}

		if ( ! current_user_can( 'list_users' ) ) {
			$prepared_args['has_published_posts'] = true;
		}

		if ( ! empty( $prepared_args['search'] ) ) {
			$prepared_args['search'] = '*' . $prepared_args['search'] . '*';
		}

		if ( isset( $registered['slug'] ) && ! empty( $request['slug'] ) ) {
			$prepared_args['search'] = $request['slug'];
			$prepared_args['search_columns'] = array( 'user_nicename' );
		}

		/**
		 * Filter arguments, before passing to WP_User_Query, when querying users via the REST API.
		 *
		 * @see https://developer.wordpress.org/reference/classes/wp_user_query/
		 *
		 * @param array           $prepared_args Array of arguments for WP_User_Query.
		 * @param WP_REST_Request $request       The current request.
		 */
		$prepared_args = apply_filters( 'rest_user_query', $prepared_args, $request );

		$query = new WP_User_Query( $prepared_args );

		$users = array();
		foreach ( $query->results as $user ) {
			$data = $this->prepare_item_for_response( $user, $request );
			$users[] = $this->prepare_response_for_collection( $data );
		}

		$response = rest_ensure_response( $users );

		// Store pagination values for headers then unset for count query.
		$per_page = (int) $prepared_args['number'];
		$page = ceil( ( ( (int) $prepared_args['offset'] ) / $per_page ) + 1 );

		$prepared_args['fields'] = 'ID';

		$total_users = $query->get_total();
		if ( $total_users < 1 ) {
			// Out-of-bounds, run the query again without LIMIT for total count
			unset( $prepared_args['number'], $prepared_args['offset'] );
			$count_query = new WP_User_Query( $prepared_args );
			$total_users = $count_query->get_total();
		}
		$response->header( 'X-WP-Total', (int) $total_users );
		$max_pages = ceil( $total_users / $per_page );
		$response->header( 'X-WP-TotalPages', (int) $max_pages );

		$base = add_query_arg( $request->get_query_params(), rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ) );
		if ( $page > 1 ) {
			$prev_page = $page - 1;
			if ( $prev_page > $max_pages ) {
				$prev_page = $max_pages;
			}
			$prev_link = add_query_arg( 'page', $prev_page, $base );
			$response->link_header( 'prev', $prev_link );
		}
		if ( $max_pages > $page ) {
			$next_page = $page + 1;
			$next_link = add_query_arg( 'page', $next_page, $base );
			$response->link_header( 'next', $next_link );
		}

		return $response;
	}
714582
public function toArray($request)
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'identifier' => $this->identifier,
            'data_type' => $this->data_type,
            'field_type' => $this->field_type,
            'sort_order' => $this->sort_order,
            'dropdown_options' => $this->when($this->field_type == 'SELECT', new PropertyDropdownOptionCollectionResource($this->propertyDropdownOptions)),
            'use_for_all_products' => $this->use_for_all_products,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at,
        ];
    }
1327319
public function search(Request $request)
    {
        $notifications = $this->service->search($request->search, Auth::id());
        return view('notifications.index')->with('notifications', $notifications);
    }
1300847
public function getFieldsFromRequest(array $request)
    {
        $keys = isset($request['field']) ? $request['field'] : null;
        $fields = [];
        if (is_array($keys)) {
            foreach ($this->groups as $group) {
                foreach ($group->getFields() as $field) {
                    if (in_array($field->getKey(), $keys)) {
                        $field->loadDataFromRequest($request);
                        $fields[] = $field;
                    }
                }
            }
        }

        return $fields;
    }
911823
public function getMapping(Request $request): array
    {
        return $this->cache->load($this->getCacheKey($request), function (&$dependencies) use ($request) {
            return $this->loadMapping($request->getPresenterName(), $request->getParameters(), $dependencies);
        });
    }
974827
public function postTypeFinder($request)
    {
        if (key_exists('type', $request->query)) {
            return $request->query['type'];
        }
        if (key_exists(0, $request->params['pass'])) {
            return $request->params['pass'][0];
        }
        return '';
    }
657744
public function index(Request $request)
    {
        $query = Tag::query();

        if ($request->has('filter.containing')) {
            $query->containing($request['filter']['containing']);
        }

        if ($request->has('filter.type')) {
            $query->where('type', $request['filter']['type']);
        }

        if ($request->has('limit')) {
            $query->limit($request['limit']);
        }

        return $query->get()->map(function (Tag $tag) {
            return $tag->name;
        });
    }
1068977
public function search(HTTPRequest $request)
    {
        // Check form field state
        if($this->isDisabled() || $this->isReadonly()) {
            return $this->httpError(403);
        }

        $query = $request->getVar('query');

        // use callbacks if they're set, otherwise used this class's methods for search and processing
        if ($this->getSearchCallback()) {
            $results = call_user_func($this->getSearchCallback(), $query, $this);
        } else {
            $results = $this->getResults($query);
        }

        if ($this->getProcessCallback()) {
            $json = call_user_func($this->getProcessCallback(), $results, $this);
        } else {
            $json = $this->processResults($results);
        }

        return Convert::array2json($json);
    }