RTF
RTF

Reputation: 6514

AWS CloudSearch request using CLI returns Invalid Javascript Object error

I'm trying to query my AWS Cloudsearch (2013 API) domain using the AWS CLI on Ubuntu. I haven't been able to get it to work successfully when the search is restricted to a specific field. The following query:

aws --profile myprofile cloudsearchdomain search   
    --endpoint-url "https://search-mydomain-abc123xyz.eu-west-1.cloudsearch.amazonaws.com"  
    --query-options {"fields":["my_field"]}  
    --query-parser "simple"  
    --return "my_field"  
    --search-query "foo bar"

...returns the following error:

An error occurred (SearchException) when calling the Search operation: q.options contains invalid javascript object

If I remove the --query-options parameter from the above query, then it works. From the AWS CLI docs regarding the fields options of the --query-options parameter:

An array of the fields to search when no fields are specified in a search... Valid for: simple , structured , lucene , and dismax

aws cli version:

aws-cli/1.11.150 Python/2.7.12 Linux/4.10.0-28-generic botocore/1.7.8

Upvotes: 0

Views: 884

Answers (1)

Frederic Henri
Frederic Henri

Reputation: 53763

I think the documentation is a bit misleading as JSon does not like embedded double quotes inside double quotes, you would need to replace with single quote as

--query-options "{'fields':['my_field']}"

or you can escape the double quote

--query-options "{\"fields\":[\"my_field\"]}"

Upvotes: 2

Related Questions