Save query with number of results and is spellchecked.

@param QueryModel $query Search query object.

@return void
186772
public function saveSearchResults(QueryModel $query)
    {
        $adapter = $this->getConnection();
        $table = $this->getMainTable();

        $numResults     = $query->getNumResults();
        $isSpellchecked = (int) $query->getIsSpellchecked();

        $saveData = [
            'store_id'        => $query->getStoreId(),
            'query_text'      => $query->getQueryText(),
            'num_results'     => $numResults,
            'is_spellchecked' => $isSpellchecked,
        ];

        $updateData = ['num_results' => $numResults, 'is_spellchecked' => $isSpellchecked];

        $adapter->insertOnDuplicate($table, $saveData, $updateData);
    }
600481
private function _doExecute(Query $query)
    {
        $collection = $this->documentManager->getCollection($this->documentClass);

        if ($this->isScroll()) {
            $scroll = $collection->scroll($query);

            foreach ($scroll as $resultSet) {
                yield $resultSet;
            }
        } else {
            yield $collection->search($query);
        }
    }
1319213
public function run(&$query, $model, $request)
    {
        $this->query = $query;
        $this->getAttributes($model);
        $this->parseRequest($request);

        return $this->query();
    }
12639
public function beforeFind(Model $model, $query) {

		$runtime = $this->runtime[$model->alias];
		if ($runtime) {
			if (!is_array($query['conditions'])) {
				$query['conditions'] = array();
			}
			$conditions = array_filter(array_keys($query['conditions']));

			$fields = $this->_normalizeFields($model);

			foreach ($fields as $flag => $date) {
				if (true === $runtime || $flag === $runtime) {
					if (!in_array($flag, $conditions) && !in_array($model->name . '.' . $flag, $conditions)) {
						$query['conditions'][$model->alias . '.' . $flag] = false;
					}

					if ($flag === $runtime) {
						break;
					}
				}
			}
			return $query;
		}
	}
848554
public function saved(Model $model)
    {
        $tags = $this->processTags(request('tags'));
        $this->syncTags($model, $tags);
    }
536086
protected function checkBindings(string $query, array $bindings)
    {
        $bindingsCountInQuery = $this->countBindingsFromQuery($query);
        $bindingsCount = count($bindings);

        if ($bindingsCountInQuery !== $bindingsCount) {
            throw QueryMapperException::wrongBindingsNumber($bindingsCountInQuery, $bindingsCount);
        }

        $this->checkBindingsPolicy($bindings);
    }
1203863
public static function fix_number_posts_wp_quirk( $query ) {
		if ( isset($query->query) && isset($query->query['numberposts'])
				&& !isset($query->query['posts_per_page']) ) {
			$query->set('posts_per_page', $query->query['numberposts']);
		}
		return $query;
	}
119946
public function count($model)
    {
        $method = 'search_count';

        $condition = $this->condition ?: [[]];

        $result = $this->call($model, $method, $condition);

        //Reset params for future queries.
        $this->resetParams('condition');

        return $this->makeResponse($result, 0);

    }
755790
protected function setQueryCount(string $query)
    {
        if ('' === $query) {
            throw new \InvalidArgumentException('setQueryCount require a valid string argument');
        }
        $this->queryCount = $query;
        $this->countMethod = self::COUNT_METHOD_QUERY;
    }
1131381
public function Search($SearchModel) {
		$SearchModel->AddSearch($this->DiscussionSql($SearchModel));
		$SearchModel->AddSearch($this->CommentSql($SearchModel));
	}
716708
protected function setKeysForSaveQuery(Builder $query)
    {
        $keys = $this->getKeyName();

        if (!is_array($keys)) {
            return parent::setKeysForSaveQuery($query);
        }

        foreach ($keys as $key) {
            $query->where($key, '=', $this->getKeyForSaveQuery($key));
        }

        return $query;
    }
1244120
private function setProperties($query)
    {
        foreach ($query as $property => $value) {
            if (property_exists(get_called_class(), $property)) {
                $this->$property = $value;
            }
        }
    }
684772
public function createSavedSearch($query)
	{
		// Set the API path
		$path = '/saved_searches/create.json';

		// Set POST request data
		$data['query'] = rawurlencode($query);

		// Send the request.
		return $this->sendRequest($path, 'POST', $data);
	}
1021619
protected function verifyLimits (SelectQuery $query) {
        if (empty($query->getLimit())) {
            $query->limit($this->getDefaultLimit());

        } else if ($query->getLimit() > $this->getMaxLimit()) {
            $query->limit($this->getMaxLimit());
        }
    }
825572
protected function setKeysForSaveQuery(Builder $query)
    {
        if (isset($this->attributes[$this->getKeyName()])) {
            return parent::setKeysForSaveQuery($query);
        }

        $query->where($this->foreignKey, $this->getOriginal(
            $this->foreignKey, $this->getAttribute($this->foreignKey)
        ));

        return $query->where($this->relatedKey, $this->getOriginal(
            $this->relatedKey, $this->getAttribute($this->relatedKey)
        ));
    }
1072617
public function createQueryTranslation(Query $query, string $locale): void
    {
        $dbQuery = $this->connection->createQueryBuilder()
            ->insert('ngbm_collection_query_translation')
            ->values(
                [
                    'query_id' => ':query_id',
                    'status' => ':status',
                    'locale' => ':locale',
                    'parameters' => ':parameters',
                ]
            )
            ->setParameter('query_id', $query->id, Type::INTEGER)
            ->setParameter('status', $query->status, Type::INTEGER)
            ->setParameter('locale', $locale, Type::STRING)
            ->setParameter('parameters', $query->parameters[$locale], Type::JSON_ARRAY);

        $dbQuery->execute();
    }
166672
protected function setJoin(Query $query = null)
    {
        $query = $query ?: $this->query;

        $foreignKey = $this->relatedMap->getTable().'.'.$this->secondKey;

        $query->join($this->parentMap->getTable(), $this->getQualifiedParentKeyName(), '=', $foreignKey);
    }