Not Getting Consistent Search Results

Topics: Developer Forum
Sep 11, 2012 at 4:03 AM

I just created a test search and I get inconsistent results as I loop through the pages of the search results. Each Page I loop through the total page count is not the same as the previous total page count. Any ideas where this is coming from? The debug output confirms this:

 

Option Explicit On
Imports FlickrNet
Imports System.Net
Public Class frmDisplayWindow
    Private Sub btnExecute_Click(sender As System.Object, e As System.EventArgs) Handles btnExecute.Click
        Call FlickrSubsAndFunctions.GetPhotosFromFlickrBasedOnDateRange("44222892@N00", "jeanparentsphotoframe", #9/9/2012 11:59:00 PM#, #9/10/2012 9:10:00 PM#)
    End Sub
End Class

Option Explicit On
Imports FlickrNet
Imports System.Net
Module FlickrSubsAndFunctions
    Public FlickrAPIKey As String = "7c7b590d482b6c20c08fcaa3b92188f0"
    Public Sub GetPhotosFromFlickrBasedOnDateRange(ByVal UserID As String, ByVal FlickrPhotoTags As String, ByVal MinUploadDate As Date, ByVal MaxUploadDate As Date)
        Debug.Print("------------------ Begin ------------------")
        Dim FlickrConnectionObject As Flickr = New Flickr(FlickrAPIKey)
        Dim FlickrSearchOptions As PhotoSearchOptions = New PhotoSearchOptions()
        FlickrSearchOptions.UserId = UserID
        FlickrSearchOptions.Tags = FlickrPhotoTags
        FlickrSearchOptions.MinUploadDate = MinUploadDate
        FlickrSearchOptions.MaxUploadDate = MaxUploadDate
        FlickrSearchOptions.Extras = PhotoSearchExtras.DateTaken Or PhotoSearchExtras.DateUploaded Or PhotoSearchExtras.OriginalDimensions
        FlickrSearchOptions.PerPage = 50
        FlickrSearchOptions.MediaType = MediaType.Photos
        FlickrSearchOptions.ContentType = ContentTypeSearch.PhotosOnly
        FlickrSearchOptions.TagMode = TagMode.AnyTag
        Dim AllFlickrPhotosFromThisSearch As New List(Of Photo)()
        FlickrSearchOptions.Page = 1
        Dim PageOneFlickrSearchResuts As PhotoCollection = FlickrConnectionObject.PhotosSearch(FlickrSearchOptions)

        'Check for errors in the return of "PageOneFlickrSearchResuts" here

        Dim TotalPhotosInThisSearch = PageOneFlickrSearchResuts.Total
        Dim TotalPagesInThisSearch = PageOneFlickrSearchResuts.Pages
        Dim NumberOfResultsInThisPage = PageOneFlickrSearchResuts.Count

        If TotalPhotosInThisSearch > 0 Then
            AllFlickrPhotosFromThisSearch.AddRange(PageOneFlickrSearchResuts)
        End If
        Debug.Print("------------------------------------------")
        Debug.Print("Total Photos In This Search: " & TotalPhotosInThisSearch)
        Debug.Print("Total Pages In This Search: " & TotalPagesInThisSearch)
        Debug.Print("Current Page Number: " & FlickrSearchOptions.Page)
        Debug.Print("Results In This Page: " & NumberOfResultsInThisPage)
        Debug.Print("------------------------------------------")
        If TotalPagesInThisSearch > 1 Then
            For PageNumber As Integer = 2 To TotalPagesInThisSearch
                FlickrSearchOptions.Page = PageNumber
                Dim MultiPageFlickrSearchResuts As PhotoCollection = FlickrConnectionObject.PhotosSearch(FlickrSearchOptions)
                Dim MultiPageTotalPhotosInThisSearch = MultiPageFlickrSearchResuts.Total
                Dim MultiPageTotalPagesInThisSearch = MultiPageFlickrSearchResuts.Pages
                Dim MultiPageNumberOfResultsInThisPage = MultiPageFlickrSearchResuts.Count
                Debug.Print("------------------------------------------")
                Debug.Print("Total Photos In This Search: " & MultiPageTotalPhotosInThisSearch)
                Debug.Print("Total Pages In This Search: " & MultiPageTotalPagesInThisSearch)
                Debug.Print("Current Page Number: " & FlickrSearchOptions.Page)
                Debug.Print("Results In This Page: " & MultiPageNumberOfResultsInThisPage)
                Debug.Print("------------------------------------------")
            Next
        End If
        Debug.Print("------------------- End -------------------")
    End Sub
End Module
 
Here is the Debug Output
 
------------------ Begin ------------------
------------------------------------------
Total Photos In This Search: 3510 <-- Correct Value
Total Pages In This Search: 71 <-- Correct Value
Current Page Number: 1
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446 <-- Why?
Total Pages In This Search: 69 <-- Why?
Current Page Number: 2
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446 <-- Why?
Total Pages In This Search: 69 <-- Why?
Current Page Number: 3
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510 <-- Back To Normal
Total Pages In This Search: 71 <-- Back To Normal
Current Page Number: 4
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 5
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 6
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 7
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 8
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 9
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 10
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 11
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 12
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 13
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 14
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 15
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 16
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 17
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 18
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 19
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 20
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 21
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 22
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 23
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 24
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 25
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 26
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 27
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 28
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 29
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 30
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 31
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 32
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 33
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 34
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 35
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 36
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 37
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 38
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 39
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 40
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 41
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 42
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 43
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 44
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 45
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 46
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 47
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 48
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 49
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 50
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 51
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 52
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 53
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 54
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 55
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 56
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 57
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 58
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 59
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 60
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 61
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 62
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 63
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 64
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 65
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 66
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 67
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 68
Results In This Page: 50
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 69
Results In This Page: 46
------------------------------------------
------------------------------------------
Total Photos In This Search: 3446
Total Pages In This Search: 69
Current Page Number: 70
Results In This Page: 0
------------------------------------------
------------------------------------------
Total Photos In This Search: 3510
Total Pages In This Search: 71
Current Page Number: 71
Results In This Page: 10
------------------------------------------
------------------- End -------------------
Coordinator
Sep 11, 2012 at 2:45 PM

Two options. 1 - caching is storing some of the results but not others, and therefore those 'lower' results are old results. Disable caching by setting Flickr.CacheDisabled to True.

or 2 - Flickr is returning those results. As to why it would do this I don't know.

Sam

Sep 11, 2012 at 4:26 PM

I took the time to generate queries directly to the REST API. It looks like the inconsistent results are coming from Flickr itself! 

The ONLY thing I am changing here is the page number in the query and yet I get different results depending on what page I view!!! This is nuts! What should I do?

 

Here are the queries and the various results (You can test them in your borwser and confirm what I am seeing). Again the ONLY difference between these queries is the "page=" field!! Also, this seems to vary based on when I make the queries. These photos are not changing in any way and are completely public.

The "Real" number of photos should be 3510 photos

Query#1 - page="1" pages="71" perpage="50" total="3510" (50 Photos Returned In This Page) <--- Correct Value
http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=c1a144cd30cbefc803404dd48814f436&user_id=44222892%40N00&tags=jeanparentsphotoframe&tag_mode=any&min_upload_date=1347148800&max_upload_date=1347321600&content_type=1&media=photos&extras=date_upload%2Cdate_taken%2Co_dims&per_page=50&page=1&format=rest

Query#2 - page="2" pages="69" perpage="50" total="3446" (50 Photos Returned In This Page) <--- Wrong Value
http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=c1a144cd30cbefc803404dd48814f436&user_id=44222892%40N00&tags=jeanparentsphotoframe&tag_mode=any&min_upload_date=1347148800&max_upload_date=1347321600&content_type=1&media=photos&extras=date_upload%2Cdate_taken%2Co_dims&per_page=50&page=2&format=rest

Query#3 - page="3" pages="71" perpage="50" total="3510" (50 Photos Returned In This Page) <--- Now Back To Correct Value
http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=c1a144cd30cbefc803404dd48814f436&user_id=44222892%40N00&tags=jeanparentsphotoframe&tag_mode=any&min_upload_date=1347148800&max_upload_date=1347321600&content_type=1&media=photos&extras=date_upload%2Cdate_taken%2Co_dims&per_page=50&page=3&format=rest

Query#3 - page="69" pages="69" perpage="50" total="3446" (46 Photos Returned In This Page) <--- Wrong Value and only 46 Photos returned!
http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=c1a144cd30cbefc803404dd48814f436&user_id=44222892%40N00&tags=jeanparentsphotoframe&tag_mode=any&min_upload_date=1347148800&max_upload_date=1347321600&content_type=1&media=photos&extras=date_upload%2Cdate_taken%2Co_dims&per_page=50&page=69&format=rest

Query#4 - page="70" pages="69" perpage="50" total="3446" (0 Photos Returned In This Page) <--- How Is This Possible????
http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=c1a144cd30cbefc803404dd48814f436&user_id=44222892%40N00&tags=jeanparentsphotoframe&tag_mode=any&min_upload_date=1347148800&max_upload_date=1347321600&content_type=1&media=photos&extras=date_upload%2Cdate_taken%2Co_dims&per_page=50&page=70&format=rest

Query#5 - page="71" pages="71" perpage="50" total="3510" (10 Photos Returned In This Page) <--- Even after the previous page "70" gives is Zero results, now we get 10 photos back here! This is totally nuts!
http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=c1a144cd30cbefc803404dd48814f436&user_id=44222892%40N00&tags=jeanparentsphotoframe&tag_mode=any&min_upload_date=1347148800&max_upload_date=1347321600&content_type=1&media=photos&extras=date_upload%2Cdate_taken%2Co_dims&per_page=50&page=71&format=res

Coordinator
Sep 11, 2012 at 9:42 PM

Yeah, Flickr does weird stuff like this sometimes. I don't really have a good answer for you unfortunately.

Sam

Mar 23, 2014 at 4:18 PM
+1 to having/following this problem w/my own Flickr app. Very frustrating. Hoping someone will find/post a solution.

My specific version as follows:
  • I have authenticated and my API is pulling back private photos
  • I have a family/friends permission photo flagged "mary" "favorite" "chris"
  • If I search tag "mary" I see the photo
  • If I search "chris" I see the photo
  • If I search tag mode "All" "mary,favorite" or "chris,favorite" I do not see the photo
  • But searching "mary,favorite" or "chris,favorite" DOES pull up other, older photos with those tags
What in the world is going on?
Coordinator
Mar 24, 2014 at 10:19 AM
Unfortunately my library just gives you whatever Flickr returns, so I can't really help on this issue. I see you've already posted on the API group, where you are much more likely to get a response (although still by no means guaranteed unfortunately).

Sam