SELECT $prop1 FROM $bucket WHERE type = '$type' AND $bucket.$prop2 = '$value'
It returns one result. When I run this query from the command line, it returns no results:
curl -d "statement=SELECT $prop1 FROM $bucket WHERE type = '$type' AND $bucket.$prop2 = '$value'" -v http://$query_node_url:$port/query -u $user:$password | jq
Please try with exact query text (echo “statement=SELECT $prop1 FROM $bucket WHERE type = ‘$type’ AND $bucket.$prop2 = ‘$value’” ). N1QL $variable is query named parameter.
Post what is the values. Exact query you ran on web console.
There are no actual variables in the request. I have a script evaluates certain variables before sending the request.
It works on one cluster of nodes, but not a different cluster. The clusters are not identical. When I point the script at the second cluster, I get 0 results, when I know 1 exists.
Here’s an example of the query:
SELECT userID FROM userData WHERE type = 'user' AND userData.email = 'email_address@example.com'
That means things normal. same try with curl and see what is difference.
If needed post the output of following commands. Strip out document information if needed.
curl -v -u user:password http://<host>:8093/query/service -H "Content-Type: application/json" -d '{"statement":"SELECT d.* FROM userData AS d WHERE d.type = \"user\" AND d.email = \"email_address@example.com\""}'
curl -v -u user:password http://<host>:8093/query/service -H "Content-Type: application/json" -d '{"statement":"SELECT d.* FROM userData AS d WHERE d.type = \"user\" AND d.email = \"email_address@example.com\"", "profile":"timings"}'
FYI : Percent-encoding - Wikipedia @ is Reserved Characters it might be causing. Try replace with ASCII (i.e. @ with %40) or use curl JSON header as described above.
curl -v -u user:password http://<host>:8093/query/service -H "Content-Type: application/json" -d '{"statement":"SELECT d.* FROM userData AS d WHERE d.type = \"user\" AND d.email = \"email_address@example.com\""}'
worked. I did not need to use percent-encoding for the @.
Do you know why sending JSON worked but ‘statement=’ did not in this one instance?
Already posted in the FYI, curl might be sending whole thing as Content-Type: application/x-www-form-urlencoded , @ is reserved character and interpreted differently and doesn’t match.
In Web console navigate to Query->Monitoring ( /ui/index.html#!/query/monitoring ) then choose Completed and you see exact statement executed with curl