Invalid Configuration when saving Synonyms in Cloudsearch via PHP SDK

Asked

Viewed 34 times

1

I’m trying to add synonyms in Cloudsearch via PHP SDK, but it’s always returning "Invalid Configuration". I am using the same configuration for Stopwords and it works normally.

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 insert this JSON directly into the AWS Console it works correctly.

Are any parameters missing? I’m doing something wrong?

1 answer

3


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

Description in 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
            ),
        ),
    ),
));
  • 1

    That’s what it was. I had even tried to pass aliases, but as I moved so much I must have changed something else. Now it worked. Thanks.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.