Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Searching for an empty vector column #2622

Open
4 tasks done
mtruyens opened this issue Oct 6, 2024 · 2 comments
Open
4 tasks done

Searching for an empty vector column #2622

mtruyens opened this issue Oct 6, 2024 · 2 comments

Comments

@mtruyens
Copy link

mtruyens commented Oct 6, 2024

Confirmation Checklist:

  • You have searched for an answer in the manual.
  • You have considered using the forum for general discussions, which can be more suitable for non-urgent or broad queries.
  • You are aware of our community support channels on Slack, Telegram EN, and Telegram RU, where you can interact with other users and our developers.
  • You know about Manticore Team's professional services. Engaging with our experts through a support subscription can significantly accelerate resolution times and provide tailored solutions to your specific needs.

Your question:

Hi, is there a possibility to search for empty vector columns, e.g. similar to what "IS NULL" would do for attributes?

@sanikolaev
Copy link
Collaborator

@mtruyens It seems that the only way to find empty vector columns is with a query like select *, knn_dist() dist from t where knn(v, 1000, (0,0)) and dist = 0.

E.g.:

mysql> drop table if exists t; create table t ( v float_vector knn_type='hnsw' knn_dims='2' hnsw_similarity='l2' ); insert into t(id) values(1); insert into t values(2, (1.2,2.3)); insert into t(id) values(3); select * from t; select *, knn_dist() dist from t where knn(v, 1000, (0,0)) and dist = 0;
--------------
drop table if exists t
--------------

Query OK, 0 rows affected (0.01 sec)

--------------
create table t ( v float_vector knn_type='hnsw' knn_dims='2' hnsw_similarity='l2' )
--------------

Query OK, 0 rows affected (0.00 sec)

--------------
insert into t(id) values(1)
--------------

Query OK, 1 row affected (0.00 sec)

--------------
insert into t values(2, (1.2,2.3))
--------------

Query OK, 1 row affected (0.00 sec)

--------------
insert into t(id) values(3)
--------------

Query OK, 1 row affected (0.00 sec)

--------------
select * from t
--------------

+------+-------------------+
| id   | v                 |
+------+-------------------+
|    2 | 1.200000,2.300000 |
|    3 | 0.000000,0.000000 |
|    1 | 0.000000,0.000000 |
+------+-------------------+
3 rows in set (0.01 sec)
--- 3 out of 3 results in 0ms ---

--------------
select *, knn_dist() dist from t where knn(v, 1000, (0,0)) and dist = 0
--------------

+------+-------------------+-----------+----------+
| id   | v                 | @knn_dist | dist     |
+------+-------------------+-----------+----------+
|    3 | 0.000000,0.000000 |  0.000000 | 0.000000 |
|    1 | 0.000000,0.000000 |  0.000000 | 0.000000 |
+------+-------------------+-----------+----------+
2 rows in set (0.00 sec)
--- 2 out of 2 results in 0ms ---

@mtruyens
Copy link
Author

mtruyens commented Oct 7, 2024

Thanks for the quick reply, that should indeed do the trick!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants