AWS CLI / Boto3 Cloudsearch 验证冲突

AWS CLI / Boto3 Cloudsearch Validation conflict

使用最新的 awscli 包,通过 pip 安装在 python 3. 与 AWS Cloudsearch 有验证冲突:

命令:

user@desktop-09:~$ aws cloudsearch define-analysis-scheme --domain-name domain-clitest --analysis-scheme '{ "AnalysisSchemeName": "stopwords", "AnalysisSchemeLanguage": "en", "AnalysisOptions": {"Stopwords": "http"}}'

Returns 这个错误:

An error occurred (InvalidType) when calling the DefineAnalysisScheme operation: Stopwords must be a json array

然后我将停用词修改为单个元素数组:

user@desktop-09:~$ aws cloudsearch define-analysis-scheme --domain-name domain-clitest --analysis-scheme '{ "AnalysisSchemeName": "stopwords", "AnalysisSchemeLanguage": "en", "AnalysisOptions": {"Stopwords": ["http"]}}'

又失败了,找字符串:

Invalid type for parameter AnalysisScheme.AnalysisOptions.Stopwords, value: ['http'], type: class 'list, valid types: class 'str'

甚至 CLI documentation 似乎也是矛盾的:

Stopwords -> (string)

A JSON array of terms to ignore during indexing and searching. For example, ["a", "an", "the", "of"] . The stopwords dictionary must explicitly list each word you want to ignore. Wildcards and regular expressions are not supported.

谢谢!

所以 Stopwords 是一个字符串值,表示 JSON 在索引和搜索期间要忽略的术语数组:

user@desktop-09:~$ aws cloudsearch define-analysis-scheme --domain-name domain-clitest --analysis-scheme \
'{ "AnalysisSchemeName": "stopwords",\
   "AnalysisSchemeLanguage": "en", \
   "AnalysisOptions": { "Stopwords": "[\"http\"]" }}'