Question

I have a json like this from my query:

{"bossresponse":{"responsecode":"200","web":{"start":"0","count":"10","totalresults":"1050000000","results":[{"date": "","clickurl":"http://www.yahoo.com/","url":"http://www.yahoo.com/","dispurl":"www.yahoo</b>.com","title":"Yahoo</b>!","abstract":"Welcome to Yahoo</b>!, the world's most visited home page. Quickly find what you're searching for, get in touch with friends and stay in-the-know with the latest news and ..."},{"date": "","clickurl":"http://news.yahoo.com/world/","url":"http://news.yahoo.com/world/","dispurl":"news.yahoo</b>.com/world","title":"World News Headlines - Yahoo</b>! News","abstract":"Get the latest world news headlines from Yahoo</b>! News. Find breaking world news, including analysis and opinion on top world stories."},{"date": "","clickurl":"http://en.wikipedia.org/wiki/Yahoo","url":"http://en.wikipedia.org/wiki/Yahoo","dispurl":"en.wikipedia.org/wiki/Yahoo</b>","title":"Yahoo</b>! - Wikipedia, the free encyclopedia","abstract":"Yahoo</b>! Inc. (NASDAQ: YHOO) is an American multinational internet corporation headquartered in Sunnyvale, California, United States. The company is perhaps best known ..."},{"date": "","clickurl":"http://mail.yahoo.com/","url":"http://mail.yahoo.com/","dispurl":"mail.yahoo</b>.com","title":"Yahoo</b>! Mail: The best web-based email!","abstract":"Your World. Your Way. Yahoo</b>! makes it easy to enjoy what matters most in your world. Best in class Yahoo</b>! Mail, breaking local, national and global news, finance ..."},{"date": "","clickurl":"http://my.yahoo.com/","url":"http://my.yahoo.com/","dispurl":"my.yahoo</b>.com","title":"Sign in to Yahoo</b>!","abstract":"My Yahoo</b> is a customizable web page with news, stock quotes, weather, and many other features."},{"date": "","clickurl":"http://au.yahoo.com/?p=us","url":"http://au.yahoo.com/?p=us","dispurl":"au.yahoo</b>.com/?p=us","title":"Yahoo</b>!7","abstract":"The Yahoo</b>! for Australia offering local & global search, free email, instant messaging, news, sport, travel, shopping, movies & music."},{"date": "","clickurl":"http://omg.yahoo.com/","url":"http://omg.yahoo.com/","dispurl":"omg.yahoo</b>.com","title":"omg! Celebrity gossip, news photos, babies, couples, hotties ...","abstract":"The latest celebrity gossip from Yahoo</b>! OMG! Get the latest news and gossip on the Hollywood celebrities with videos and photos."},{"date": "","clickurl":"http://finance.yahoo.com/?u","url":"http://finance.yahoo.com/?u","dispurl":"finance.yahoo</b>.com/?u","title":"Yahoo</b>! Finance - Business Finance, Stock Market, Quotes, News","abstract":"At Yahoo</b>! Finance, you get free stock quotes, up to date news, portfolio management resources, international market data, message boards, and mortgage rates that help ..."},{"date": "","clickurl":"http://news.yahoo.com/","url":"http://news.yahoo.com/","dispurl":"news.yahoo</b>.com","title":"Yahoo</b>! News - Latest News & Headlines","abstract":"The latest news and headlines from Yahoo</b>! News. Get breaking news stories and in-depth coverage with videos and photos."},{"date": "","clickurl":"http://search.yahoo.com/","url":"http://search.yahoo.com/","dispurl":"search.yahoo</b>.com","title":"Yahoo</b>! Search - Web Search","abstract":"The search engine that helps you find exactly what you're looking for. Find the most relevant information, video, images, and answers from all across the Web."}]}}}

In that json you can see 'totalresults' is '1050000000' this is not total result for list, but total documents matched the search ref:http://developer.yahoo.com/search/boss/boss_api_guide/webv2_response.html.

If I use the totalresults for paging in my page,and i'm show perpage is 10 the page is very much and when i'm execute by $start =10 or $start =20 ...ect, in the next $start =1010 is not run.i'm read the documentation maximum of $start is 1000 .

How i can find the lastpage? or the real totalresult for list?

Était-ce utile?

La solution

As you noted, the maximum start value is 1000, so you could set your UI "total pages" to be 1000 divided by number you're showing on each page.

Per the Universal BOSS API Arguments:

Ordinal position of first result. First position is 0. Default sets start to 0. Note: Start parameter cannot be greater than 1000. All services return a maximum of 1000 results only.

All of the search webservices I've seen are designed in a similar way, because they don't want to expose their entire search database. (Also because search results that deep tend to not be that useful.) Some common traits:

  • The "total results" value returned is an approximation
  • There is a limit as to how deep you can go for a given query

For example in your case your query said that over a billion results were available, but it's not practical to try and fetch each one of those.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top