Bing Search API から結果をページングする方法How to page through results from the Bing Search APIs
警告
Bing Search API は、Cognitive Services から Bing Search Services に移行されます。Bing Search APIs are moving from Cognitive Services to Bing Search Services. 2020 年 10 月 30 日 以降、Bing Search の新しいインスタンスは、こちらに記載されているプロセスに従ってプロビジョニングする必要があります。Starting October 30, 2020, any new instances of Bing Search need to be provisioned following the process documented here. Cognitive Services を使用してプロビジョニングされた Bing Search API は、次の 3 年間、または Enterprise Agreement の終わり (どちらか先に発生した方) までサポートされます。Bing Search APIs provisioned using Cognitive Services will be supported for the next three years or until the end of your Enterprise Agreement, whichever happens first. 移行手順については、Bing Search Services に関する記事を参照してください。For migration instructions, see Bing Search Services.
Bing Web、Custom、Image、News または Video Search API の呼び出しを送信すると、Bing からは、クエリに関連する可能性のある結果の合計数のサブセットが返されます。When you send a call to the Bing Web, Custom, Image, News or Video Search APIs, Bing returns a subset of the total number of results that may be relevant to the query. 利用可能な結果の推定総数を取得するには、回答オブジェクトの totalEstimatedMatches
フィールドにアクセスします。To get the estimated total number of available results, access the answer object's totalEstimatedMatches
field.
次に例を示します。For example:
{
"_type" : "SearchResponse",
"webPages" : {
"webSearchUrl" : "https:\/\/www.bing.com\/cr?IG=3A43CA...",
"totalEstimatedMatches" : 262000,
"value" : [...]
}
}
検索結果をページングするPaging through search results
利用可能な動画をページングするには、要求の送信時にクエリ パラメーター count
と offset
を使用します。To page through the available results, use the count
and offset
query parameters when sending your request.
注意
- Bing Video、Image、News API によるページングは、一般的な動画 (
/video/search
)、ニュース (/news/search
)、画像 (/image/search
) の検索にのみ適用されます。Paging with the Bing Video, Image, and News APIs applies only to general video (/video/search
), news (/news/search
) and image (/image/search
) searches. 流行のトピックとカテゴリによるページングはサポートされていません。Paging through trending topics and categories is not supported. TotalEstimatedMatches
フィールドは、現在のクエリに対する検索結果の合計数の見積もりです。TheTotalEstimatedMatches
field is an estimate of the total number of search results for the current query.count
パラメーターとoffset
パラメーターを設定すると、この見積もりが変わることがあります。When you set thecount
andoffset
parameters, this estimate may change.
パラメーターParameter | 説明Description |
---|---|
count |
応答で返される結果の数を指定します。Specifies the number of results to return in the response. count の既定値と、要求できる結果の最大数は API によって異なることに注意してください。Note that the default value of count , and the maximum number of results that you may request varies by API. これらの値については、「次の手順」の下にあるリファレンス ドキュメントを参照してください。You can find these values in the reference documentation under Next steps. |
offset |
スキップする結果の数を指定します。Specifies the number of results to skip. offset は 0 から始まり、(totalEstimatedMatches - count ) 未満である必要があります。The offset is zero-based and should be less than (totalEstimatedMatches - count ). |
たとえば、1 ページあたり 15 件の結果を表示する場合、count
を 15 に、offset
を 0 に設定し、結果の最初のページを取得します。As an example, if you want to display 15 results per page, you would set count
to 15 and offset
to 0 to get the first page of results. 後続の API 呼び出しごとに、offset
を 15 ずつ増やします。For each subsequent API call, you would increment offset
by 15. 次の例は、オフセット 45 から始まる 15 件の Web ページを要求します。The following example requests 15 webpages beginning at offset 45.
GET https://api.cognitive.microsoft.com/bing/v7.0/search?q=sailing+dinghies&count=15&offset=45&mkt=en-us HTTP/1.1
Ocp-Apim-Subscription-Key: 123456789ABCDE
Host: api.cognitive.microsoft.com
既定の count
値を使用する場合、API 呼び出しで指定する必要があるのは offset
クエリ パラメーターだけです。If you use the default count
value, you only need to specify the offset
query parameter in your API calls.
GET https://api.cognitive.microsoft.com/bing/v7.0/search?q=sailing+dinghies&offset=45&mkt=en-us HTTP/1.1
Ocp-Apim-Subscription-Key: 123456789ABCDE
Host: api.cognitive.microsoft.com
Bing Image API と Video API を使用する場合は、nextOffset
の値を使用して、検索結果の重複を避けることができます。When using the Bing Image and Video APIs, you can use the nextOffset
value to avoid duplicate search results. Images
または Videos
応答オブジェクトから値を取得し、要求の中で offset
パラメーターと共に使用します。Get the value from the Images
or Videos
response objects, and use it in your requests with the offset
parameter.
注意
Bing Web Search API から返される結果には、Web ページ、画像、動画、ニュースが含まれます。The Bing Web Search API returns search results that can include webpages, images, videos, and news. Bing Web Search API からの検索結果をページングするとき、Web ページのみがページングされ、画像やニュースなど、他の種類の応答はページングされません。When you page through search results from the Bing Web Search API, you are paging only WebPages, and not other answer types such as images or news. WebPage
オブジェクトの検索結果には、他の種類の応答にも表示される結果が含まれることがあります。Search results in WebPage
objects may include results that appear in other answer types as well.
フィルター値を指定せずに responseFilter
クエリ パラメーターを使用する場合、count
パラメーターと offset
パラメーターを使用しないでください。If you use the responseFilter
query parameter without specifying any filter values, don't use the count
and offset
parameters.
次のステップNext steps
- Bing Web Search API とはWhat are the Bing Web Search APIs?
- Bing Web Search API v7 リファレンスBing Web Search API v7 reference
- Bing Custom Search API v7 リファレンスBing Custom Search API v7 reference
- Bing News Search API v7 リファレンスBing News Search API v7 reference
- Bing Video Search API v7 リファレンスBing Video Search API v7 reference
- Bing Image Search API v7 リファレンスBing Image Search API v7 reference