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

Support sorting by vector for API Tables #1559

Closed
amorton opened this issue Oct 17, 2024 · 1 comment · Fixed by #1620
Closed

Support sorting by vector for API Tables #1559

amorton opened this issue Oct 17, 2024 · 1 comment · Fixed by #1620
Assignees

Comments

@amorton
Copy link
Contributor

amorton commented Oct 17, 2024

Given this table CQL:

CREATE TABLE IF NOT EXISTS vector_5 (
  key text,
  comment text, 
  comment_vector VECTOR <FLOAT, 5>,
  PRIMARY KEY (key)
);

CREATE CUSTOM INDEX vector_5_comment_vector_idx ON vector_5(comment_vector) 
  USING 'StorageAttachedIndex';

This insert worked:

{
    "insertOne": {
        "document": 
            {
                "key" : "doc 1",
                "comment": "comment about cheese and monkeys",
                "comment_vector": [0.45, 0.09, 0.01, 0.2, 0.11]
            }
    }
}
{
    "status": {
        "primaryKeySchema": {
            "key": {
                "type": "text"
            }
        },
        "insertedIds": [
            [
                "doc 1"
            ]
        ]
    }
}

Can see this in the table:

cassandra@cqlsh:demo> 
cassandra@cqlsh:demo> select * from vector_5;

 key   | comment                          | comment_vector
-------+----------------------------------+-------------------------------
 doc 1 | comment about cheese and monkeys | [0.45, 0.09, 0.01, 0.2, 0.11]

(1 rows)

But when doing ANN sort:

{
    "find": {
        "sort": 
            {
                "comment_vector": [0.45, 0.09, 0.01, 0.2, 0.11]
            }
    }
}

{
    "errors": [
        {
            "message": "Invalid sort clause value: Sort ordering value can only be `1` for ascending or `-1` for descending (not `[0.45,0.09,0.01,0.2,0.11]`)",
            "errorCode": "INVALID_SORT_CLAUSE_VALUE",
            "id": "af946cb8-61a6-4bfa-81ba-be37586b00f7",
            "family": "REQUEST",
            "title": "Invalid sort clause value",
            "scope": "SORT"
        }
    ]
}

insert working as expected, this ticket is to make sort work as expected.

We will then work on $vecotrize separately.

@amorton amorton self-assigned this Oct 17, 2024
@amorton
Copy link
Contributor Author

amorton commented Oct 17, 2024

Looking at this

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

Successfully merging a pull request may close this issue.

1 participant