You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm running into an issue where I am frequently getting the following error:
score() function received unexpected expression
When using the score function.
As mentioned in the title, this error occurs in Sanity Studio Vision, the Sanity CLI using sanity documents query, as well as the Sanity Client in @sanity/client (obviously being the biggest issue).
What's interesting, is that groq-js evaluate produces correct results without errors.
Additionally, I would expect that running score against a regular array (not a document filter) should work. The following query:
[{ "title": "hello" }] | score(title match "hello")
produces the error
score() function cannot be used in its current position
(again, this works using groq-js)
To Reproduce
There are a number of combinations in which I have found this to be the case:
When the value of the field being matched is null or an empty string:
*[]{
"title": null,
_score,
} | score(title match "hello")
When the result doesn't match at all
*[]{
"title": "no match",
_score,
} | score(title match "hello")
When there is a match, but the _score field is excluded from the projection.
*[]{
"title": "hello",
} | score(title match "hello")
Expected behavior
The score function should not be erroring with simple, valid expressions passed to it.
Screenshots
If applicable, add screenshots to help explain your problem.
Any security issues should be submitted directly to [email protected]. In order to determine whether you are dealing with a security issue, ask yourself these two questions:
Can I access something that's not mine, or something I shouldn't have access to?
Can I disable something for other people? If the answer to either of those two questions are "yes", then you're probably dealing with a security issue. Note that even if you answer "no" to both questions, you may still be dealing with a security issue, so if you're unsure, just email us at [[email protected]](mailto:[email protected].
The text was updated successfully, but these errors were encountered:
Describe the bug
I'm running into an issue where I am frequently getting the following error:
When using the score function.
As mentioned in the title, this error occurs in Sanity Studio Vision, the Sanity CLI using
sanity documents query
, as well as the Sanity Client in@sanity/client
(obviously being the biggest issue).What's interesting, is that
groq-js
evaluate produces correct results without errors.Additionally, I would expect that running score against a regular array (not a document filter) should work. The following query:
produces the error
(again, this works using groq-js)
To Reproduce
There are a number of combinations in which I have found this to be the case:
null
or an empty string:_score
field is excluded from the projection.Expected behavior
The score function should not be erroring with simple, valid expressions passed to it.
Screenshots
If applicable, add screenshots to help explain your problem.
Which versions of Sanity are you using?
What operating system are you using?
MacOS
Which versions of Node.js / npm are you running?
Additional context
Add any other context about the problem here.
Security issue?
Any security issues should be submitted directly to [email protected]. In order to determine whether you are dealing with a security issue, ask yourself these two questions:
The text was updated successfully, but these errors were encountered: