Volumes not showing in API. How to fix?

Avatar image for eduo
eduo

4

Forum Posts

9

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

#1  Edited By eduo

Some authority volumes are not showing up in API results searches. 
 
If you search the following: 
 
http://api.comicvine.com/search/?api_key=xxxx&format=xml&query=The%20Authority&resources=volume     
 
You won't get V1 or V2. If you search without specigfying resources then you'll see the volumes referenced from individual issues, and their volume api pages exist: 
 
  http://api.comicvine.com/volume/7499/  
http://api.comicvine.com/volume/11206/  
 
Is there a way to search differently in a way that shows all results properly?  
 
NOTE: I started this thread in The Authority's Forums by error. Will delete there when I get a response here. I thought I had changed it before posting but it seems it didn't take, 

Avatar image for callahan09
callahan09

24

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

#2  Edited By callahan09
@eduo:   Hi.  The search does return the volumes you're looking for, but you can't see them due to pagination.  Let me explain: If you look at the XML for your query result you should see the following things near the top (just before the < results > node):

 < limit > 20 </ limit >
  < number_of_page_results > 20 </ number_of_page_results >
  < number_of_total_results > 24 </ number_of_total_results >
  < offset > 0 </ offset >


limit is the MAXIMUM number of results returned by the query. number_of_page_results is the number of actual results returned by the query.  In your case, it's the same as the limit, because there are as many or more results as the limit.
number_of_total_results is the total number of hits that match your query.
offset is like the starting point for your results.

So putting all of that together, you're seeing offset to (offset + number_of_page_results) results out of number_of_total_results.
So you're seeing results 0 to 20 out of 24.

If (offset + limit) < number_of_total_results then there is at least one more page of results.

In order to see the next page of results, increase the offset by the limit.  So your new query for the next page of results needs to have &offset=20 added to the end, as follows:

http://api.comicvine.com/search/?api_key=f363cf3bc6d6a385f9df0353fb3251f4ef8b0fc6&format=xml&query=The%20Authority&resources=volume&offset=20

Now you have the following XML returned at the top:

< limit > 20 </ limit >
  < number_of_page_results > 4 </ number_of_page_results >
  < number_of_total_results > 24 </ number_of_total_results >
  < offset > 20 </ offset >

    So you're seeing results 20 to 24 out of 24.  Intuitively you know that you've now seen all of your results, but mathematically speaking you're looking at (offset + limit) > number_of_total_results (40 > 24), so there is no need to go looking for another page of results.  If you tried, you'd be looking for results 40 to 60, of which there are none, so you'd get:


 < limit > 20 </ limit >
  < number_of_page_results > 0 </ number_of_page_results >
  < number_of_total_results > 24 </ number_of_total_results >
  < offset > 40 </ offset >


So to answer your question more directly, The Authority V1 and V2 are both in that second page of results.  I hope this helps.