update_default_search_field ( $domain_name, $default_search_field, $opt )

Configures the default search field for the search domain. The default search field is used when a search request does not specify which fields to search. By default, it is configured to include the contents of all of the domain’s text fields.

Access

public

Parameters

Parameter

Type

Required

Description

$domain_name

string

Required

A string that represents the name of a domain. Domain names must be unique across the domains owned by an account within an AWS region. Domain names must start with a letter or number and can contain the following characters: a-z (lowercase), 0-9, and - (hyphen). Uppercase letters and underscores are not allowed. [Constraints: The value must be between 3 and 28 characters, and must match the following regular expression pattern: [a-z][a-z0-9-]+]

$default_search_field

string

Required

The IndexField to use for search requests issued with the q parameter. The default is an empty string, which automatically searches all text fields.

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.

Returns

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response.

Examples

Update and describe the default search field.

// Instantiate the class
$search = new AmazonCloudSearch();

$domain_name = 'my-domain';
$search_field = 'test_field';

/*%**************************************************************%*/
// Create a new CloudSearch domain

echo '# Creating a new CloudSearch domain' . PHP_EOL;
$response = $search->create_domain($domain_name);

// Check for success...
if ($response->isOK())
{
	echo 'Kicked off the creation of the CloudSearch domain...' . PHP_EOL;
}
else
{
	print_r($response);
}

echo PHP_EOL;

/*%**************************************************************%*/
// Define index fields

echo '# Defining a new CloudSearch index field' . PHP_EOL;
$response = $search->define_index_field($domain_name, array(
	'IndexFieldName' => $search_field,
	'IndexFieldType' => 'text',
));

// Check for success...
if ($response->isOK())
{
	echo 'Defined an index field...' . PHP_EOL;
}
else
{
	print_r($response);
}

echo PHP_EOL;

/*%**************************************************************%*/
// Update default search field

sleep(1);

echo "# Update the default search field, \"${domain_name}\"" . PHP_EOL;
$response = $search->update_default_search_field($domain_name, $search_field);

// Check for success...
if ($response->isOK())
{
	echo 'Updated the default search field...' . PHP_EOL;
}
else
{
	print_r($response);
}

echo PHP_EOL;

/*%**************************************************************%*/
// Describe default search field

echo "# Describing the default search field, \"${domain_name}\"" . PHP_EOL;
$response = $search->describe_default_search_field($domain_name);

print_r($response->body->Options()->map_string());

echo PHP_EOL;

/*%**************************************************************%*/
// Delete the CloudSearch domain

echo '# Deleting the CloudSearch domain...' . PHP_EOL;
$response = $search->delete_domain($domain_name);

// Check for success...
if ($response->isOK())
{
	echo 'CloudSearch domain was deleted successfully.' . PHP_EOL;
}
else
{
	print_r($response);
}

Source

Method defined in services/cloudsearch.class.php | Toggle source view (8 lines) | View on GitHub

public function update_default_search_field($domain_name, $default_search_field, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['DomainName'] = $domain_name;
    $opt['DefaultSearchField'] = $default_search_field;
    
    return $this->authenticate('UpdateDefaultSearchField', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback