Invalid configuration when saving Synonyms in CloudSearch via PHP SDK

1

I'm trying to add synonyms in CloudSearch via PHP SDK, but it's always returning "Invalid configuration". I'm using the same setting for Stopwords and it works fine.

My PHP:

use Aws\CloudSearch\CloudSearchClient;

$this->client = CloudSearchClient::factory(array(
    'key' => MY_KEY,
    'secret' => MY_SECRET,
    'region' => 'us-east-1'
));

$result = $this->client->defineAnalysisScheme(array(
    'DomainName' => MY_DOMAIN,
    'AnalysisScheme' => array(
        'AnalysisSchemeName' => MY_AnalysisSchemeName,
        'AnalysisSchemeLanguage' => 'pt',
        'AnalysisOptions' => array(
            'Synonyms' => $words
        ),
    ),
));

My JSON ($ words):

{
  "batman": [
    "coringa",
    "gordon",
    "joker",
    "robin"
  ],
  "raul": [
    "mango",
    "mangolin"
  ]
}

If I enter this JSON directly into the AWS Console it works correctly.

Is there any parameter missing? Am I doing something wrong?

    
asked by anonymous 12.12.2015 / 00:11

1 answer

3

I think it's because of the lack of aliases (or alternatively a groups ).

Description at documentation :

{
    "groups": [["tool box", "toolbox"], ["band saw", "bandsaw"]],
    "aliases": { "workbench": ["work bench"]}
}

{
    "AnalysisSchemeName": "myscheme",
    "AnalysisSchemeLanguage": "en",
    "AnalysisOptions": {
        Synonyms": "{\"aliases\": {\"youth\": [\"child\",\"kid\"]}}"
    }
} 

Applying to the code

$result = $this->client->defineAnalysisScheme(array(
    'DomainName' => MY_DOMAIN,
    'AnalysisScheme' => array(
        'AnalysisSchemeName' => MY_AnalysisSchemeName,
        'AnalysisSchemeLanguage' => 'pt',
        'AnalysisOptions' => array(
            'Synonyms' => array(
                'aliases' => $words
            ),
        ),
    ),
));
    
12.12.2015 / 00:29