Lines Matching refs:query
179 $query = "SELECT cluster || ' ' || lang, COUNT(*) || ' chunks' as cnt
183 $clusters = $this->db->queryKeyValueList($query);
196 * @param string $query JSON encoded vector array
200 public function sqliteCosineSimilarityCallback($query, $embedding)
203 json_decode($query, true, 512, JSON_THROW_ON_ERROR),
262 $query = "DELETE FROM clusters $where";
263 $this->db->exec($query);
264 $query = "UPDATE embeddings SET cluster = NULL $where";
265 $this->db->exec($query);
268 $query = "SELECT id, embedding FROM embeddings $where ORDER BY RANDOM() LIMIT ?";
269 $result = $this->db->queryAll($query, [self::SAMPLE_SIZE]);
279 $query = "SELECT COUNT(*) FROM embeddings $where";
280 $total = $this->db->queryValue($query);
305 $query = 'INSERT INTO clusters (lang, centroid) VALUES (?, ?)';
306 $this->db->exec($query, [$lang, json_encode($centroid, JSON_THROW_ON_ERROR)]);
325 $query = 'SELECT id, embedding, lang FROM embeddings WHERE cluster IS NULL';
326 $handle = $this->db->query($query);
331 $query = 'UPDATE embeddings SET cluster = ? WHERE id = ?';
332 $this->db->exec($query, [$cluster, $record['id']]);
355 $query = "SELECT cluster, centroid
361 $result = $this->db->queryRecord($query, [json_encode($vector, JSON_THROW_ON_ERROR)]);
372 $query = 'SELECT COUNT(*) FROM clusters';
373 return $this->db->queryValue($query) > 0;
385 $query = 'SELECT * FROM embeddings';
386 $handle = $this->db->query($query);