2

HTTP GET メッセージを Google Books API に送信する Java のプログラムがあります。検索条件「料理」に当てはまる本を手に入れたい。応答のアイテムの最大数は 40 で、これは GET メッセージで設定した数です。

https://www.googleapis.com/books/v1/volumes?q=cooking&projection=full&startIndex=0&maxResults=40&key=/*My Key*/

私が得た応答では、「totalItem」の値は約 450 です。Google ブックス GUI または「料理」で検索すると 580 万件の結果が得られるため、これは非常に間違っているように見えます。

なぜこのようになっているのか知っている人はいますか?

2 番目の問題: 私が送信する最初のリクエストは、インデックス 0-39 の結果を要求し、その後は 40-79... 1000 までです。1000 は、この API の curtesy クエリの 1 日の制限です。JSONファイルを取得するたびになぜか「totalItem」の値が違う!常に約 450 です
が、そこには一貫性がありません。

それについて何か知っている人はいますか?

4

2 に答える 2

3

The totalItems retrieved is infact, openSearch:totalResults. According to openSearch specification,

The "totalResults" element

The number of search results available for the current search.

If the totalResults element does not appear on the page then the search client should consider the current page to be the last page of search results.

Restrictions: The value must be a non-negative integer. Default: The default value is equal to the offset index of the last search result on the current page. Requirements: The element may appear zero or one time.

This is not working for this API though, and if you decrease the maxResults to 1, your totalItems will soar to 590s. Nothing in the google documentation says anything about that explicitly. The closest one I got was at the youtube API documentation

The tag identifies the number of items in the result set for the feed. Please note that the tag value is an approximation and may not represent an exact value. In addition, the maximum value for this tag is 1,000,000. You should not use this value to create pagination links.

Did you need totalItems for pagination?

于 2011-09-01T07:29:26.310 に答える
0

Books API と Books GUI の間の検索結果に関する最初の質問に答えるには、次のスレッドを参照してください。GUI 検索ではコンテンツとメタデータを処理し、API ではメタデータのみを処理します。

http://www.google.com/support/forum/p/booksearch-apis/thread?tid=38628f43b3bf6ee4&hl=en

于 2011-09-14T20:59:14.247 に答える