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

$similarity accepted within projection #633

Closed
hemidactylus opened this issue Nov 10, 2023 · 3 comments · Fixed by #635
Closed

$similarity accepted within projection #633

hemidactylus opened this issue Nov 10, 2023 · 3 comments · Fixed by #635
Assignees

Comments

@hemidactylus
Copy link
Contributor

Dollar-fields raise an UNSUPPORTED_PROJECTION_PARAM error all right, while (perhaps unexpected since there's the includeSimilarity option already to control that) as special case "$similarity": 1 is accepted by the find methods.

ERROR:

curl -XPOST   "${ASTRA_DB_API_ENDPOINT}/api/json/v1/default_keyspace/astra_db_quickstart"   -H "X-Cassandra-Token: $ASTRA_DB_APPLICATION_TOKEN"   -H "Content-Type: application/json"   -d '{
    "findOne": {
      "sort" : {"$vector" : [0.15, 0.1, 0.1, 0.35, 0.55]},
      "projection": {"text": 1, "$similarity": 1, "$pizza": 1},
      "options" : {
        "includeSimilarity" : true
      }
    }
  }' | jq

NO ERRORS (just take out the , "$pizza": 1 bit):

curl -XPOST   "${ASTRA_DB_API_ENDPOINT}/api/json/v1/default_keyspace/astra_db_quickstart"   -H "X-Cassandra-Token: $ASTRA_DB_APPLICATION_TOKEN"   -H "Content-Type: application/json"   -d '{
    "findOne": {
      "sort" : {"$vector" : [0.15, 0.1, 0.1, 0.35, 0.55]},
      "projection": {"text": 1, "$similarity": 1},
      "options" : {
        "includeSimilarity" : true
      }
    }
  }' | jq
@tatu-at-datastax tatu-at-datastax self-assigned this Nov 10, 2023
@tatu-at-datastax
Copy link
Contributor

Thank you for reporting this @hemidactylus.

This does look inconsistent and redundant: while we have some exceptions already ($vector and $vectorize pseudo-fields) this case looks like we should only allow inclusion via includeSimilarity.
I will discuss this with team to know whether behavior needs to be documented or changed.

@vkulichenko
Copy link

+1. $similarity in projection should result in error. It's not part of a document (unlike $vector), so it doesn't belong there.

@tatu-at-datastax
Copy link
Contributor

@vkulichenko That makes sense.

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.

3 participants