Multi match, match query in multiple fields

@param  string $query
@param  array  $fields
@param  string $fuzziness
@return $this
332965
public function whereMultiMatch(string $query, array $fields, $fuzziness = "auto")
    {
        $param = [
            "multi_match" => [
                "query" => $query,
                "fields" => $fields,
                "fuzziness" => $fuzziness
            ]
        ];
        $this->elasticQuery[] = $param;
        return $this;
    }
486031
public function setQuery($query = null)
    {

        try {

            // need to return << true
            $this->validator->verify($query, ['isNotNull', 'isAcceptLength']);

            if (false === $this->exact) {
                $this->query = ['query' => '%' . $query . '%'];
            }
            else {
                $this->query = ['query' => $query];
            }

        }
        catch(ExceptionFactory $e) {
            echo $e->getMessage();
        }

        return $this;
    }
1042675
public function multiquery($query, $params = []) {

		if(true === is_array($query)) {
			$query = implode(";\n", $query);
		}

		if(false === is_string($query)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string or array, "%s" given', __METHOD__, gettype($query)), E_USER_ERROR);
		}

		$results = new ResultSet([], 'array');

		if(null === $this -> connection) {
			$this -> connect();
		}

		//Escape paramaters
		$query = $this -> escapeSql($query, $params);

		if($this -> connection -> multi_query($query)) {

			$array = [];

			do {

				if($result = $this -> connection -> use_result()) {

					while($row = $result -> fetch_array(MYSQLI_ASSOC)) {
						$array[] = $row;
					}

					$result -> close();
					$results -> append($array);
					$array = [];
				}
			}

			while($this -> connection -> more_results() && $this -> connection -> next_result());
		}

		return $results;
	}
1249978
protected function doFindOne(array $query, array $fields)
    {
        $mongoCollection = $this->mongoCollection;
        return $this->retry(function() use ($mongoCollection, $query, $fields) {
            return $mongoCollection->findOne($query, $fields);
        });
    }
328071
public function boostingQuery($query, $boost = 1) {
		if(empty($this->data['boostingQueries'])) {
			$this->data['boostingQueries'] = array();
		}
		$newBoosting = array(
			'patternQuery' => $query,
			'boost' => $boost
		);
		$this->data['boostingQueries'][] = $newBoosting;
		return $this;
	}
1269113
public function findConcept($query, $options)
    {
        $query->where([
            $this->config('field') => $this->config('states.concept'),
        ]);

        return $query;
    }
507487
def query(self, search, query):
        
        if query:
            if self.fields:
                return search.query('multi_match', fields=self.fields, query=query)
            else:
                return search.query('multi_match', query=query)
        return search
1150597
protected static function query($fields)
    {
        $result = Query::from(static::$table);

        $result = $result->where();

        foreach ($fields as $key => $value) {
            $result = $result->andWhere($key, '=', $value);
        }

        return $result->get();
    }
1093417
protected function process_query(Query $query, array $columns = [], array $defaults = [])
	{
		// Count all items
		$all_items_count = $query->count();

		// Process incoming sorting values
		$sort = [];
		for ($i = 0; $i < \Input::param('iSortingCols'); $i++)
		{
			$sort[\Input::param('iSortCol_'.$i)] = \Input::param('sSortDir_'.$i);
		}

		$i = 0;
		$order_by = [];
		$where = [];
		$global_filter = \Input::param('sSearch');

		foreach ($columns as $key => $value)
		{
			$rels = explode('.', $key);

			$rel = '';

			for ($j=0; $j < count($rels) - 1 and count($rels) > 1; $j++)
			{
				$rel .= '.' . $rels[$j];
				$query->related($rel);
			}

			$value = \Arr::merge($defaults, $value);

			if ($eav = \Arr::get($value, 'eav', false))
			{
				$query->related($rel . '.' . $eav);
			}

			// Order by statement
			if (\Input::param('bSortable_'.$i, true) and \Arr::get($value, 'sort', true) and array_key_exists($i,  $sort))
			{
				$order_by[$key] = $sort[$i];
			}

			$filter = \Input::param('sSearch_'.$i);

			$filter = json_decode($filter);

			if ( ! in_array($filter, array(null, '', 'null')) and \Input::param('bSearchable_'.$i, true) and \Arr::get($value, 'search', true))
			{
				switch (\Arr::get($value, 'type', 'text'))
				{
					case 'select-multiple':
					case 'select':
					case 'enum':
						$query->where($key, 'IN', $filter);
						break;
					case 'select-single':
					case 'number':
						$query->where($key, $filter);
						break;
					case 'text':
						$query->where($key, 'LIKE', '%' . $filter . '%');
						break;
					case 'range':
						$query->where($key, 'BETWEEN', $filter);
						break;
					default:
						break;
				}
			}

			if ( ! empty($global_filter))
			{
				if (\Arr::get($value, 'search', true) === true and \Arr::get($value, 'global', true) === true)
				{
					$where[] = array($key, 'LIKE', '%' . $global_filter . '%');
				}
			}

			$i++;
		}

		if ( ! empty($where))
		{
			$query->where_open();
			foreach ($where as $where)
			{
				$query->or_where($where[0], $where[1], $where[2]);
			}
			$query->where_close();
		}

		// Order query
		$query->order_by($order_by);

		$partial_items_count = $query->count();

		// Limit query
		$query
			->limit(\Input::param('iDisplayLength', 10))
			->offset(\Input::param('iDisplayStart', 0));

		return array($all_items_count, $partial_items_count);
	}
1188224
public function query($query, array $params = [])
    {
        $this->query  = $query;
        $this->params = $params;
        $this->send();

        return $this;
    }
165834
public function prepareQuery($query, $params = false)
    {
        if (isset($params) and is_array($params)) {
            $this->prepareParms($params);
        }

        if (!isset($this->setQuery)) {
            $this->setQuery = $query . ' ';
        } else {
            $this->setQuery .= $this->getQuery() . ' ' . $query . ' ';
        }

        return $this;
    }
954177
public function select($fields = [])
    {
        if (is_array($fields)) {
            foreach ($fields as $field) {
                $this->addSelect($field);
            }
        } elseif (is_string($fields)) {
            $this->addSelect($fields);
        }

        return $this;
    }
560248
protected function _schema($query, $fields = null) {
		$model = $query->model();
		$paths = $query->paths($this);
		$models = $query->models($this);
		$alias = $query->alias();
		$result = [];

		if (!$model) {
			foreach ($fields as $field => $value) {
				if (is_array($value)) {
					$result[$field] = array_keys($value);
				} else {
					$result[''][] = $field;
				}
			}
			return $result;
		}
		if (!$fields) {
			foreach ($paths as $alias => $relation) {
				$model = $models[$alias];
				$result[$relation] = $model::schema()->names();
			}
			return $result;
		}

		$unalias = function ($value) {
			if (is_object($value) && isset($value->scalar)) {
				$value = $value->scalar;
			}
			$aliasing = preg_split("/\s+as\s+/i", $value);
			return isset($aliasing[1]) ? $aliasing[1] : $value;
		};

		if (isset($fields[0])) {
			$raw = array_map($unalias, $fields[0]);
			unset($fields[0]);
		}

		$fields = isset($fields[$alias]) ? [$alias => $fields[$alias]] + $fields : $fields;

		foreach ($fields as $field => $value) {
			if (is_array($value)) {
				if (isset($value['*'])) {
					$relModel = $models[$field];
					$result[$paths[$field]] = $relModel::schema()->names();
				} else {
					$result[$paths[$field]] = array_map($unalias, array_keys($value));
				}
			}
		}

		if (isset($raw)) {
			$result[''] = isset($result['']) ? array_merge($raw, $result['']) : $raw;
		}
		return $result;
	}
288574
public function queryFetch($query, $params = null, $style = null)
    {
        trigger_error('queryFetch() is deprecated in favour of method chaining, eg $sql->query($query, $params)->fetch()', E_USER_DEPRECATED);
        return $this->query($query, $params)->fetch($style);
    }
1014270
public function statements($query, $statements)
    {
        try {
            $query = $this->conn->prepare($query);

            foreach ($statements as $key => $value) {
                $param = $statements[$key][0];
                $value = $statements[$key][1];
                $ifExists = (isset($statements[$key][2]));
                $dataType = $ifExists ? $statements[$key][2] : false;

                switch ($dataType) {
                    case 'bool':
                        $query->bindValue($param, $value, \PDO::PARAM_BOOL);
                        continue;
                    case 'null':
                        $query->bindValue($param, $value, \PDO::PARAM_NULL);
                        continue;
                    case 'int':
                        $query->bindValue($param, $value, \PDO::PARAM_INT);
                        continue;
                    case 'str':
                        $query->bindValue($param, $value, \PDO::PARAM_STR);
                        continue;
                }

                $query->bindValue($param, $value);
            }

            $query->execute();

            return $query;
        } catch (\PDOException $e) {
            $this->error = $e->getMessage();

            return null;
        }
    }
1160023
public function query($query, array $params = [])
    {
        if (!$this->nextQueryIsolationLevel) {
            return $this->retryQuery($query, $params);
        }

        [$oldLevel] = $this->setIsolationLevel($this->nextQueryIsolationLevel);
        $result = $this->retryQuery($query, $params);
        $this->setIsolationLevel($oldLevel);

        return $result;
    }
321126
protected function doFindOne(array $query, array $fields)
    {
        $riakCollection = $this->riakCollection;
        return $this->retry(function() use ($riakCollection, $query, $fields) {
            return $riakCollection->findOne($query, $fields);
        });
    }