aws / aws-sdk-php

Official repository of the AWS SDK for PHP (@awsforphp)
http://aws.amazon.com/sdkforphp
Apache License 2.0
6.02k stars 1.22k forks source link

Invalid configuration Exception in CloudSearch Synonyms #845

Closed raulmangolin closed 8 years ago

raulmangolin commented 8 years ago

I'm trying to add synonyms in CloudSearch via PHP SDK, but always returning "Invalid configuration". I'm using the same configuration for Stopwords and functions normally.

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"
  ],
  "chaves": [
    "bruxa do 71",
    "florinda",
    "kiko",
    "seu barriga",
    "seu madruga",
    "sr barriga"
  ],
  "raul": [
    "mango",
    "mangolin"
  ]
}

If I insert this JSON directly to AWS Console it works correctly.

You are missing some parameter? Am I doing something wrong?

jeskew commented 8 years ago

Can you post the full error?

raulmangolin commented 8 years ago

Sure!

This the full error:

Fatal error: Uncaught Aws\CloudSearch\Exception\InvalidTypeException: AWS Error Code: InvalidType, Status Code: 409, AWS Request ID: 14cd15c7-a05f-11e5-9d81-331d916aa968, AWS Error Type: client, AWS Error Message: Invalid configuration, User-Agent: aws-sdk-php2/2.8.24 Guzzle/3.9.3 curl/7.22.0 PHP/5.5.27-1+deb.sury.org~precise+1 thrown in /var/www/awesome/admin/Vendor/aws/aws-sdk-php/src/Aws/Common/Exception/NamespaceExceptionFactory.php on line 91

raulmangolin commented 8 years ago

@jeskew I found in AWS Documentation a parameter who I haven't see before.

Just need "aliases" parameter in JSON. http://docs.aws.amazon.com/cloudsearch/latest/developerguide/configuring-analysis-schemes.html

I'm sorry for the inconvenience and thank you.

jeskew commented 8 years ago

No worries! Glad you were able to solve the issue.