Decode search query into searchable parts.

@param string $q

@return array
512719
private function decodeSearchQuery($q)
    {
        $words = preg_split('|[\r\n\t ]+|', trim($q));

        $words = array_map(
            function ($word) {
                return mb_strtolower($word);
            },
            $words
        );
        $words = array_filter(
            $words,
            function ($word) {
                return strlen($word) >= 2;
            }
        );

        return [
            'valid' => count($words) > 0,
            'in_q'  => $q,
            'use_q' => implode(' ', $words),
            'sanitized_q' => strip_tags($q),
            'words' => $words,
        ];
    }
141401
public function textSearch($query = null) {
		if ($query) {
			if (strpos($query, 'type@') === 0) {
				$query = str_replace('type@', '', $query);
				return ['Log.type' => $query];
			}

			$escapedQuery = "'" . $query . "'"; // for now - $this->getDataSource()->value($query);
			return ["MATCH (message) AGAINST ($escapedQuery)"];
		}
		return [];
	}
639599
protected function parseQ()
    {
        if ($this->query->has('q')) {
            $exprs = explode(',', $this->query->getRaw('q'));

            foreach ($exprs as $expr) {
                $this->query->addExpression($this->parseExpression($expr));
            }
        }
    }
980698
protected function parseSearch()
    {
        return implode(' ', array_map(function ($key, $val) {
            if (is_null($val)) {
                return strtoupper($key);
            }
            return sprintf('%s %s', strtoupper($key), $val);
        }, array_keys($this->where), array_values($this->where)));
    }
706566
function(q) {
            var workingQ = '' + q;
            workingQ = workingQ.replace(this.reLTrimCommand, '');
            if (workingQ.substring(0, 7) == 'search ') {
                return workingQ.substring(7).replace(this.reLTrimCommand, '');
            }
            return q;
        }
596085
public function scopeSearchFilter($query, $q)
    {
        if(!empty($q)){
            return $query->where(DB::raw('LOWER(name)'), 'LIKE', '%' . strtolower($q) . '%');
        }
    }
1003054
public function search($q, $mimes) {
		$result = array();

		$sql = 'SELECT f.id, f.parent_id, f.name, f.size, f.mtime AS ts, f.mime, f.read, f.write, f.locked, f.hidden, f.width, f.height, 0 AS dirs 
				FROM %s AS f 
				WHERE f.name RLIKE "%s"';
		
		$sql = sprintf($sql, $this->tbf, $this->db->real_escape_string($q));
		
		if (($res = $this->query($sql))) {
			while ($row = $res->fetch_assoc()) {
				if ($this->mimeAccepted($row['mime'], $mimes)) {
					$id = $row['id'];
					if ($row['parent_id']) {
						$row['phash'] = $this->encode($row['parent_id']);
					} 

					if ($row['mime'] == 'directory') {
						unset($row['width']);
						unset($row['height']);
					} else {
						unset($row['dirs']);
					}

					unset($row['id']);
					unset($row['parent_id']);



					if (($stat = $this->updateCache($id, $row)) && empty($stat['hidden'])) {
						$result[] = $stat;
					}
				}
			}
		}
		
		return $result;
	}
43464
protected function filterQuery($query)
    {
        $query = preg_replace_callback(
            '/(?:[^' . self::CHARACTERS_UNRESERVED . self::CHARACTERS_SUB_DELIMS . '%:@\/\?]+|%(?![A-Fa-f0-9]{2}))/',
            function ($match) {
                return rawurlencode($match[0]);
            },
            $query
        );

        if (is_null($query)) {
            throw new InvalidArgumentException(sprintf('Invalid query strings "%s".', $query));
        } elseif (!$query) {
            $query = '';
        }

        if (substr($query, 0, 1) === '?') {
            $query = substr($query, 1);
        }

        return $query;
    }
600373
public function search($query)
    {
        $this->validate($query);
        $client = $this->client->getClient();
        $result = array();
        // Change the match column name with the column name you want to search in it.
        $params = [
                'index' => $this->client->getIndex(),
                'type'  => $this->client->getType(),
                'body'  => [
                    'query' => [
                        'match' => [ $this->searchColumn => $query],
                    ],
                ],
            ];
        $query  = $client->search($params);
            
        return  $this->extractResult($query);
    }
236586
private function prepareCondition($q)
    {
        $condition = [];
        foreach ($this->searchFields as $field) {
            $condition[] = ['like', $field, $q];
        }
        if (count($this->searchFields) > 1) {
            array_unshift($condition, 'or');
        }
        return $condition;
    }
1133121
protected function query_parse($query)
    {
        $start = $this->options['identifier_start'];
        $end   = $this->options['identifier_end'];
        $quote = self::DEFAULT_QUOTE;

        if ($start == $quote) {
            return $query;
        }

        $pos = 0;
        $in  = false;

        while ($pos = strpos($query, $quote, $pos)) {
            if ($query[$pos+1] == $quote) {  // skip escaped quote
                $pos += 2;
            }
            else {
                if ($in) {
                    $q  = $end;
                    $in = false;
                }
                else {
                    $q  = $start;
                    $in = true;
                }

                $query = substr_replace($query, $q, $pos, 1);
                $pos++;
            }
        }

        return $query;
    }
713106
function QueryString (qs) {
        var parts = qs.split('&');

        for (var i = 0, s = parts.length; i < s; i++) {
            var keyVal = parts[i].split('=');
            var key = decodeURIComponent(keyVal[0].replace(RX_PLUS, ' '));

            if (!key) {
                continue;
            }

            var value = keyVal[1] !== undefined ? decode(keyVal[1]) : null;

            if (typeof this[key] === 'undefined') {
                this[key] = value;
            } else {
                if (!(this[key] instanceof Array)) {
                    this[key] = [this[key]];
                }

                this[key].push(value);
            }
        }
    }
232082
public function getRequestQueryKey()
    {
        $uri = explode('?', $this->getEnv('REQUEST_URI'));

        array_shift($uri);
        parse_str(implode('?', $uri), $qrs);

        return array_keys($qrs);
    }
849566
private function prepareQueryFiler($query)
    {
        $result = [];
        foreach ($query as $key => $value) {
            if (is_array($value)) {
                $result[$key] = $this->prepareQueryFiler($value);
            } elseif (is_string($value) && preg_match('#^(MongoDB\\\\BSON\\\\[A-Za-z]+)\\((.*)\\)$#s', $value, $matches)) {
                $class = $matches[1];
                $objectValue = $matches[1];

                try {
                    $result[$key] = new $class($objectValue);
                } catch (\Exception $e) {
                    $result[$key] = $value;
                }
            } else {
                $result[$key] = $value;
            }
        }
        return $result;
    }
66319
public static function q_assoc_id($q): array
    {
        $res = [];
        $qh = is_string($q) ? self::getInstance()->sql_query($q) : $q;

        while ($q = $qh->fetch(PDO::FETCH_ASSOC)) {
            $res[\current($q)] = $q;
        }

        return $res;
    }
838632
public function search($q)
    {
        $api = new Search($q);
        if (!$this->getHttpClient()) {
            $this->setHttpClient();
        }
        if (!$this->getEntityFactory()) {
            $this->setEntityFactory();
        }
        return $api->registerDiffbot($this);
    }
1166090
public static function parseUrlQuery($query)
    {
        $result = [];
        $pairs = explode('&', $query);
        foreach ($pairs as $pair) {
            $parts = explode('=', $pair);
            $rawKey = $parts[0];
            $rawValue = isset($parts[1]) ? $parts[1] : '';
            $value = urldecode($rawValue);
            $key = strtr(urldecode($rawKey), ['[' => '.', ']' => '']);
            Arr::set($result, $key, $value);
        }
        return $result;
    }