@@ -1511,6 +1511,7 @@ def query(self,
1511
1511
similar_document_ids=None,
1512
1512
similar_fields=None,
1513
1513
bias=None,
1514
+ spelling_suggestions=None,
1514
1515
x_watson_logging_opt_out=None,
1515
1516
**kwargs):
1516
1517
"""
@@ -1588,6 +1589,12 @@ def query(self,
1588
1589
field is specified, returned results are biased towards higher field
1589
1590
values. This parameter cannot be used in the same query as the **sort**
1590
1591
parameter.
1592
+ :param bool spelling_suggestions: (optional) When `true` and the
1593
+ **natural_language_query** parameter is used, the **natural_languge_query**
1594
+ parameter is spell checked. The most likely correction is retunred in the
1595
+ **suggested_query** field of the response (if one exists).
1596
+ **Important:** this parameter is only valid when using the Cloud Pak
1597
+ version of Discovery.
1591
1598
:param bool x_watson_logging_opt_out: (optional) If `true`, queries are not
1592
1599
stored in the Discovery **Logs** endpoint.
1593
1600
:param dict headers: A `dict` containing the request headers
@@ -1627,7 +1634,8 @@ def query(self,
1627
1634
'similar': similar,
1628
1635
'similar.document_ids': similar_document_ids,
1629
1636
'similar.fields': similar_fields,
1630
- 'bias': bias
1637
+ 'bias': bias,
1638
+ 'spelling_suggestions': spelling_suggestions
1631
1639
}
1632
1640
1633
1641
url = '/v1/environments/{0}/collections/{1}/query'.format(
@@ -2047,6 +2055,63 @@ def federated_query_notices(self,
2047
2055
response = self.send(request)
2048
2056
return response
2049
2057
2058
+ def get_autocompletion(self,
2059
+ environment_id,
2060
+ collection_id,
2061
+ *,
2062
+ field=None,
2063
+ prefix=None,
2064
+ count=None,
2065
+ **kwargs):
2066
+ """
2067
+ Get Autocomplete Suggestions.
2068
+
2069
+ Returns completion query suggestions for the specified prefix. /n/n
2070
+ **Important:** this method is only valid when using the Cloud Pak version of
2071
+ Discovery.
2072
+
2073
+ :param str environment_id: The ID of the environment.
2074
+ :param str collection_id: The ID of the collection.
2075
+ :param str field: (optional) The field in the result documents that
2076
+ autocompletion suggestions are identified from.
2077
+ :param str prefix: (optional) The prefix to use for autocompletion. For
2078
+ example, the prefix `Ho` could autocomplete to `Hot`, `Housing`, or `How do
2079
+ I upgrade`. Possible completions are.
2080
+ :param int count: (optional) The number of autocompletion suggestions to
2081
+ return.
2082
+ :param dict headers: A `dict` containing the request headers
2083
+ :return: A `DetailedResponse` containing the result, headers and HTTP status code.
2084
+ :rtype: DetailedResponse
2085
+ """
2086
+
2087
+ if environment_id is None:
2088
+ raise ValueError('environment_id must be provided')
2089
+ if collection_id is None:
2090
+ raise ValueError('collection_id must be provided')
2091
+
2092
+ headers = {}
2093
+ if 'headers' in kwargs:
2094
+ headers.update(kwargs.get('headers'))
2095
+ sdk_headers = get_sdk_headers('discovery', 'V1', 'get_autocompletion')
2096
+ headers.update(sdk_headers)
2097
+
2098
+ params = {
2099
+ 'version': self.version,
2100
+ 'field': field,
2101
+ 'prefix': prefix,
2102
+ 'count': count
2103
+ }
2104
+
2105
+ url = '/v1/environments/{0}/collections/{1}/autocompletion'.format(
2106
+ *self._encode_path_vars(environment_id, collection_id))
2107
+ request = self.prepare_request(method='GET',
2108
+ url=url,
2109
+ headers=headers,
2110
+ params=params,
2111
+ accept_json=True)
2112
+ response = self.send(request)
2113
+ return response
2114
+
2050
2115
#########################
2051
2116
# Training data
2052
2117
#########################
@@ -3857,6 +3922,59 @@ def __ne__(self, other):
3857
3922
return not self == other
3858
3923
3859
3924
3925
+ class Completions():
3926
+ """
3927
+ An object containing an array of autocompletion suggestions.
3928
+
3929
+ :attr list[str] completions: (optional) Array of autcomplete suggestion based on
3930
+ the provided prefix.
3931
+ """
3932
+
3933
+ def __init__(self, *, completions=None):
3934
+ """
3935
+ Initialize a Completions object.
3936
+
3937
+ :param list[str] completions: (optional) Array of autcomplete suggestion
3938
+ based on the provided prefix.
3939
+ """
3940
+ self.completions = completions
3941
+
3942
+ @classmethod
3943
+ def _from_dict(cls, _dict):
3944
+ """Initialize a Completions object from a json dictionary."""
3945
+ args = {}
3946
+ valid_keys = ['completions']
3947
+ bad_keys = set(_dict.keys()) - set(valid_keys)
3948
+ if bad_keys:
3949
+ raise ValueError(
3950
+ 'Unrecognized keys detected in dictionary for class Completions: '
3951
+ + ', '.join(bad_keys))
3952
+ if 'completions' in _dict:
3953
+ args['completions'] = _dict.get('completions')
3954
+ return cls(**args)
3955
+
3956
+ def _to_dict(self):
3957
+ """Return a json dictionary representing this model."""
3958
+ _dict = {}
3959
+ if hasattr(self, 'completions') and self.completions is not None:
3960
+ _dict['completions'] = self.completions
3961
+ return _dict
3962
+
3963
+ def __str__(self):
3964
+ """Return a `str` version of this Completions object."""
3965
+ return json.dumps(self._to_dict(), indent=2)
3966
+
3967
+ def __eq__(self, other):
3968
+ """Return `true` when self and other are equal, false otherwise."""
3969
+ if not isinstance(other, self.__class__):
3970
+ return False
3971
+ return self.__dict__ == other.__dict__
3972
+
3973
+ def __ne__(self, other):
3974
+ """Return `true` when self and other are not equal, false otherwise."""
3975
+ return not self == other
3976
+
3977
+
3860
3978
class Configuration():
3861
3979
"""
3862
3980
A custom configuration for the environment.
0 commit comments