manticoresoftware / columnar

Manticore Columnar Library
Apache License 2.0
82 stars 13 forks source link

KNN Find-similar-docs-by-id doesn't work as described. #69

Closed pavelnemirovsky closed 1 month ago

pavelnemirovsky commented 1 month ago

Bug Description:

It seems this example with KNN Find-similar-docs-by-id doesn't work as described.

image

Manticore Search Version:

6.3.6

Operating System Version:

Original Docker Container

Have you tried the latest development version?

No

Internal Checklist:

The example was taken from your documentation:

mysql> create table test ( title text, image_vector float_vector knn_type='hnsw' knn_dims='4' hnsw_similarity='l2' );
mysql> insert into test values ( 1, 'yellow bag', (0.653448,0.192478,0.017971,0.339821) ), ( 2, 'white bag', (-0.148894,0.748278,0.091892,-0.095406) );
mysql> select id, knn_dist() from test where knn ( image_vector, 5, (0.286569,-0.031816,0.066684,0.032926), 2000 );
+------+------------+
| id   | knn_dist() |
+------+------------+
|    1 | 0.28146550 |
|    2 | 0.81527930 |
+------+------------+
mysql> select id, knn_dist() from test where knn ( image_vector, 5, 1 );
ERROR 1064 (42000): P01: syntax error, unexpected integer, expecting '(' near '1 )'
mysql> 
djklim87 commented 1 month ago

Are you sure that you runs with EXTRA=1? Cause everything works fine for me

docker run -e EXTRA=1 --name manticore --rm -d manticoresearch/manticore:6.3.6 && echo "Waiting for Manticore docker to start. Consider mapping the data_dir to make it start faster next time" && until docker logs manticore 2>&1 | grep -q "accepting connections"; do sleep 1; echo -n .; done && echo && docker exec -it manticore mysql && docker stop manticore

Unable to find image 'manticoresearch/manticore:6.3.6' locally
6.3.6: Pulling from manticoresearch/manticore
732b09ecef86: Pull complete 
4f4fb700ef54: Pull complete 
Digest: sha256:767c48291e48fdff47f08772e1cc0340f389fb008663a60142825b314710121f
Status: Downloaded newer image for manticoresearch/manticore:6.3.6
2cc1c003c40701dad034c817260e3641fc287861b53e87ccb6babbabcac9e5cb
Waiting for Manticore docker to start. Consider mapping the data_dir to make it start faster next time
....
mysql> show version;
+-----------+----------------------------------+
| Component | Version                          |
+-----------+----------------------------------+
| Daemon    | 6.3.6 593045790@24080214         |
| Columnar  | columnar 2.3.0 88a01c3@24052206  |
| Secondary | secondary 2.3.0 88a01c3@24052206 |
| KNN       | knn 2.3.0 88a01c3@24052206       |
| Buddy     | buddy v2.3.12                    |
+-----------+----------------------------------+
mysql> create table test ( title text, image_vector float_vector knn_type='hnsw' knn_dims='4' hnsw_similarity='l2' );
mysql> insert into test values ( 1, 'yellow bag', (0.653448,0.192478,0.017971,0.339821) ), ( 2, 'white bag', (-0.148894,0.748278,0.091892,-0.095406) );
mysql> select id, knn_dist() from test where knn ( image_vector, 5, (0.286569,-0.031816,0.066684,0.032926), 2000 );
+------+------------+
| id   | knn_dist() |
+------+------------+
|    1 | 0.28146550 |
|    2 | 0.81527930 |
+------+------------+
mysql> select id, knn_dist() from test where knn ( image_vector, 5, 1 );
+------+------------+
| id   | knn_dist() |
+------+------------+
|    2 | 1.14755321 |
+------+------------+
mysql> 
pavelnemirovsky commented 1 month ago

@djklim87 Yes, it works. I used a custom Dockerfile, which is why it seemed like Buddy didn’t load automatically. My bad closing the ticket.

FROM manticoresearch/manticore:6.3.6
ARG CPUTYPE
ENV CPUTYPE=${CPUTYPE}
RUN apt update && apt-get -y install wget
RUN wget https://repo.manticoresearch.com/repository/manticoresearch_bionic/dists/bionic/main/binary-${CPUTYPE}/manticore-columnar-lib_2.3.0-24052206-88a01c3_${CPUTYPE}.deb -O /tmp/manticore-columnar.deb
RUN dpkg -i /tmp/manticore-columnar.deb