comparison env/lib/python3.7/site-packages/boto/cloudsearch/layer1.py @ 0:26e78fe6e8c4 draft

"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
author shellac
date Sat, 02 May 2020 07:14:21 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:26e78fe6e8c4
1 # Copyright (c) 2012 Mitch Garnaat http://garnaat.org/
2 # Copyright (c) 2012 Amazon.com, Inc. or its affiliates.
3 # All Rights Reserved
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining a
6 # copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish, dis-
9 # tribute, sublicense, and/or sell copies of the Software, and to permit
10 # persons to whom the Software is furnished to do so, subject to the fol-
11 # lowing conditions:
12 #
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
18 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
19 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 # IN THE SOFTWARE.
23
24 import boto
25 import boto.jsonresponse
26 from boto.connection import AWSQueryConnection
27 from boto.regioninfo import RegionInfo
28
29 #boto.set_stream_logger('cloudsearch')
30
31
32 def do_bool(val):
33 return 'true' if val in [True, 1, '1', 'true'] else 'false'
34
35
36 class Layer1(AWSQueryConnection):
37
38 APIVersion = '2011-02-01'
39 DefaultRegionName = boto.config.get('Boto', 'cs_region_name', 'us-east-1')
40 DefaultRegionEndpoint = boto.config.get('Boto', 'cs_region_endpoint',
41 'cloudsearch.us-east-1.amazonaws.com')
42
43 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
44 is_secure=True, host=None, port=None,
45 proxy=None, proxy_port=None,
46 proxy_user=None, proxy_pass=None, debug=0,
47 https_connection_factory=None, region=None, path='/',
48 api_version=None, security_token=None,
49 validate_certs=True, profile_name=None):
50 if not region:
51 region = RegionInfo(self, self.DefaultRegionName,
52 self.DefaultRegionEndpoint)
53 self.region = region
54 AWSQueryConnection.__init__(
55 self,
56 host=self.region.endpoint,
57 aws_access_key_id=aws_access_key_id,
58 aws_secret_access_key=aws_secret_access_key,
59 is_secure=is_secure,
60 port=port,
61 proxy=proxy,
62 proxy_port=proxy_port,
63 proxy_user=proxy_user,
64 proxy_pass=proxy_pass,
65 debug=debug,
66 https_connection_factory=https_connection_factory,
67 path=path,
68 security_token=security_token,
69 validate_certs=validate_certs,
70 profile_name=profile_name)
71
72 def _required_auth_capability(self):
73 return ['hmac-v4']
74
75 def get_response(self, doc_path, action, params, path='/',
76 parent=None, verb='GET', list_marker=None):
77 if not parent:
78 parent = self
79 response = self.make_request(action, params, path, verb)
80 body = response.read()
81 boto.log.debug(body)
82 if response.status == 200:
83 e = boto.jsonresponse.Element(
84 list_marker=list_marker if list_marker else 'Set',
85 pythonize_name=True)
86 h = boto.jsonresponse.XmlHandler(e, parent)
87 h.parse(body)
88 inner = e
89 for p in doc_path:
90 inner = inner.get(p)
91 if not inner:
92 return None if list_marker is None else []
93 if isinstance(inner, list):
94 return inner
95 else:
96 return dict(**inner)
97 else:
98 raise self.ResponseError(response.status, response.reason, body)
99
100 def create_domain(self, domain_name):
101 """
102 Create a new search domain.
103
104 :type domain_name: string
105 :param domain_name: A string that represents the name of a
106 domain. Domain names must be unique across the domains
107 owned by an account within an AWS region. Domain names
108 must start with a letter or number and can contain the
109 following characters: a-z (lowercase), 0-9, and -
110 (hyphen). Uppercase letters and underscores are not
111 allowed.
112
113 :raises: BaseException, InternalException, LimitExceededException
114 """
115 doc_path = ('create_domain_response',
116 'create_domain_result',
117 'domain_status')
118 params = {'DomainName': domain_name}
119 return self.get_response(doc_path, 'CreateDomain',
120 params, verb='POST')
121
122 def define_index_field(self, domain_name, field_name, field_type,
123 default='', facet=False, result=False,
124 searchable=False, source_attributes=None):
125 """
126 Defines an ``IndexField``, either replacing an existing
127 definition or creating a new one.
128
129 :type domain_name: string
130 :param domain_name: A string that represents the name of a
131 domain. Domain names must be unique across the domains
132 owned by an account within an AWS region. Domain names
133 must start with a letter or number and can contain the
134 following characters: a-z (lowercase), 0-9, and -
135 (hyphen). Uppercase letters and underscores are not
136 allowed.
137
138 :type field_name: string
139 :param field_name: The name of a field in the search index.
140
141 :type field_type: string
142 :param field_type: The type of field. Valid values are
143 uint | literal | text
144
145 :type default: string or int
146 :param default: The default value for the field. If the
147 field is of type ``uint`` this should be an integer value.
148 Otherwise, it's a string.
149
150 :type facet: bool
151 :param facet: A boolean to indicate whether facets
152 are enabled for this field or not. Does not apply to
153 fields of type ``uint``.
154
155 :type results: bool
156 :param results: A boolean to indicate whether values
157 of this field can be returned in search results or
158 used in ranking. Does not apply to fields of type ``uint``.
159
160 :type searchable: bool
161 :param searchable: A boolean to indicate whether search
162 is enabled for this field or not. Applies only to fields
163 of type ``literal``.
164
165 :type source_attributes: list of dicts
166 :param source_attributes: An optional list of dicts that
167 provide information about attributes for this index field.
168 A maximum of 20 source attributes can be configured for
169 each index field.
170
171 Each item in the list is a dict with the following keys:
172
173 * data_copy - The value is a dict with the following keys:
174 * default - Optional default value if the source attribute
175 is not specified in a document.
176 * name - The name of the document source field to add
177 to this ``IndexField``.
178 * data_function - Identifies the transformation to apply
179 when copying data from a source attribute.
180 * data_map - The value is a dict with the following keys:
181 * cases - A dict that translates source field values
182 to custom values.
183 * default - An optional default value to use if the
184 source attribute is not specified in a document.
185 * name - the name of the document source field to add
186 to this ``IndexField``
187 * data_trim_title - Trims common title words from a source
188 document attribute when populating an ``IndexField``.
189 This can be used to create an ``IndexField`` you can
190 use for sorting. The value is a dict with the following
191 fields:
192 * default - An optional default value.
193 * language - an IETF RFC 4646 language code.
194 * separator - The separator that follows the text to trim.
195 * name - The name of the document source field to add.
196
197 :raises: BaseException, InternalException, LimitExceededException,
198 InvalidTypeException, ResourceNotFoundException
199 """
200 doc_path = ('define_index_field_response',
201 'define_index_field_result',
202 'index_field')
203 params = {'DomainName': domain_name,
204 'IndexField.IndexFieldName': field_name,
205 'IndexField.IndexFieldType': field_type}
206 if field_type == 'literal':
207 params['IndexField.LiteralOptions.DefaultValue'] = default
208 params['IndexField.LiteralOptions.FacetEnabled'] = do_bool(facet)
209 params['IndexField.LiteralOptions.ResultEnabled'] = do_bool(result)
210 params['IndexField.LiteralOptions.SearchEnabled'] = do_bool(searchable)
211 elif field_type == 'uint':
212 params['IndexField.UIntOptions.DefaultValue'] = default
213 elif field_type == 'text':
214 params['IndexField.TextOptions.DefaultValue'] = default
215 params['IndexField.TextOptions.FacetEnabled'] = do_bool(facet)
216 params['IndexField.TextOptions.ResultEnabled'] = do_bool(result)
217
218 return self.get_response(doc_path, 'DefineIndexField',
219 params, verb='POST')
220
221 def define_rank_expression(self, domain_name, rank_name, rank_expression):
222 """
223 Defines a RankExpression, either replacing an existing
224 definition or creating a new one.
225
226 :type domain_name: string
227 :param domain_name: A string that represents the name of a
228 domain. Domain names must be unique across the domains
229 owned by an account within an AWS region. Domain names
230 must start with a letter or number and can contain the
231 following characters: a-z (lowercase), 0-9, and -
232 (hyphen). Uppercase letters and underscores are not
233 allowed.
234
235 :type rank_name: string
236 :param rank_name: The name of an expression computed for ranking
237 while processing a search request.
238
239 :type rank_expression: string
240 :param rank_expression: The expression to evaluate for ranking
241 or thresholding while processing a search request. The
242 RankExpression syntax is based on JavaScript expressions
243 and supports:
244
245 * Integer, floating point, hex and octal literals
246 * Shortcut evaluation of logical operators such that an
247 expression a || b evaluates to the value a if a is
248 true without evaluting b at all
249 * JavaScript order of precedence for operators
250 * Arithmetic operators: + - * / %
251 * Boolean operators (including the ternary operator)
252 * Bitwise operators
253 * Comparison operators
254 * Common mathematic functions: abs ceil erf exp floor
255 lgamma ln log2 log10 max min sqrt pow
256 * Trigonometric library functions: acosh acos asinh asin
257 atanh atan cosh cos sinh sin tanh tan
258 * Random generation of a number between 0 and 1: rand
259 * Current time in epoch: time
260 * The min max functions that operate on a variable argument list
261
262 Intermediate results are calculated as double precision
263 floating point values. The final return value of a
264 RankExpression is automatically converted from floating
265 point to a 32-bit unsigned integer by rounding to the
266 nearest integer, with a natural floor of 0 and a ceiling
267 of max(uint32_t), 4294967295. Mathematical errors such as
268 dividing by 0 will fail during evaluation and return a
269 value of 0.
270
271 The source data for a RankExpression can be the name of an
272 IndexField of type uint, another RankExpression or the
273 reserved name text_relevance. The text_relevance source is
274 defined to return an integer from 0 to 1000 (inclusive) to
275 indicate how relevant a document is to the search request,
276 taking into account repetition of search terms in the
277 document and proximity of search terms to each other in
278 each matching IndexField in the document.
279
280 For more information about using rank expressions to
281 customize ranking, see the Amazon CloudSearch Developer
282 Guide.
283
284 :raises: BaseException, InternalException, LimitExceededException,
285 InvalidTypeException, ResourceNotFoundException
286 """
287 doc_path = ('define_rank_expression_response',
288 'define_rank_expression_result',
289 'rank_expression')
290 params = {'DomainName': domain_name,
291 'RankExpression.RankExpression': rank_expression,
292 'RankExpression.RankName': rank_name}
293 return self.get_response(doc_path, 'DefineRankExpression',
294 params, verb='POST')
295
296 def delete_domain(self, domain_name):
297 """
298 Delete a search domain.
299
300 :type domain_name: string
301 :param domain_name: A string that represents the name of a
302 domain. Domain names must be unique across the domains
303 owned by an account within an AWS region. Domain names
304 must start with a letter or number and can contain the
305 following characters: a-z (lowercase), 0-9, and -
306 (hyphen). Uppercase letters and underscores are not
307 allowed.
308
309 :raises: BaseException, InternalException
310 """
311 doc_path = ('delete_domain_response',
312 'delete_domain_result',
313 'domain_status')
314 params = {'DomainName': domain_name}
315 return self.get_response(doc_path, 'DeleteDomain',
316 params, verb='POST')
317
318 def delete_index_field(self, domain_name, field_name):
319 """
320 Deletes an existing ``IndexField`` from the search domain.
321
322 :type domain_name: string
323 :param domain_name: A string that represents the name of a
324 domain. Domain names must be unique across the domains
325 owned by an account within an AWS region. Domain names
326 must start with a letter or number and can contain the
327 following characters: a-z (lowercase), 0-9, and -
328 (hyphen). Uppercase letters and underscores are not
329 allowed.
330
331 :type field_name: string
332 :param field_name: A string that represents the name of
333 an index field. Field names must begin with a letter and
334 can contain the following characters: a-z (lowercase),
335 0-9, and _ (underscore). Uppercase letters and hyphens are
336 not allowed. The names "body", "docid", and
337 "text_relevance" are reserved and cannot be specified as
338 field or rank expression names.
339
340 :raises: BaseException, InternalException, ResourceNotFoundException
341 """
342 doc_path = ('delete_index_field_response',
343 'delete_index_field_result',
344 'index_field')
345 params = {'DomainName': domain_name,
346 'IndexFieldName': field_name}
347 return self.get_response(doc_path, 'DeleteIndexField',
348 params, verb='POST')
349
350 def delete_rank_expression(self, domain_name, rank_name):
351 """
352 Deletes an existing ``RankExpression`` from the search domain.
353
354 :type domain_name: string
355 :param domain_name: A string that represents the name of a
356 domain. Domain names must be unique across the domains
357 owned by an account within an AWS region. Domain names
358 must start with a letter or number and can contain the
359 following characters: a-z (lowercase), 0-9, and -
360 (hyphen). Uppercase letters and underscores are not
361 allowed.
362
363 :type rank_name: string
364 :param rank_name: Name of the ``RankExpression`` to delete.
365
366 :raises: BaseException, InternalException, ResourceNotFoundException
367 """
368 doc_path = ('delete_rank_expression_response',
369 'delete_rank_expression_result',
370 'rank_expression')
371 params = {'DomainName': domain_name, 'RankName': rank_name}
372 return self.get_response(doc_path, 'DeleteRankExpression',
373 params, verb='POST')
374
375 def describe_default_search_field(self, domain_name):
376 """
377 Describes options defining the default search field used by
378 indexing for the search domain.
379
380 :type domain_name: string
381 :param domain_name: A string that represents the name of a
382 domain. Domain names must be unique across the domains
383 owned by an account within an AWS region. Domain names
384 must start with a letter or number and can contain the
385 following characters: a-z (lowercase), 0-9, and -
386 (hyphen). Uppercase letters and underscores are not
387 allowed.
388
389 :raises: BaseException, InternalException, ResourceNotFoundException
390 """
391 doc_path = ('describe_default_search_field_response',
392 'describe_default_search_field_result',
393 'default_search_field')
394 params = {'DomainName': domain_name}
395 return self.get_response(doc_path, 'DescribeDefaultSearchField',
396 params, verb='POST')
397
398 def describe_domains(self, domain_names=None):
399 """
400 Describes the domains (optionally limited to one or more
401 domains by name) owned by this account.
402
403 :type domain_names: list
404 :param domain_names: Limits the response to the specified domains.
405
406 :raises: BaseException, InternalException
407 """
408 doc_path = ('describe_domains_response',
409 'describe_domains_result',
410 'domain_status_list')
411 params = {}
412 if domain_names:
413 for i, domain_name in enumerate(domain_names, 1):
414 params['DomainNames.member.%d' % i] = domain_name
415 return self.get_response(doc_path, 'DescribeDomains',
416 params, verb='POST',
417 list_marker='DomainStatusList')
418
419 def describe_index_fields(self, domain_name, field_names=None):
420 """
421 Describes index fields in the search domain, optionally
422 limited to a single ``IndexField``.
423
424 :type domain_name: string
425 :param domain_name: A string that represents the name of a
426 domain. Domain names must be unique across the domains
427 owned by an account within an AWS region. Domain names
428 must start with a letter or number and can contain the
429 following characters: a-z (lowercase), 0-9, and -
430 (hyphen). Uppercase letters and underscores are not
431 allowed.
432
433 :type field_names: list
434 :param field_names: Limits the response to the specified fields.
435
436 :raises: BaseException, InternalException, ResourceNotFoundException
437 """
438 doc_path = ('describe_index_fields_response',
439 'describe_index_fields_result',
440 'index_fields')
441 params = {'DomainName': domain_name}
442 if field_names:
443 for i, field_name in enumerate(field_names, 1):
444 params['FieldNames.member.%d' % i] = field_name
445 return self.get_response(doc_path, 'DescribeIndexFields',
446 params, verb='POST',
447 list_marker='IndexFields')
448
449 def describe_rank_expressions(self, domain_name, rank_names=None):
450 """
451 Describes RankExpressions in the search domain, optionally
452 limited to a single expression.
453
454 :type domain_name: string
455 :param domain_name: A string that represents the name of a
456 domain. Domain names must be unique across the domains
457 owned by an account within an AWS region. Domain names
458 must start with a letter or number and can contain the
459 following characters: a-z (lowercase), 0-9, and -
460 (hyphen). Uppercase letters and underscores are not
461 allowed.
462
463 :type rank_names: list
464 :param rank_names: Limit response to the specified rank names.
465
466 :raises: BaseException, InternalException, ResourceNotFoundException
467 """
468 doc_path = ('describe_rank_expressions_response',
469 'describe_rank_expressions_result',
470 'rank_expressions')
471 params = {'DomainName': domain_name}
472 if rank_names:
473 for i, rank_name in enumerate(rank_names, 1):
474 params['RankNames.member.%d' % i] = rank_name
475 return self.get_response(doc_path, 'DescribeRankExpressions',
476 params, verb='POST',
477 list_marker='RankExpressions')
478
479 def describe_service_access_policies(self, domain_name):
480 """
481 Describes the resource-based policies controlling access to
482 the services in this search domain.
483
484 :type domain_name: string
485 :param domain_name: A string that represents the name of a
486 domain. Domain names must be unique across the domains
487 owned by an account within an AWS region. Domain names
488 must start with a letter or number and can contain the
489 following characters: a-z (lowercase), 0-9, and -
490 (hyphen). Uppercase letters and underscores are not
491 allowed.
492
493 :raises: BaseException, InternalException, ResourceNotFoundException
494 """
495 doc_path = ('describe_service_access_policies_response',
496 'describe_service_access_policies_result',
497 'access_policies')
498 params = {'DomainName': domain_name}
499 return self.get_response(doc_path, 'DescribeServiceAccessPolicies',
500 params, verb='POST')
501
502 def describe_stemming_options(self, domain_name):
503 """
504 Describes stemming options used by indexing for the search domain.
505
506 :type domain_name: string
507 :param domain_name: A string that represents the name of a
508 domain. Domain names must be unique across the domains
509 owned by an account within an AWS region. Domain names
510 must start with a letter or number and can contain the
511 following characters: a-z (lowercase), 0-9, and -
512 (hyphen). Uppercase letters and underscores are not
513 allowed.
514
515 :raises: BaseException, InternalException, ResourceNotFoundException
516 """
517 doc_path = ('describe_stemming_options_response',
518 'describe_stemming_options_result',
519 'stems')
520 params = {'DomainName': domain_name}
521 return self.get_response(doc_path, 'DescribeStemmingOptions',
522 params, verb='POST')
523
524 def describe_stopword_options(self, domain_name):
525 """
526 Describes stopword options used by indexing for the search domain.
527
528 :type domain_name: string
529 :param domain_name: A string that represents the name of a
530 domain. Domain names must be unique across the domains
531 owned by an account within an AWS region. Domain names
532 must start with a letter or number and can contain the
533 following characters: a-z (lowercase), 0-9, and -
534 (hyphen). Uppercase letters and underscores are not
535 allowed.
536
537 :raises: BaseException, InternalException, ResourceNotFoundException
538 """
539 doc_path = ('describe_stopword_options_response',
540 'describe_stopword_options_result',
541 'stopwords')
542 params = {'DomainName': domain_name}
543 return self.get_response(doc_path, 'DescribeStopwordOptions',
544 params, verb='POST')
545
546 def describe_synonym_options(self, domain_name):
547 """
548 Describes synonym options used by indexing for the search domain.
549
550 :type domain_name: string
551 :param domain_name: A string that represents the name of a
552 domain. Domain names must be unique across the domains
553 owned by an account within an AWS region. Domain names
554 must start with a letter or number and can contain the
555 following characters: a-z (lowercase), 0-9, and -
556 (hyphen). Uppercase letters and underscores are not
557 allowed.
558
559 :raises: BaseException, InternalException, ResourceNotFoundException
560 """
561 doc_path = ('describe_synonym_options_response',
562 'describe_synonym_options_result',
563 'synonyms')
564 params = {'DomainName': domain_name}
565 return self.get_response(doc_path, 'DescribeSynonymOptions',
566 params, verb='POST')
567
568 def index_documents(self, domain_name):
569 """
570 Tells the search domain to start scanning its documents using
571 the latest text processing options and ``IndexFields``. This
572 operation must be invoked to make visible in searches any
573 options whose <a>OptionStatus</a> has ``OptionState`` of
574 ``RequiresIndexDocuments``.
575
576 :type domain_name: string
577 :param domain_name: A string that represents the name of a
578 domain. Domain names must be unique across the domains
579 owned by an account within an AWS region. Domain names
580 must start with a letter or number and can contain the
581 following characters: a-z (lowercase), 0-9, and -
582 (hyphen). Uppercase letters and underscores are not
583 allowed.
584
585 :raises: BaseException, InternalException, ResourceNotFoundException
586 """
587 doc_path = ('index_documents_response',
588 'index_documents_result',
589 'field_names')
590 params = {'DomainName': domain_name}
591 return self.get_response(doc_path, 'IndexDocuments', params,
592 verb='POST', list_marker='FieldNames')
593
594 def update_default_search_field(self, domain_name, default_search_field):
595 """
596 Updates options defining the default search field used by
597 indexing for the search domain.
598
599 :type domain_name: string
600 :param domain_name: A string that represents the name of a
601 domain. Domain names must be unique across the domains
602 owned by an account within an AWS region. Domain names
603 must start with a letter or number and can contain the
604 following characters: a-z (lowercase), 0-9, and -
605 (hyphen). Uppercase letters and underscores are not
606 allowed.
607
608 :type default_search_field: string
609 :param default_search_field: The IndexField to use for search
610 requests issued with the q parameter. The default is an
611 empty string, which automatically searches all text
612 fields.
613
614 :raises: BaseException, InternalException, InvalidTypeException,
615 ResourceNotFoundException
616 """
617 doc_path = ('update_default_search_field_response',
618 'update_default_search_field_result',
619 'default_search_field')
620 params = {'DomainName': domain_name,
621 'DefaultSearchField': default_search_field}
622 return self.get_response(doc_path, 'UpdateDefaultSearchField',
623 params, verb='POST')
624
625 def update_service_access_policies(self, domain_name, access_policies):
626 """
627 Updates the policies controlling access to the services in
628 this search domain.
629
630 :type domain_name: string
631 :param domain_name: A string that represents the name of a
632 domain. Domain names must be unique across the domains
633 owned by an account within an AWS region. Domain names
634 must start with a letter or number and can contain the
635 following characters: a-z (lowercase), 0-9, and -
636 (hyphen). Uppercase letters and underscores are not
637 allowed.
638
639 :type access_policies: string
640 :param access_policies: An IAM access policy as described in
641 The Access Policy Language in Using AWS Identity and
642 Access Management. The maximum size of an access policy
643 document is 100KB.
644
645 :raises: BaseException, InternalException, LimitExceededException,
646 ResourceNotFoundException, InvalidTypeException
647 """
648 doc_path = ('update_service_access_policies_response',
649 'update_service_access_policies_result',
650 'access_policies')
651 params = {'AccessPolicies': access_policies,
652 'DomainName': domain_name}
653 return self.get_response(doc_path, 'UpdateServiceAccessPolicies',
654 params, verb='POST')
655
656 def update_stemming_options(self, domain_name, stems):
657 """
658 Updates stemming options used by indexing for the search domain.
659
660 :type domain_name: string
661 :param domain_name: A string that represents the name of a
662 domain. Domain names must be unique across the domains
663 owned by an account within an AWS region. Domain names
664 must start with a letter or number and can contain the
665 following characters: a-z (lowercase), 0-9, and -
666 (hyphen). Uppercase letters and underscores are not
667 allowed.
668
669 :type stems: string
670 :param stems: Maps terms to their stems. The JSON object
671 has a single key called "stems" whose value is a
672 dict mapping terms to their stems. The maximum size
673 of a stemming document is 500KB.
674 Example: {"stems":{"people": "person", "walking":"walk"}}
675
676 :raises: BaseException, InternalException, InvalidTypeException,
677 LimitExceededException, ResourceNotFoundException
678 """
679 doc_path = ('update_stemming_options_response',
680 'update_stemming_options_result',
681 'stems')
682 params = {'DomainName': domain_name,
683 'Stems': stems}
684 return self.get_response(doc_path, 'UpdateStemmingOptions',
685 params, verb='POST')
686
687 def update_stopword_options(self, domain_name, stopwords):
688 """
689 Updates stopword options used by indexing for the search domain.
690
691 :type domain_name: string
692 :param domain_name: A string that represents the name of a
693 domain. Domain names must be unique across the domains
694 owned by an account within an AWS region. Domain names
695 must start with a letter or number and can contain the
696 following characters: a-z (lowercase), 0-9, and -
697 (hyphen). Uppercase letters and underscores are not
698 allowed.
699
700 :type stopwords: string
701 :param stopwords: Lists stopwords in a JSON object. The object has a
702 single key called "stopwords" whose value is an array of strings.
703 The maximum size of a stopwords document is 10KB. Example:
704 {"stopwords": ["a", "an", "the", "of"]}
705
706 :raises: BaseException, InternalException, InvalidTypeException,
707 LimitExceededException, ResourceNotFoundException
708 """
709 doc_path = ('update_stopword_options_response',
710 'update_stopword_options_result',
711 'stopwords')
712 params = {'DomainName': domain_name,
713 'Stopwords': stopwords}
714 return self.get_response(doc_path, 'UpdateStopwordOptions',
715 params, verb='POST')
716
717 def update_synonym_options(self, domain_name, synonyms):
718 """
719 Updates synonym options used by indexing for the search domain.
720
721 :type domain_name: string
722 :param domain_name: A string that represents the name of a
723 domain. Domain names must be unique across the domains
724 owned by an account within an AWS region. Domain names
725 must start with a letter or number and can contain the
726 following characters: a-z (lowercase), 0-9, and -
727 (hyphen). Uppercase letters and underscores are not
728 allowed.
729
730 :type synonyms: string
731 :param synonyms: Maps terms to their synonyms. The JSON object
732 has a single key "synonyms" whose value is a dict mapping terms
733 to their synonyms. Each synonym is a simple string or an
734 array of strings. The maximum size of a stopwords document
735 is 100KB. Example:
736 {"synonyms": {"cat": ["feline", "kitten"], "puppy": "dog"}}
737
738 :raises: BaseException, InternalException, InvalidTypeException,
739 LimitExceededException, ResourceNotFoundException
740 """
741 doc_path = ('update_synonym_options_response',
742 'update_synonym_options_result',
743 'synonyms')
744 params = {'DomainName': domain_name,
745 'Synonyms': synonyms}
746 return self.get_response(doc_path, 'UpdateSynonymOptions',
747 params, verb='POST')