Search code examples
aws-cliamazon-cloudsearch

AWS Cloudsearch CLI with --query-options throwing error


I have a query which I am passing via the command line:

aws cloudsearchdomain --endpoint-url http://myendpt search --search-query value --return _all_fields --cursor initial --size 100 --query-options {"defaultOperator":"or","fields":["id"],"operators":["and","escape","fuzzy","near","not","or","phrase","precedence","prefix","whitespace"]} --query-parser simple --query-parser simple --profile myname

It responds with:

Unknown options: operators:[and, escape, fuzzy, near, not, or, phrase, precedence, prefix, whitespace], fields:[id]

I assure you that id field exists in AWS Cloudsearch. I reverse engineered the query in the online cloudsearch query tester to AWS CLI.

Please help.

Update:

This problem has been resolved in the updated aws-cli/1.8.4. If you are a ubuntu/linux user like me:

please do:

sudo pip uninstall awscli
sudo pip install awscli
aws --version

Solution

  • Summarizing the Asker's solution from the comments: the issue is that you have to double-quote your json param, and then either single-quote (') or escaped-double-quote (\") the json key/values within your param.

    For example, both of these are valid

    --query-options "{'defaultOperator':'and','fields':['name']}"
    

    or

    --query-options "{\"defaultOperator\":\"and\",\"fields\":[\"name\"]}"