azure_cognitiveservices_websearch 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch.rb +69 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/answer.rb +90 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/answer_type.rb +22 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/article.rb +163 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/computation.rb +119 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/creative_work.rb +160 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/error.rb +116 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/error_code.rb +20 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/error_response.rb +89 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/error_sub_code.rb +25 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/freshness.rb +17 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/identifiable.rb +62 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/image_object.rb +199 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/images.rb +210 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/intangible.rb +115 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/media_object.rb +200 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/news.rb +148 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/news_article.rb +159 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/places.rb +135 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/query.rb +100 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/query_context.rb +126 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/ranking_ranking_group.rb +56 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/ranking_ranking_item.rb +116 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/ranking_ranking_response.rb +79 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/related_searches_related_search_answer.rb +135 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/response.rb +72 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/response_base.rb +71 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/safe_search.rb +17 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/search_response.rb +212 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/search_results_answer.rb +126 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/spell_suggestions.rb +141 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/structured_value.rb +115 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/text_format.rb +16 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/thing.rb +131 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/time_zone.rb +157 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/time_zone_time_zone_information.rb +70 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/video_object.rb +295 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/videos.rb +189 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/web_meta_tag.rb +59 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/web_page.rb +251 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/web_web_answer.rb +149 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/models/web_web_grouping.rb +66 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/module_definition.rb +9 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/web.rb +775 -0
- data/lib/1.0/generated/azure_cognitiveservices_websearch/web_search_client.rb +127 -0
- data/lib/azure_cognitiveservices_websearch.rb +6 -0
- data/lib/module_definition.rb +7 -0
- data/lib/profiles/latest/modules/websearch_profile_module.rb +223 -0
- data/lib/profiles/latest/websearch_latest_profile_client.rb +38 -0
- data/lib/profiles/latest/websearch_module_definition.rb +8 -0
- data/lib/version.rb +7 -0
- metadata +171 -0
@@ -0,0 +1,149 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator.
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
+
# regenerated.
|
5
|
+
|
6
|
+
module Azure::CognitiveServices::WebSearch::V1_0
|
7
|
+
module Models
|
8
|
+
#
|
9
|
+
# Defines a list of relevant webpage links.
|
10
|
+
#
|
11
|
+
class WebWebAnswer < SearchResultsAnswer
|
12
|
+
|
13
|
+
include MsRestAzure
|
14
|
+
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@_type = "Web/WebAnswer"
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_accessor :_type
|
21
|
+
|
22
|
+
# @return [Array<WebPage>] A list of webpages that are relevant to the
|
23
|
+
# query.
|
24
|
+
attr_accessor :value
|
25
|
+
|
26
|
+
# @return [Boolean] A Boolean value that indicates whether the response
|
27
|
+
# excluded some results from the answer. If Bing excluded some results,
|
28
|
+
# the value is true.
|
29
|
+
attr_accessor :some_results_removed
|
30
|
+
|
31
|
+
|
32
|
+
#
|
33
|
+
# Mapper for WebWebAnswer class as Ruby Hash.
|
34
|
+
# This will be used for serialization/deserialization.
|
35
|
+
#
|
36
|
+
def self.mapper()
|
37
|
+
{
|
38
|
+
client_side_validation: true,
|
39
|
+
required: false,
|
40
|
+
serialized_name: 'Web/WebAnswer',
|
41
|
+
type: {
|
42
|
+
name: 'Composite',
|
43
|
+
class_name: 'WebWebAnswer',
|
44
|
+
model_properties: {
|
45
|
+
_type: {
|
46
|
+
client_side_validation: true,
|
47
|
+
required: true,
|
48
|
+
serialized_name: '_type',
|
49
|
+
type: {
|
50
|
+
name: 'String'
|
51
|
+
}
|
52
|
+
},
|
53
|
+
id: {
|
54
|
+
client_side_validation: true,
|
55
|
+
required: false,
|
56
|
+
read_only: true,
|
57
|
+
serialized_name: 'id',
|
58
|
+
type: {
|
59
|
+
name: 'String'
|
60
|
+
}
|
61
|
+
},
|
62
|
+
web_search_url: {
|
63
|
+
client_side_validation: true,
|
64
|
+
required: false,
|
65
|
+
read_only: true,
|
66
|
+
serialized_name: 'webSearchUrl',
|
67
|
+
type: {
|
68
|
+
name: 'String'
|
69
|
+
}
|
70
|
+
},
|
71
|
+
follow_up_queries: {
|
72
|
+
client_side_validation: true,
|
73
|
+
required: false,
|
74
|
+
read_only: true,
|
75
|
+
serialized_name: 'followUpQueries',
|
76
|
+
type: {
|
77
|
+
name: 'Sequence',
|
78
|
+
element: {
|
79
|
+
client_side_validation: true,
|
80
|
+
required: false,
|
81
|
+
serialized_name: 'QueryElementType',
|
82
|
+
type: {
|
83
|
+
name: 'Composite',
|
84
|
+
class_name: 'Query'
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
},
|
89
|
+
query_context: {
|
90
|
+
client_side_validation: true,
|
91
|
+
required: false,
|
92
|
+
read_only: true,
|
93
|
+
serialized_name: 'queryContext',
|
94
|
+
type: {
|
95
|
+
name: 'Composite',
|
96
|
+
class_name: 'QueryContext'
|
97
|
+
}
|
98
|
+
},
|
99
|
+
total_estimated_matches: {
|
100
|
+
client_side_validation: true,
|
101
|
+
required: false,
|
102
|
+
read_only: true,
|
103
|
+
serialized_name: 'totalEstimatedMatches',
|
104
|
+
type: {
|
105
|
+
name: 'Number'
|
106
|
+
}
|
107
|
+
},
|
108
|
+
is_family_friendly: {
|
109
|
+
client_side_validation: true,
|
110
|
+
required: false,
|
111
|
+
read_only: true,
|
112
|
+
serialized_name: 'isFamilyFriendly',
|
113
|
+
type: {
|
114
|
+
name: 'Boolean'
|
115
|
+
}
|
116
|
+
},
|
117
|
+
value: {
|
118
|
+
client_side_validation: true,
|
119
|
+
required: true,
|
120
|
+
serialized_name: 'value',
|
121
|
+
type: {
|
122
|
+
name: 'Sequence',
|
123
|
+
element: {
|
124
|
+
client_side_validation: true,
|
125
|
+
required: false,
|
126
|
+
serialized_name: 'WebPageElementType',
|
127
|
+
type: {
|
128
|
+
name: 'Composite',
|
129
|
+
class_name: 'WebPage'
|
130
|
+
}
|
131
|
+
}
|
132
|
+
}
|
133
|
+
},
|
134
|
+
some_results_removed: {
|
135
|
+
client_side_validation: true,
|
136
|
+
required: false,
|
137
|
+
read_only: true,
|
138
|
+
serialized_name: 'someResultsRemoved',
|
139
|
+
type: {
|
140
|
+
name: 'Boolean'
|
141
|
+
}
|
142
|
+
}
|
143
|
+
}
|
144
|
+
}
|
145
|
+
}
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator.
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
+
# regenerated.
|
5
|
+
|
6
|
+
module Azure::CognitiveServices::WebSearch::V1_0
|
7
|
+
module Models
|
8
|
+
#
|
9
|
+
# Model object.
|
10
|
+
#
|
11
|
+
#
|
12
|
+
class WebWebGrouping
|
13
|
+
|
14
|
+
include MsRestAzure
|
15
|
+
|
16
|
+
@@discriminatorMap = Hash.new
|
17
|
+
|
18
|
+
def initialize
|
19
|
+
@_type = "Web/WebGrouping"
|
20
|
+
end
|
21
|
+
|
22
|
+
attr_accessor :_type
|
23
|
+
|
24
|
+
# @return [Array<WebPage>]
|
25
|
+
attr_accessor :web_pages
|
26
|
+
|
27
|
+
|
28
|
+
#
|
29
|
+
# Mapper for WebWebGrouping class as Ruby Hash.
|
30
|
+
# This will be used for serialization/deserialization.
|
31
|
+
#
|
32
|
+
def self.mapper()
|
33
|
+
{
|
34
|
+
client_side_validation: true,
|
35
|
+
required: false,
|
36
|
+
serialized_name: 'Web/WebGrouping',
|
37
|
+
type: {
|
38
|
+
name: 'Composite',
|
39
|
+
polymorphic_discriminator: '_type',
|
40
|
+
uber_parent: 'WebWebGrouping',
|
41
|
+
class_name: 'WebWebGrouping',
|
42
|
+
model_properties: {
|
43
|
+
web_pages: {
|
44
|
+
client_side_validation: true,
|
45
|
+
required: true,
|
46
|
+
serialized_name: 'webPages',
|
47
|
+
type: {
|
48
|
+
name: 'Sequence',
|
49
|
+
element: {
|
50
|
+
client_side_validation: true,
|
51
|
+
required: false,
|
52
|
+
serialized_name: 'WebPageElementType',
|
53
|
+
type: {
|
54
|
+
name: 'Composite',
|
55
|
+
class_name: 'WebPage'
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator.
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
+
# regenerated.
|
5
|
+
|
6
|
+
module Azure end
|
7
|
+
module Azure::CognitiveServices end
|
8
|
+
module Azure::CognitiveServices::WebSearch end
|
9
|
+
module Azure::CognitiveServices::WebSearch::V1_0 end
|
@@ -0,0 +1,775 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator.
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
+
# regenerated.
|
5
|
+
|
6
|
+
module Azure::CognitiveServices::WebSearch::V1_0
|
7
|
+
#
|
8
|
+
# The Web Search API lets you send a search query to Bing and get back search
|
9
|
+
# results that include links to webpages, images, and more.
|
10
|
+
#
|
11
|
+
class Web
|
12
|
+
include MsRestAzure
|
13
|
+
|
14
|
+
#
|
15
|
+
# Creates and initializes a new instance of the Web class.
|
16
|
+
# @param client service class for accessing basic functionality.
|
17
|
+
#
|
18
|
+
def initialize(client)
|
19
|
+
@client = client
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [WebSearchClient] reference to the WebSearchClient
|
23
|
+
attr_reader :client
|
24
|
+
|
25
|
+
#
|
26
|
+
# The Web Search API lets you send a search query to Bing and get back search
|
27
|
+
# results that include links to webpages, images, and more.
|
28
|
+
#
|
29
|
+
# @param query [String] The user's search query term. The term may not be
|
30
|
+
# empty. The term may contain Bing Advanced Operators. For example, to limit
|
31
|
+
# results to a specific domain, use the site: operator.
|
32
|
+
# @param accept_language [String] A comma-delimited list of one or more
|
33
|
+
# languages to use for user interface strings. The list is in decreasing order
|
34
|
+
# of preference. For additional information, including expected format, see
|
35
|
+
# [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
|
36
|
+
# header and the setLang query parameter are mutually exclusive; do not specify
|
37
|
+
# both. If you set this header, you must also specify the cc query parameter.
|
38
|
+
# Bing will use the first supported language it finds from the list, and
|
39
|
+
# combine that language with the cc parameter value to determine the market to
|
40
|
+
# return results for. If the list does not include a supported language, Bing
|
41
|
+
# will find the closest language and market that supports the request, and may
|
42
|
+
# use an aggregated or default market for the results instead of a specified
|
43
|
+
# one. You should use this header and the cc query parameter only if you
|
44
|
+
# specify multiple languages; otherwise, you should use the mkt and setLang
|
45
|
+
# query parameters. A user interface string is a string that's used as a label
|
46
|
+
# in a user interface. There are very few user interface strings in the JSON
|
47
|
+
# response objects. Any links in the response objects to Bing.com properties
|
48
|
+
# will apply the specified language.
|
49
|
+
# @param pragma [String] By default, Bing returns cached content, if available.
|
50
|
+
# To prevent Bing from returning cached content, set the Pragma header to
|
51
|
+
# no-cache (for example, Pragma: no-cache).
|
52
|
+
# @param user_agent [String] The user agent originating the request. Bing uses
|
53
|
+
# the user agent to provide mobile users with an optimized experience. Although
|
54
|
+
# optional, you are strongly encouraged to always specify this header. The
|
55
|
+
# user-agent should be the same string that any commonly used browser would
|
56
|
+
# send. For information about user agents, see [RFC
|
57
|
+
# 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
|
58
|
+
# @param client_id [String] Bing uses this header to provide users with
|
59
|
+
# consistent behavior across Bing API calls. Bing often flights new features
|
60
|
+
# and improvements, and it uses the client ID as a key for assigning traffic on
|
61
|
+
# different flights. If you do not use the same client ID for a user across
|
62
|
+
# multiple requests, then Bing may assign the user to multiple conflicting
|
63
|
+
# flights. Being assigned to multiple conflicting flights can lead to an
|
64
|
+
# inconsistent user experience. For example, if the second request has a
|
65
|
+
# different flight assignment than the first, the experience may be unexpected.
|
66
|
+
# Also, Bing can use the client ID to tailor web results to that client ID’s
|
67
|
+
# search history, providing a richer experience for the user. Bing also uses
|
68
|
+
# this header to help improve result rankings by analyzing the activity
|
69
|
+
# generated by a client ID. The relevance improvements help with better quality
|
70
|
+
# of results delivered by Bing APIs and in turn enables higher click-through
|
71
|
+
# rates for the API consumer. IMPORTANT: Although optional, you should consider
|
72
|
+
# this header required. Persisting the client ID across multiple requests for
|
73
|
+
# the same end user and device combination enables 1) the API consumer to
|
74
|
+
# receive a consistent user experience, and 2) higher click-through rates via
|
75
|
+
# better quality of results from the Bing APIs. Each user that uses your
|
76
|
+
# application on the device must have a unique, Bing generated client ID. If
|
77
|
+
# you do not include this header in the request, Bing generates an ID and
|
78
|
+
# returns it in the X-MSEdge-ClientID response header. The only time that you
|
79
|
+
# should NOT include this header in a request is the first time the user uses
|
80
|
+
# your app on that device. Use the client ID for each Bing API request that
|
81
|
+
# your app makes for this user on the device. Persist the client ID. To persist
|
82
|
+
# the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
|
83
|
+
# used across all sessions. Do not use a session cookie. For other apps such as
|
84
|
+
# mobile apps, use the device's persistent storage to persist the ID. The next
|
85
|
+
# time the user uses your app on that device, get the client ID that you
|
86
|
+
# persisted. Bing responses may or may not include this header. If the response
|
87
|
+
# includes this header, capture the client ID and use it for all subsequent
|
88
|
+
# Bing requests for the user on that device. If you include the
|
89
|
+
# X-MSEdge-ClientID, you must not include cookies in the request.
|
90
|
+
# @param client_ip [String] The IPv4 or IPv6 address of the client device. The
|
91
|
+
# IP address is used to discover the user's location. Bing uses the location
|
92
|
+
# information to determine safe search behavior. Although optional, you are
|
93
|
+
# encouraged to always specify this header and the X-Search-Location header. Do
|
94
|
+
# not obfuscate the address (for example, by changing the last octet to 0).
|
95
|
+
# Obfuscating the address results in the location not being anywhere near the
|
96
|
+
# device's actual location, which may result in Bing serving erroneous results.
|
97
|
+
# @param location [String] A semicolon-delimited list of key/value pairs that
|
98
|
+
# describe the client's geographical location. Bing uses the location
|
99
|
+
# information to determine safe search behavior and to return relevant local
|
100
|
+
# content. Specify the key/value pair as <key>:<value>. The following are the
|
101
|
+
# keys that you use to specify the user's location. lat (required): The
|
102
|
+
# latitude of the client's location, in degrees. The latitude must be greater
|
103
|
+
# than or equal to -90.0 and less than or equal to +90.0. Negative values
|
104
|
+
# indicate southern latitudes and positive values indicate northern latitudes.
|
105
|
+
# long (required): The longitude of the client's location, in degrees. The
|
106
|
+
# longitude must be greater than or equal to -180.0 and less than or equal to
|
107
|
+
# +180.0. Negative values indicate western longitudes and positive values
|
108
|
+
# indicate eastern longitudes. re (required): The radius, in meters, which
|
109
|
+
# specifies the horizontal accuracy of the coordinates. Pass the value returned
|
110
|
+
# by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
|
111
|
+
# 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
|
112
|
+
# (optional): The UTC UNIX timestamp of when the client was at the location.
|
113
|
+
# (The UNIX timestamp is the number of seconds since January 1, 1970.) head
|
114
|
+
# (optional): The client's relative heading or direction of travel. Specify the
|
115
|
+
# direction of travel as degrees from 0 through 360, counting clockwise
|
116
|
+
# relative to true north. Specify this key only if the sp key is nonzero. sp
|
117
|
+
# (optional): The horizontal velocity (speed), in meters per second, that the
|
118
|
+
# client device is traveling. alt (optional): The altitude of the client
|
119
|
+
# device, in meters. are (optional): The radius, in meters, that specifies the
|
120
|
+
# vertical accuracy of the coordinates. Specify this key only if you specify
|
121
|
+
# the alt key. Although many of the keys are optional, the more information
|
122
|
+
# that you provide, the more accurate the location results are. Although
|
123
|
+
# optional, you are encouraged to always specify the user's geographical
|
124
|
+
# location. Providing the location is especially important if the client's IP
|
125
|
+
# address does not accurately reflect the user's physical location (for
|
126
|
+
# example, if the client uses VPN). For optimal results, you should include
|
127
|
+
# this header and the X-MSEdge-ClientIP header, but at a minimum, you should
|
128
|
+
# include this header.
|
129
|
+
# @param answer_count [Integer] The number of answers that you want the
|
130
|
+
# response to include. The answers that Bing returns are based on ranking. For
|
131
|
+
# example, if Bing returns webpages, images, videos, and relatedSearches for a
|
132
|
+
# request and you set this parameter to two (2), the response includes webpages
|
133
|
+
# and images.If you included the responseFilter query parameter in the same
|
134
|
+
# request and set it to webpages and news, the response would include only
|
135
|
+
# webpages.
|
136
|
+
# @param country_code [String] A 2-character country code of the country where
|
137
|
+
# the results come from. This API supports only the United States market. If
|
138
|
+
# you specify this query parameter, it must be set to us. If you set this
|
139
|
+
# parameter, you must also specify the Accept-Language header. Bing uses the
|
140
|
+
# first supported language it finds from the languages list, and combine that
|
141
|
+
# language with the country code that you specify to determine the market to
|
142
|
+
# return results for. If the languages list does not include a supported
|
143
|
+
# language, Bing finds the closest language and market that supports the
|
144
|
+
# request, or it may use an aggregated or default market for the results
|
145
|
+
# instead of a specified one. You should use this query parameter and the
|
146
|
+
# Accept-Language query parameter only if you specify multiple languages;
|
147
|
+
# otherwise, you should use the mkt and setLang query parameters. This
|
148
|
+
# parameter and the mkt query parameter are mutually exclusive—do not specify
|
149
|
+
# both.
|
150
|
+
# @param count [Integer] The number of search results to return in the
|
151
|
+
# response. The default is 10 and the maximum value is 50. The actual number
|
152
|
+
# delivered may be less than requested.Use this parameter along with the offset
|
153
|
+
# parameter to page results.For example, if your user interface displays 10
|
154
|
+
# search results per page, set count to 10 and offset to 0 to get the first
|
155
|
+
# page of results. For each subsequent page, increment offset by 10 (for
|
156
|
+
# example, 0, 10, 20). It is possible for multiple pages to include some
|
157
|
+
# overlap in results.
|
158
|
+
# @param freshness [Freshness] Filter search results by the following age
|
159
|
+
# values: Day—Return webpages that Bing discovered within the last 24 hours.
|
160
|
+
# Week—Return webpages that Bing discovered within the last 7 days.
|
161
|
+
# Month—Return webpages that discovered within the last 30 days. This filter
|
162
|
+
# applies only to webpage results and not to the other results such as news and
|
163
|
+
# images. Possible values include: 'Day', 'Week', 'Month'
|
164
|
+
# @param market [String] The market where the results come from. Typically, mkt
|
165
|
+
# is the country where the user is making the request from. However, it could
|
166
|
+
# be a different country if the user is not located in a country where Bing
|
167
|
+
# delivers results. The market must be in the form <language code>-<country
|
168
|
+
# code>. For example, en-US. The string is case insensitive. If known, you are
|
169
|
+
# encouraged to always specify the market. Specifying the market helps Bing
|
170
|
+
# route the request and return an appropriate and optimal response. If you
|
171
|
+
# specify a market that is not listed in Market Codes, Bing uses a best fit
|
172
|
+
# market code based on an internal mapping that is subject to change. This
|
173
|
+
# parameter and the cc query parameter are mutually exclusive—do not specify
|
174
|
+
# both.
|
175
|
+
# @param offset [Integer] The zero-based offset that indicates the number of
|
176
|
+
# search results to skip before returning results. The default is 0. The offset
|
177
|
+
# should be less than (totalEstimatedMatches - count). Use this parameter along
|
178
|
+
# with the count parameter to page results. For example, if your user interface
|
179
|
+
# displays 10 search results per page, set count to 10 and offset to 0 to get
|
180
|
+
# the first page of results. For each subsequent page, increment offset by 10
|
181
|
+
# (for example, 0, 10, 20). it is possible for multiple pages to include some
|
182
|
+
# overlap in results.
|
183
|
+
# @param promote [Array<AnswerType>] A comma-delimited list of answers that you
|
184
|
+
# want the response to include regardless of their ranking. For example, if you
|
185
|
+
# set answerCount) to two (2) so Bing returns the top two ranked answers, but
|
186
|
+
# you also want the response to include news, you'd set promote to news. If the
|
187
|
+
# top ranked answers are webpages, images, videos, and relatedSearches, the
|
188
|
+
# response includes webpages and images because news is not a ranked answer.
|
189
|
+
# But if you set promote to video, Bing would promote the video answer into the
|
190
|
+
# response and return webpages, images, and videos. The answers that you want
|
191
|
+
# to promote do not count against the answerCount limit. For example, if the
|
192
|
+
# ranked answers are news, images, and videos, and you set answerCount to 1 and
|
193
|
+
# promote to news, the response contains news and images. Or, if the ranked
|
194
|
+
# answers are videos, images, and news, the response contains videos and news.
|
195
|
+
# Possible values are Computation, Images, News, RelatedSearches,
|
196
|
+
# SpellSuggestions, TimeZone, Videos, Webpages. Use only if you specify
|
197
|
+
# answerCount.
|
198
|
+
# @param response_filter [Array<AnswerType>] A comma-delimited list of answers
|
199
|
+
# to include in the response. If you do not specify this parameter, the
|
200
|
+
# response includes all search answers for which there's relevant data.
|
201
|
+
# Possible filter values are Computation, Images, News, RelatedSearches,
|
202
|
+
# SpellSuggestions, TimeZone, Videos, Webpages. Although you may use this
|
203
|
+
# filter to get a single answer, you should instead use the answer-specific
|
204
|
+
# endpoint in order to get richer results. For example, to receive only images,
|
205
|
+
# send the request to one of the Image Search API endpoints. The
|
206
|
+
# RelatedSearches and SpellSuggestions answers do not support a separate
|
207
|
+
# endpoint like the Image Search API does (only the Web Search API returns
|
208
|
+
# them). To include answers that would otherwise be excluded because of
|
209
|
+
# ranking, see the promote query parameter.
|
210
|
+
# @param safe_search [SafeSearch] A filter used to filter adult content. Off:
|
211
|
+
# Return webpages with adult text, images, or videos. Moderate: Return webpages
|
212
|
+
# with adult text, but not adult images or videos. Strict: Do not return
|
213
|
+
# webpages with adult text, images, or videos. The default is Moderate. If the
|
214
|
+
# request comes from a market that Bing's adult policy requires that safeSearch
|
215
|
+
# is set to Strict, Bing ignores the safeSearch value and uses Strict. If you
|
216
|
+
# use the site: query operator, there is the chance that the response may
|
217
|
+
# contain adult content regardless of what the safeSearch query parameter is
|
218
|
+
# set to. Use site: only if you are aware of the content on the site and your
|
219
|
+
# scenario supports the possibility of adult content. Possible values include:
|
220
|
+
# 'Off', 'Moderate', 'Strict'
|
221
|
+
# @param set_lang [String] The language to use for user interface strings.
|
222
|
+
# Specify the language using the ISO 639-1 2-letter language code. For example,
|
223
|
+
# the language code for English is EN. The default is EN (English). Although
|
224
|
+
# optional, you should always specify the language. Typically, you set setLang
|
225
|
+
# to the same language specified by mkt unless the user wants the user
|
226
|
+
# interface strings displayed in a different language. This parameter and the
|
227
|
+
# Accept-Language header are mutually exclusive; do not specify both. A user
|
228
|
+
# interface string is a string that's used as a label in a user interface.
|
229
|
+
# There are few user interface strings in the JSON response objects. Also, any
|
230
|
+
# links to Bing.com properties in the response objects apply the specified
|
231
|
+
# language.
|
232
|
+
# @param text_decorations [Boolean] A Boolean value that determines whether
|
233
|
+
# display strings should contain decoration markers such as hit highlighting
|
234
|
+
# characters. If true, the strings may include markers. The default is false.
|
235
|
+
# To specify whether to use Unicode characters or HTML tags as the markers, see
|
236
|
+
# the textFormat query parameter.
|
237
|
+
# @param text_format [TextFormat] The type of markers to use for text
|
238
|
+
# decorations (see the textDecorations query parameter). Possible values are
|
239
|
+
# Raw—Use Unicode characters to mark content that needs special formatting. The
|
240
|
+
# Unicode characters are in the range E000 through E019. For example, Bing uses
|
241
|
+
# E000 and E001 to mark the beginning and end of query terms for hit
|
242
|
+
# highlighting. HTML—Use HTML tags to mark content that needs special
|
243
|
+
# formatting. For example, use <b> tags to highlight query terms in display
|
244
|
+
# strings. The default is Raw. For display strings that contain escapable HTML
|
245
|
+
# characters such as <, >, and &, if textFormat is set to HTML, Bing escapes
|
246
|
+
# the characters as appropriate (for example, < is escaped to <). Possible
|
247
|
+
# values include: 'Raw', 'Html'
|
248
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
249
|
+
# will be added to the HTTP request.
|
250
|
+
#
|
251
|
+
# @return [SearchResponse] operation results.
|
252
|
+
#
|
253
|
+
def search(query, accept_language:nil, pragma:nil, user_agent:nil, client_id:nil, client_ip:nil, location:nil, answer_count:nil, country_code:nil, count:nil, freshness:nil, market:'en-us', offset:nil, promote:nil, response_filter:nil, safe_search:nil, set_lang:nil, text_decorations:nil, text_format:nil, custom_headers:nil)
|
254
|
+
response = search_async(query, accept_language:accept_language, pragma:pragma, user_agent:user_agent, client_id:client_id, client_ip:client_ip, location:location, answer_count:answer_count, country_code:country_code, count:count, freshness:freshness, market:market, offset:offset, promote:promote, response_filter:response_filter, safe_search:safe_search, set_lang:set_lang, text_decorations:text_decorations, text_format:text_format, custom_headers:custom_headers).value!
|
255
|
+
response.body unless response.nil?
|
256
|
+
end
|
257
|
+
|
258
|
+
#
|
259
|
+
# The Web Search API lets you send a search query to Bing and get back search
|
260
|
+
# results that include links to webpages, images, and more.
|
261
|
+
#
|
262
|
+
# @param query [String] The user's search query term. The term may not be
|
263
|
+
# empty. The term may contain Bing Advanced Operators. For example, to limit
|
264
|
+
# results to a specific domain, use the site: operator.
|
265
|
+
# @param accept_language [String] A comma-delimited list of one or more
|
266
|
+
# languages to use for user interface strings. The list is in decreasing order
|
267
|
+
# of preference. For additional information, including expected format, see
|
268
|
+
# [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
|
269
|
+
# header and the setLang query parameter are mutually exclusive; do not specify
|
270
|
+
# both. If you set this header, you must also specify the cc query parameter.
|
271
|
+
# Bing will use the first supported language it finds from the list, and
|
272
|
+
# combine that language with the cc parameter value to determine the market to
|
273
|
+
# return results for. If the list does not include a supported language, Bing
|
274
|
+
# will find the closest language and market that supports the request, and may
|
275
|
+
# use an aggregated or default market for the results instead of a specified
|
276
|
+
# one. You should use this header and the cc query parameter only if you
|
277
|
+
# specify multiple languages; otherwise, you should use the mkt and setLang
|
278
|
+
# query parameters. A user interface string is a string that's used as a label
|
279
|
+
# in a user interface. There are very few user interface strings in the JSON
|
280
|
+
# response objects. Any links in the response objects to Bing.com properties
|
281
|
+
# will apply the specified language.
|
282
|
+
# @param pragma [String] By default, Bing returns cached content, if available.
|
283
|
+
# To prevent Bing from returning cached content, set the Pragma header to
|
284
|
+
# no-cache (for example, Pragma: no-cache).
|
285
|
+
# @param user_agent [String] The user agent originating the request. Bing uses
|
286
|
+
# the user agent to provide mobile users with an optimized experience. Although
|
287
|
+
# optional, you are strongly encouraged to always specify this header. The
|
288
|
+
# user-agent should be the same string that any commonly used browser would
|
289
|
+
# send. For information about user agents, see [RFC
|
290
|
+
# 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
|
291
|
+
# @param client_id [String] Bing uses this header to provide users with
|
292
|
+
# consistent behavior across Bing API calls. Bing often flights new features
|
293
|
+
# and improvements, and it uses the client ID as a key for assigning traffic on
|
294
|
+
# different flights. If you do not use the same client ID for a user across
|
295
|
+
# multiple requests, then Bing may assign the user to multiple conflicting
|
296
|
+
# flights. Being assigned to multiple conflicting flights can lead to an
|
297
|
+
# inconsistent user experience. For example, if the second request has a
|
298
|
+
# different flight assignment than the first, the experience may be unexpected.
|
299
|
+
# Also, Bing can use the client ID to tailor web results to that client ID’s
|
300
|
+
# search history, providing a richer experience for the user. Bing also uses
|
301
|
+
# this header to help improve result rankings by analyzing the activity
|
302
|
+
# generated by a client ID. The relevance improvements help with better quality
|
303
|
+
# of results delivered by Bing APIs and in turn enables higher click-through
|
304
|
+
# rates for the API consumer. IMPORTANT: Although optional, you should consider
|
305
|
+
# this header required. Persisting the client ID across multiple requests for
|
306
|
+
# the same end user and device combination enables 1) the API consumer to
|
307
|
+
# receive a consistent user experience, and 2) higher click-through rates via
|
308
|
+
# better quality of results from the Bing APIs. Each user that uses your
|
309
|
+
# application on the device must have a unique, Bing generated client ID. If
|
310
|
+
# you do not include this header in the request, Bing generates an ID and
|
311
|
+
# returns it in the X-MSEdge-ClientID response header. The only time that you
|
312
|
+
# should NOT include this header in a request is the first time the user uses
|
313
|
+
# your app on that device. Use the client ID for each Bing API request that
|
314
|
+
# your app makes for this user on the device. Persist the client ID. To persist
|
315
|
+
# the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
|
316
|
+
# used across all sessions. Do not use a session cookie. For other apps such as
|
317
|
+
# mobile apps, use the device's persistent storage to persist the ID. The next
|
318
|
+
# time the user uses your app on that device, get the client ID that you
|
319
|
+
# persisted. Bing responses may or may not include this header. If the response
|
320
|
+
# includes this header, capture the client ID and use it for all subsequent
|
321
|
+
# Bing requests for the user on that device. If you include the
|
322
|
+
# X-MSEdge-ClientID, you must not include cookies in the request.
|
323
|
+
# @param client_ip [String] The IPv4 or IPv6 address of the client device. The
|
324
|
+
# IP address is used to discover the user's location. Bing uses the location
|
325
|
+
# information to determine safe search behavior. Although optional, you are
|
326
|
+
# encouraged to always specify this header and the X-Search-Location header. Do
|
327
|
+
# not obfuscate the address (for example, by changing the last octet to 0).
|
328
|
+
# Obfuscating the address results in the location not being anywhere near the
|
329
|
+
# device's actual location, which may result in Bing serving erroneous results.
|
330
|
+
# @param location [String] A semicolon-delimited list of key/value pairs that
|
331
|
+
# describe the client's geographical location. Bing uses the location
|
332
|
+
# information to determine safe search behavior and to return relevant local
|
333
|
+
# content. Specify the key/value pair as <key>:<value>. The following are the
|
334
|
+
# keys that you use to specify the user's location. lat (required): The
|
335
|
+
# latitude of the client's location, in degrees. The latitude must be greater
|
336
|
+
# than or equal to -90.0 and less than or equal to +90.0. Negative values
|
337
|
+
# indicate southern latitudes and positive values indicate northern latitudes.
|
338
|
+
# long (required): The longitude of the client's location, in degrees. The
|
339
|
+
# longitude must be greater than or equal to -180.0 and less than or equal to
|
340
|
+
# +180.0. Negative values indicate western longitudes and positive values
|
341
|
+
# indicate eastern longitudes. re (required): The radius, in meters, which
|
342
|
+
# specifies the horizontal accuracy of the coordinates. Pass the value returned
|
343
|
+
# by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
|
344
|
+
# 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
|
345
|
+
# (optional): The UTC UNIX timestamp of when the client was at the location.
|
346
|
+
# (The UNIX timestamp is the number of seconds since January 1, 1970.) head
|
347
|
+
# (optional): The client's relative heading or direction of travel. Specify the
|
348
|
+
# direction of travel as degrees from 0 through 360, counting clockwise
|
349
|
+
# relative to true north. Specify this key only if the sp key is nonzero. sp
|
350
|
+
# (optional): The horizontal velocity (speed), in meters per second, that the
|
351
|
+
# client device is traveling. alt (optional): The altitude of the client
|
352
|
+
# device, in meters. are (optional): The radius, in meters, that specifies the
|
353
|
+
# vertical accuracy of the coordinates. Specify this key only if you specify
|
354
|
+
# the alt key. Although many of the keys are optional, the more information
|
355
|
+
# that you provide, the more accurate the location results are. Although
|
356
|
+
# optional, you are encouraged to always specify the user's geographical
|
357
|
+
# location. Providing the location is especially important if the client's IP
|
358
|
+
# address does not accurately reflect the user's physical location (for
|
359
|
+
# example, if the client uses VPN). For optimal results, you should include
|
360
|
+
# this header and the X-MSEdge-ClientIP header, but at a minimum, you should
|
361
|
+
# include this header.
|
362
|
+
# @param answer_count [Integer] The number of answers that you want the
|
363
|
+
# response to include. The answers that Bing returns are based on ranking. For
|
364
|
+
# example, if Bing returns webpages, images, videos, and relatedSearches for a
|
365
|
+
# request and you set this parameter to two (2), the response includes webpages
|
366
|
+
# and images.If you included the responseFilter query parameter in the same
|
367
|
+
# request and set it to webpages and news, the response would include only
|
368
|
+
# webpages.
|
369
|
+
# @param country_code [String] A 2-character country code of the country where
|
370
|
+
# the results come from. This API supports only the United States market. If
|
371
|
+
# you specify this query parameter, it must be set to us. If you set this
|
372
|
+
# parameter, you must also specify the Accept-Language header. Bing uses the
|
373
|
+
# first supported language it finds from the languages list, and combine that
|
374
|
+
# language with the country code that you specify to determine the market to
|
375
|
+
# return results for. If the languages list does not include a supported
|
376
|
+
# language, Bing finds the closest language and market that supports the
|
377
|
+
# request, or it may use an aggregated or default market for the results
|
378
|
+
# instead of a specified one. You should use this query parameter and the
|
379
|
+
# Accept-Language query parameter only if you specify multiple languages;
|
380
|
+
# otherwise, you should use the mkt and setLang query parameters. This
|
381
|
+
# parameter and the mkt query parameter are mutually exclusive—do not specify
|
382
|
+
# both.
|
383
|
+
# @param count [Integer] The number of search results to return in the
|
384
|
+
# response. The default is 10 and the maximum value is 50. The actual number
|
385
|
+
# delivered may be less than requested.Use this parameter along with the offset
|
386
|
+
# parameter to page results.For example, if your user interface displays 10
|
387
|
+
# search results per page, set count to 10 and offset to 0 to get the first
|
388
|
+
# page of results. For each subsequent page, increment offset by 10 (for
|
389
|
+
# example, 0, 10, 20). It is possible for multiple pages to include some
|
390
|
+
# overlap in results.
|
391
|
+
# @param freshness [Freshness] Filter search results by the following age
|
392
|
+
# values: Day—Return webpages that Bing discovered within the last 24 hours.
|
393
|
+
# Week—Return webpages that Bing discovered within the last 7 days.
|
394
|
+
# Month—Return webpages that discovered within the last 30 days. This filter
|
395
|
+
# applies only to webpage results and not to the other results such as news and
|
396
|
+
# images. Possible values include: 'Day', 'Week', 'Month'
|
397
|
+
# @param market [String] The market where the results come from. Typically, mkt
|
398
|
+
# is the country where the user is making the request from. However, it could
|
399
|
+
# be a different country if the user is not located in a country where Bing
|
400
|
+
# delivers results. The market must be in the form <language code>-<country
|
401
|
+
# code>. For example, en-US. The string is case insensitive. If known, you are
|
402
|
+
# encouraged to always specify the market. Specifying the market helps Bing
|
403
|
+
# route the request and return an appropriate and optimal response. If you
|
404
|
+
# specify a market that is not listed in Market Codes, Bing uses a best fit
|
405
|
+
# market code based on an internal mapping that is subject to change. This
|
406
|
+
# parameter and the cc query parameter are mutually exclusive—do not specify
|
407
|
+
# both.
|
408
|
+
# @param offset [Integer] The zero-based offset that indicates the number of
|
409
|
+
# search results to skip before returning results. The default is 0. The offset
|
410
|
+
# should be less than (totalEstimatedMatches - count). Use this parameter along
|
411
|
+
# with the count parameter to page results. For example, if your user interface
|
412
|
+
# displays 10 search results per page, set count to 10 and offset to 0 to get
|
413
|
+
# the first page of results. For each subsequent page, increment offset by 10
|
414
|
+
# (for example, 0, 10, 20). it is possible for multiple pages to include some
|
415
|
+
# overlap in results.
|
416
|
+
# @param promote [Array<AnswerType>] A comma-delimited list of answers that you
|
417
|
+
# want the response to include regardless of their ranking. For example, if you
|
418
|
+
# set answerCount) to two (2) so Bing returns the top two ranked answers, but
|
419
|
+
# you also want the response to include news, you'd set promote to news. If the
|
420
|
+
# top ranked answers are webpages, images, videos, and relatedSearches, the
|
421
|
+
# response includes webpages and images because news is not a ranked answer.
|
422
|
+
# But if you set promote to video, Bing would promote the video answer into the
|
423
|
+
# response and return webpages, images, and videos. The answers that you want
|
424
|
+
# to promote do not count against the answerCount limit. For example, if the
|
425
|
+
# ranked answers are news, images, and videos, and you set answerCount to 1 and
|
426
|
+
# promote to news, the response contains news and images. Or, if the ranked
|
427
|
+
# answers are videos, images, and news, the response contains videos and news.
|
428
|
+
# Possible values are Computation, Images, News, RelatedSearches,
|
429
|
+
# SpellSuggestions, TimeZone, Videos, Webpages. Use only if you specify
|
430
|
+
# answerCount.
|
431
|
+
# @param response_filter [Array<AnswerType>] A comma-delimited list of answers
|
432
|
+
# to include in the response. If you do not specify this parameter, the
|
433
|
+
# response includes all search answers for which there's relevant data.
|
434
|
+
# Possible filter values are Computation, Images, News, RelatedSearches,
|
435
|
+
# SpellSuggestions, TimeZone, Videos, Webpages. Although you may use this
|
436
|
+
# filter to get a single answer, you should instead use the answer-specific
|
437
|
+
# endpoint in order to get richer results. For example, to receive only images,
|
438
|
+
# send the request to one of the Image Search API endpoints. The
|
439
|
+
# RelatedSearches and SpellSuggestions answers do not support a separate
|
440
|
+
# endpoint like the Image Search API does (only the Web Search API returns
|
441
|
+
# them). To include answers that would otherwise be excluded because of
|
442
|
+
# ranking, see the promote query parameter.
|
443
|
+
# @param safe_search [SafeSearch] A filter used to filter adult content. Off:
|
444
|
+
# Return webpages with adult text, images, or videos. Moderate: Return webpages
|
445
|
+
# with adult text, but not adult images or videos. Strict: Do not return
|
446
|
+
# webpages with adult text, images, or videos. The default is Moderate. If the
|
447
|
+
# request comes from a market that Bing's adult policy requires that safeSearch
|
448
|
+
# is set to Strict, Bing ignores the safeSearch value and uses Strict. If you
|
449
|
+
# use the site: query operator, there is the chance that the response may
|
450
|
+
# contain adult content regardless of what the safeSearch query parameter is
|
451
|
+
# set to. Use site: only if you are aware of the content on the site and your
|
452
|
+
# scenario supports the possibility of adult content. Possible values include:
|
453
|
+
# 'Off', 'Moderate', 'Strict'
|
454
|
+
# @param set_lang [String] The language to use for user interface strings.
|
455
|
+
# Specify the language using the ISO 639-1 2-letter language code. For example,
|
456
|
+
# the language code for English is EN. The default is EN (English). Although
|
457
|
+
# optional, you should always specify the language. Typically, you set setLang
|
458
|
+
# to the same language specified by mkt unless the user wants the user
|
459
|
+
# interface strings displayed in a different language. This parameter and the
|
460
|
+
# Accept-Language header are mutually exclusive; do not specify both. A user
|
461
|
+
# interface string is a string that's used as a label in a user interface.
|
462
|
+
# There are few user interface strings in the JSON response objects. Also, any
|
463
|
+
# links to Bing.com properties in the response objects apply the specified
|
464
|
+
# language.
|
465
|
+
# @param text_decorations [Boolean] A Boolean value that determines whether
|
466
|
+
# display strings should contain decoration markers such as hit highlighting
|
467
|
+
# characters. If true, the strings may include markers. The default is false.
|
468
|
+
# To specify whether to use Unicode characters or HTML tags as the markers, see
|
469
|
+
# the textFormat query parameter.
|
470
|
+
# @param text_format [TextFormat] The type of markers to use for text
|
471
|
+
# decorations (see the textDecorations query parameter). Possible values are
|
472
|
+
# Raw—Use Unicode characters to mark content that needs special formatting. The
|
473
|
+
# Unicode characters are in the range E000 through E019. For example, Bing uses
|
474
|
+
# E000 and E001 to mark the beginning and end of query terms for hit
|
475
|
+
# highlighting. HTML—Use HTML tags to mark content that needs special
|
476
|
+
# formatting. For example, use <b> tags to highlight query terms in display
|
477
|
+
# strings. The default is Raw. For display strings that contain escapable HTML
|
478
|
+
# characters such as <, >, and &, if textFormat is set to HTML, Bing escapes
|
479
|
+
# the characters as appropriate (for example, < is escaped to <). Possible
|
480
|
+
# values include: 'Raw', 'Html'
|
481
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
482
|
+
# will be added to the HTTP request.
|
483
|
+
#
|
484
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
485
|
+
#
|
486
|
+
def search_with_http_info(query, accept_language:nil, pragma:nil, user_agent:nil, client_id:nil, client_ip:nil, location:nil, answer_count:nil, country_code:nil, count:nil, freshness:nil, market:'en-us', offset:nil, promote:nil, response_filter:nil, safe_search:nil, set_lang:nil, text_decorations:nil, text_format:nil, custom_headers:nil)
|
487
|
+
search_async(query, accept_language:accept_language, pragma:pragma, user_agent:user_agent, client_id:client_id, client_ip:client_ip, location:location, answer_count:answer_count, country_code:country_code, count:count, freshness:freshness, market:market, offset:offset, promote:promote, response_filter:response_filter, safe_search:safe_search, set_lang:set_lang, text_decorations:text_decorations, text_format:text_format, custom_headers:custom_headers).value!
|
488
|
+
end
|
489
|
+
|
490
|
+
#
|
491
|
+
# The Web Search API lets you send a search query to Bing and get back search
|
492
|
+
# results that include links to webpages, images, and more.
|
493
|
+
#
|
494
|
+
# @param query [String] The user's search query term. The term may not be
|
495
|
+
# empty. The term may contain Bing Advanced Operators. For example, to limit
|
496
|
+
# results to a specific domain, use the site: operator.
|
497
|
+
# @param accept_language [String] A comma-delimited list of one or more
|
498
|
+
# languages to use for user interface strings. The list is in decreasing order
|
499
|
+
# of preference. For additional information, including expected format, see
|
500
|
+
# [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
|
501
|
+
# header and the setLang query parameter are mutually exclusive; do not specify
|
502
|
+
# both. If you set this header, you must also specify the cc query parameter.
|
503
|
+
# Bing will use the first supported language it finds from the list, and
|
504
|
+
# combine that language with the cc parameter value to determine the market to
|
505
|
+
# return results for. If the list does not include a supported language, Bing
|
506
|
+
# will find the closest language and market that supports the request, and may
|
507
|
+
# use an aggregated or default market for the results instead of a specified
|
508
|
+
# one. You should use this header and the cc query parameter only if you
|
509
|
+
# specify multiple languages; otherwise, you should use the mkt and setLang
|
510
|
+
# query parameters. A user interface string is a string that's used as a label
|
511
|
+
# in a user interface. There are very few user interface strings in the JSON
|
512
|
+
# response objects. Any links in the response objects to Bing.com properties
|
513
|
+
# will apply the specified language.
|
514
|
+
# @param pragma [String] By default, Bing returns cached content, if available.
|
515
|
+
# To prevent Bing from returning cached content, set the Pragma header to
|
516
|
+
# no-cache (for example, Pragma: no-cache).
|
517
|
+
# @param user_agent [String] The user agent originating the request. Bing uses
|
518
|
+
# the user agent to provide mobile users with an optimized experience. Although
|
519
|
+
# optional, you are strongly encouraged to always specify this header. The
|
520
|
+
# user-agent should be the same string that any commonly used browser would
|
521
|
+
# send. For information about user agents, see [RFC
|
522
|
+
# 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
|
523
|
+
# @param client_id [String] Bing uses this header to provide users with
|
524
|
+
# consistent behavior across Bing API calls. Bing often flights new features
|
525
|
+
# and improvements, and it uses the client ID as a key for assigning traffic on
|
526
|
+
# different flights. If you do not use the same client ID for a user across
|
527
|
+
# multiple requests, then Bing may assign the user to multiple conflicting
|
528
|
+
# flights. Being assigned to multiple conflicting flights can lead to an
|
529
|
+
# inconsistent user experience. For example, if the second request has a
|
530
|
+
# different flight assignment than the first, the experience may be unexpected.
|
531
|
+
# Also, Bing can use the client ID to tailor web results to that client ID’s
|
532
|
+
# search history, providing a richer experience for the user. Bing also uses
|
533
|
+
# this header to help improve result rankings by analyzing the activity
|
534
|
+
# generated by a client ID. The relevance improvements help with better quality
|
535
|
+
# of results delivered by Bing APIs and in turn enables higher click-through
|
536
|
+
# rates for the API consumer. IMPORTANT: Although optional, you should consider
|
537
|
+
# this header required. Persisting the client ID across multiple requests for
|
538
|
+
# the same end user and device combination enables 1) the API consumer to
|
539
|
+
# receive a consistent user experience, and 2) higher click-through rates via
|
540
|
+
# better quality of results from the Bing APIs. Each user that uses your
|
541
|
+
# application on the device must have a unique, Bing generated client ID. If
|
542
|
+
# you do not include this header in the request, Bing generates an ID and
|
543
|
+
# returns it in the X-MSEdge-ClientID response header. The only time that you
|
544
|
+
# should NOT include this header in a request is the first time the user uses
|
545
|
+
# your app on that device. Use the client ID for each Bing API request that
|
546
|
+
# your app makes for this user on the device. Persist the client ID. To persist
|
547
|
+
# the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
|
548
|
+
# used across all sessions. Do not use a session cookie. For other apps such as
|
549
|
+
# mobile apps, use the device's persistent storage to persist the ID. The next
|
550
|
+
# time the user uses your app on that device, get the client ID that you
|
551
|
+
# persisted. Bing responses may or may not include this header. If the response
|
552
|
+
# includes this header, capture the client ID and use it for all subsequent
|
553
|
+
# Bing requests for the user on that device. If you include the
|
554
|
+
# X-MSEdge-ClientID, you must not include cookies in the request.
|
555
|
+
# @param client_ip [String] The IPv4 or IPv6 address of the client device. The
|
556
|
+
# IP address is used to discover the user's location. Bing uses the location
|
557
|
+
# information to determine safe search behavior. Although optional, you are
|
558
|
+
# encouraged to always specify this header and the X-Search-Location header. Do
|
559
|
+
# not obfuscate the address (for example, by changing the last octet to 0).
|
560
|
+
# Obfuscating the address results in the location not being anywhere near the
|
561
|
+
# device's actual location, which may result in Bing serving erroneous results.
|
562
|
+
# @param location [String] A semicolon-delimited list of key/value pairs that
|
563
|
+
# describe the client's geographical location. Bing uses the location
|
564
|
+
# information to determine safe search behavior and to return relevant local
|
565
|
+
# content. Specify the key/value pair as <key>:<value>. The following are the
|
566
|
+
# keys that you use to specify the user's location. lat (required): The
|
567
|
+
# latitude of the client's location, in degrees. The latitude must be greater
|
568
|
+
# than or equal to -90.0 and less than or equal to +90.0. Negative values
|
569
|
+
# indicate southern latitudes and positive values indicate northern latitudes.
|
570
|
+
# long (required): The longitude of the client's location, in degrees. The
|
571
|
+
# longitude must be greater than or equal to -180.0 and less than or equal to
|
572
|
+
# +180.0. Negative values indicate western longitudes and positive values
|
573
|
+
# indicate eastern longitudes. re (required): The radius, in meters, which
|
574
|
+
# specifies the horizontal accuracy of the coordinates. Pass the value returned
|
575
|
+
# by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
|
576
|
+
# 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
|
577
|
+
# (optional): The UTC UNIX timestamp of when the client was at the location.
|
578
|
+
# (The UNIX timestamp is the number of seconds since January 1, 1970.) head
|
579
|
+
# (optional): The client's relative heading or direction of travel. Specify the
|
580
|
+
# direction of travel as degrees from 0 through 360, counting clockwise
|
581
|
+
# relative to true north. Specify this key only if the sp key is nonzero. sp
|
582
|
+
# (optional): The horizontal velocity (speed), in meters per second, that the
|
583
|
+
# client device is traveling. alt (optional): The altitude of the client
|
584
|
+
# device, in meters. are (optional): The radius, in meters, that specifies the
|
585
|
+
# vertical accuracy of the coordinates. Specify this key only if you specify
|
586
|
+
# the alt key. Although many of the keys are optional, the more information
|
587
|
+
# that you provide, the more accurate the location results are. Although
|
588
|
+
# optional, you are encouraged to always specify the user's geographical
|
589
|
+
# location. Providing the location is especially important if the client's IP
|
590
|
+
# address does not accurately reflect the user's physical location (for
|
591
|
+
# example, if the client uses VPN). For optimal results, you should include
|
592
|
+
# this header and the X-MSEdge-ClientIP header, but at a minimum, you should
|
593
|
+
# include this header.
|
594
|
+
# @param answer_count [Integer] The number of answers that you want the
|
595
|
+
# response to include. The answers that Bing returns are based on ranking. For
|
596
|
+
# example, if Bing returns webpages, images, videos, and relatedSearches for a
|
597
|
+
# request and you set this parameter to two (2), the response includes webpages
|
598
|
+
# and images.If you included the responseFilter query parameter in the same
|
599
|
+
# request and set it to webpages and news, the response would include only
|
600
|
+
# webpages.
|
601
|
+
# @param country_code [String] A 2-character country code of the country where
|
602
|
+
# the results come from. This API supports only the United States market. If
|
603
|
+
# you specify this query parameter, it must be set to us. If you set this
|
604
|
+
# parameter, you must also specify the Accept-Language header. Bing uses the
|
605
|
+
# first supported language it finds from the languages list, and combine that
|
606
|
+
# language with the country code that you specify to determine the market to
|
607
|
+
# return results for. If the languages list does not include a supported
|
608
|
+
# language, Bing finds the closest language and market that supports the
|
609
|
+
# request, or it may use an aggregated or default market for the results
|
610
|
+
# instead of a specified one. You should use this query parameter and the
|
611
|
+
# Accept-Language query parameter only if you specify multiple languages;
|
612
|
+
# otherwise, you should use the mkt and setLang query parameters. This
|
613
|
+
# parameter and the mkt query parameter are mutually exclusive—do not specify
|
614
|
+
# both.
|
615
|
+
# @param count [Integer] The number of search results to return in the
|
616
|
+
# response. The default is 10 and the maximum value is 50. The actual number
|
617
|
+
# delivered may be less than requested.Use this parameter along with the offset
|
618
|
+
# parameter to page results.For example, if your user interface displays 10
|
619
|
+
# search results per page, set count to 10 and offset to 0 to get the first
|
620
|
+
# page of results. For each subsequent page, increment offset by 10 (for
|
621
|
+
# example, 0, 10, 20). It is possible for multiple pages to include some
|
622
|
+
# overlap in results.
|
623
|
+
# @param freshness [Freshness] Filter search results by the following age
|
624
|
+
# values: Day—Return webpages that Bing discovered within the last 24 hours.
|
625
|
+
# Week—Return webpages that Bing discovered within the last 7 days.
|
626
|
+
# Month—Return webpages that discovered within the last 30 days. This filter
|
627
|
+
# applies only to webpage results and not to the other results such as news and
|
628
|
+
# images. Possible values include: 'Day', 'Week', 'Month'
|
629
|
+
# @param market [String] The market where the results come from. Typically, mkt
|
630
|
+
# is the country where the user is making the request from. However, it could
|
631
|
+
# be a different country if the user is not located in a country where Bing
|
632
|
+
# delivers results. The market must be in the form <language code>-<country
|
633
|
+
# code>. For example, en-US. The string is case insensitive. If known, you are
|
634
|
+
# encouraged to always specify the market. Specifying the market helps Bing
|
635
|
+
# route the request and return an appropriate and optimal response. If you
|
636
|
+
# specify a market that is not listed in Market Codes, Bing uses a best fit
|
637
|
+
# market code based on an internal mapping that is subject to change. This
|
638
|
+
# parameter and the cc query parameter are mutually exclusive—do not specify
|
639
|
+
# both.
|
640
|
+
# @param offset [Integer] The zero-based offset that indicates the number of
|
641
|
+
# search results to skip before returning results. The default is 0. The offset
|
642
|
+
# should be less than (totalEstimatedMatches - count). Use this parameter along
|
643
|
+
# with the count parameter to page results. For example, if your user interface
|
644
|
+
# displays 10 search results per page, set count to 10 and offset to 0 to get
|
645
|
+
# the first page of results. For each subsequent page, increment offset by 10
|
646
|
+
# (for example, 0, 10, 20). it is possible for multiple pages to include some
|
647
|
+
# overlap in results.
|
648
|
+
# @param promote [Array<AnswerType>] A comma-delimited list of answers that you
|
649
|
+
# want the response to include regardless of their ranking. For example, if you
|
650
|
+
# set answerCount) to two (2) so Bing returns the top two ranked answers, but
|
651
|
+
# you also want the response to include news, you'd set promote to news. If the
|
652
|
+
# top ranked answers are webpages, images, videos, and relatedSearches, the
|
653
|
+
# response includes webpages and images because news is not a ranked answer.
|
654
|
+
# But if you set promote to video, Bing would promote the video answer into the
|
655
|
+
# response and return webpages, images, and videos. The answers that you want
|
656
|
+
# to promote do not count against the answerCount limit. For example, if the
|
657
|
+
# ranked answers are news, images, and videos, and you set answerCount to 1 and
|
658
|
+
# promote to news, the response contains news and images. Or, if the ranked
|
659
|
+
# answers are videos, images, and news, the response contains videos and news.
|
660
|
+
# Possible values are Computation, Images, News, RelatedSearches,
|
661
|
+
# SpellSuggestions, TimeZone, Videos, Webpages. Use only if you specify
|
662
|
+
# answerCount.
|
663
|
+
# @param response_filter [Array<AnswerType>] A comma-delimited list of answers
|
664
|
+
# to include in the response. If you do not specify this parameter, the
|
665
|
+
# response includes all search answers for which there's relevant data.
|
666
|
+
# Possible filter values are Computation, Images, News, RelatedSearches,
|
667
|
+
# SpellSuggestions, TimeZone, Videos, Webpages. Although you may use this
|
668
|
+
# filter to get a single answer, you should instead use the answer-specific
|
669
|
+
# endpoint in order to get richer results. For example, to receive only images,
|
670
|
+
# send the request to one of the Image Search API endpoints. The
|
671
|
+
# RelatedSearches and SpellSuggestions answers do not support a separate
|
672
|
+
# endpoint like the Image Search API does (only the Web Search API returns
|
673
|
+
# them). To include answers that would otherwise be excluded because of
|
674
|
+
# ranking, see the promote query parameter.
|
675
|
+
# @param safe_search [SafeSearch] A filter used to filter adult content. Off:
|
676
|
+
# Return webpages with adult text, images, or videos. Moderate: Return webpages
|
677
|
+
# with adult text, but not adult images or videos. Strict: Do not return
|
678
|
+
# webpages with adult text, images, or videos. The default is Moderate. If the
|
679
|
+
# request comes from a market that Bing's adult policy requires that safeSearch
|
680
|
+
# is set to Strict, Bing ignores the safeSearch value and uses Strict. If you
|
681
|
+
# use the site: query operator, there is the chance that the response may
|
682
|
+
# contain adult content regardless of what the safeSearch query parameter is
|
683
|
+
# set to. Use site: only if you are aware of the content on the site and your
|
684
|
+
# scenario supports the possibility of adult content. Possible values include:
|
685
|
+
# 'Off', 'Moderate', 'Strict'
|
686
|
+
# @param set_lang [String] The language to use for user interface strings.
|
687
|
+
# Specify the language using the ISO 639-1 2-letter language code. For example,
|
688
|
+
# the language code for English is EN. The default is EN (English). Although
|
689
|
+
# optional, you should always specify the language. Typically, you set setLang
|
690
|
+
# to the same language specified by mkt unless the user wants the user
|
691
|
+
# interface strings displayed in a different language. This parameter and the
|
692
|
+
# Accept-Language header are mutually exclusive; do not specify both. A user
|
693
|
+
# interface string is a string that's used as a label in a user interface.
|
694
|
+
# There are few user interface strings in the JSON response objects. Also, any
|
695
|
+
# links to Bing.com properties in the response objects apply the specified
|
696
|
+
# language.
|
697
|
+
# @param text_decorations [Boolean] A Boolean value that determines whether
|
698
|
+
# display strings should contain decoration markers such as hit highlighting
|
699
|
+
# characters. If true, the strings may include markers. The default is false.
|
700
|
+
# To specify whether to use Unicode characters or HTML tags as the markers, see
|
701
|
+
# the textFormat query parameter.
|
702
|
+
# @param text_format [TextFormat] The type of markers to use for text
|
703
|
+
# decorations (see the textDecorations query parameter). Possible values are
|
704
|
+
# Raw—Use Unicode characters to mark content that needs special formatting. The
|
705
|
+
# Unicode characters are in the range E000 through E019. For example, Bing uses
|
706
|
+
# E000 and E001 to mark the beginning and end of query terms for hit
|
707
|
+
# highlighting. HTML—Use HTML tags to mark content that needs special
|
708
|
+
# formatting. For example, use <b> tags to highlight query terms in display
|
709
|
+
# strings. The default is Raw. For display strings that contain escapable HTML
|
710
|
+
# characters such as <, >, and &, if textFormat is set to HTML, Bing escapes
|
711
|
+
# the characters as appropriate (for example, < is escaped to <). Possible
|
712
|
+
# values include: 'Raw', 'Html'
|
713
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
714
|
+
# to the HTTP request.
|
715
|
+
#
|
716
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
717
|
+
#
|
718
|
+
def search_async(query, accept_language:nil, pragma:nil, user_agent:nil, client_id:nil, client_ip:nil, location:nil, answer_count:nil, country_code:nil, count:nil, freshness:nil, market:'en-us', offset:nil, promote:nil, response_filter:nil, safe_search:nil, set_lang:nil, text_decorations:nil, text_format:nil, custom_headers:nil)
|
719
|
+
x_bing_apis_sdk = 'true'
|
720
|
+
fail ArgumentError, 'query is nil' if query.nil?
|
721
|
+
|
722
|
+
|
723
|
+
request_headers = {}
|
724
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
725
|
+
|
726
|
+
# Set Headers
|
727
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
728
|
+
request_headers['X-BingApis-SDK'] = x_bing_apis_sdk unless x_bing_apis_sdk.nil?
|
729
|
+
request_headers['Accept-Language'] = accept_language unless accept_language.nil?
|
730
|
+
request_headers['Pragma'] = pragma unless pragma.nil?
|
731
|
+
request_headers['User-Agent'] = user_agent unless user_agent.nil?
|
732
|
+
request_headers['X-MSEdge-ClientID'] = client_id unless client_id.nil?
|
733
|
+
request_headers['X-MSEdge-ClientIP'] = client_ip unless client_ip.nil?
|
734
|
+
request_headers['X-Search-Location'] = location unless location.nil?
|
735
|
+
path_template = 'search'
|
736
|
+
|
737
|
+
request_url = @base_url || @client.base_url
|
738
|
+
|
739
|
+
options = {
|
740
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
741
|
+
query_params: {'answerCount' => answer_count,'cc' => country_code,'count' => count,'freshness' => freshness,'mkt' => market,'offset' => offset,'promote' => promote.nil? ? nil : promote.join(','),'q' => query,'responseFilter' => response_filter.nil? ? nil : response_filter.join(','),'safeSearch' => safe_search,'setLang' => set_lang,'textDecorations' => text_decorations,'textFormat' => text_format},
|
742
|
+
headers: request_headers.merge(custom_headers || {}),
|
743
|
+
base_url: request_url
|
744
|
+
}
|
745
|
+
promise = @client.make_request_async(:get, path_template, options)
|
746
|
+
|
747
|
+
promise = promise.then do |result|
|
748
|
+
http_response = result.response
|
749
|
+
status_code = http_response.status
|
750
|
+
response_content = http_response.body
|
751
|
+
unless status_code == 200
|
752
|
+
error_model = JSON.load(response_content)
|
753
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
754
|
+
end
|
755
|
+
|
756
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
757
|
+
# Deserialize Response
|
758
|
+
if status_code == 200
|
759
|
+
begin
|
760
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
761
|
+
result_mapper = Azure::CognitiveServices::WebSearch::V1_0::Models::SearchResponse.mapper()
|
762
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
763
|
+
rescue Exception => e
|
764
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
765
|
+
end
|
766
|
+
end
|
767
|
+
|
768
|
+
result
|
769
|
+
end
|
770
|
+
|
771
|
+
promise.execute
|
772
|
+
end
|
773
|
+
|
774
|
+
end
|
775
|
+
end
|