You are viewing limited content. For full access, please sign in.

Question

Question

Problem with SearchResultListings

SDK
asked on April 4, 2019 Show version history

We are having an odd problem with the SearchResultsListing object, in code that (I swear) used to work fine.  We have tried TK 10.1, 10.2, 9.2 all with the same result.  It's all very conventional, searching with:

Dim SearchResults As SearchResultListing

From there we do the search, and get the expected number of hits.  Then as we try to iterate through the results, it blows up on the third iteration every time. It does not matter whether there are three results returned or five - meaning that we do not seem to be hitting any out of range conditions. The error message is the incredibly un-useful, "Operation is not in progress."  Here is a little test loop we set up, basically doing nothing but iterating through the results:

            For nIndex = 1 To ResultSet.RowsCount
                Dim DocInfo = ResultSet.GetEntryInfo(nIndex)
            Next nIndex

Disposing of DocInfo between iterations does not change anything.

This also happens when using ResultSet.RowCount (singular Row vs. plural Rows) It does not matter whether the results are from documents only, folders only, or a mix of both.

I feel like I have seen and used code like this a million times.  Any thoughts or ideas on what may be different?  TIA -

0 0

Answer

SELECTED ANSWER
replied on April 5, 2019

The log indicates that Search.Close() is being called directly, before GetDatumAsString is called. Closing the search invalidates the search result listing.

1 0

Replies

replied on April 4, 2019

what if you extract the entry IDs from the listing, and process them outside of the loop, like this:

            Dim lIds As List(Of Integer) = New List(Of Integer)

            For nIndex = 1 To SearchResults.RowsCount
                lIds.Add(SearchResults.GetDatum(1, SystemColumn.Id))
            Next nIndex

            For Each entryId As Integer In lIds
                Dim entryInfo = Entry.GetEntryInfo(entryId, raSession)
                ' ...
            Next

If that doesn't fix the problem, try enabling RA tracing to generate a log that might shed light on why the search operation is being closed. To do this, call InitializeMethodTracer like this at the beginning of your code:

Laserfiche.RepositoryAccess.MethodTracer.InitializeMethodTracer("c:\logs\RA.log")

 

0 0
replied on April 5, 2019

Thanks, Robert - 

Here's the implementation:

            For nIndex = 1 To ResultSet.RowsCount
                nDocID = ResultSet.GetDatumAsString(nIndex, SystemColumn.Id)
            Next nIndex

But it still blew up on iteration 3.  The tracking piece is useful, but I did not see anything obvious there either.  It's attached.

RA.txt (5.38 KB)
0 0
SELECTED ANSWER
replied on April 5, 2019

The log indicates that Search.Close() is being called directly, before GetDatumAsString is called. Closing the search invalidates the search result listing.

1 0
replied on April 5, 2019

Thanks, Robert - you were correct on all counts.  I did have a Search.Close in the wrong spot.  I also like the idea of collecting all of the EntryIDs and then disposing of the search object. Kudos!

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.