DocsRequested property: SearchQuery class

Description

Use this property to set or return the size of the result set as an integer. After invoking the Execute method, use this property to return the value of the size parameter passed to Execute. Alternatively, if the search query is to be executed by the ExecuteQuery method of the QueryService class, then use this property to specify the size of the result set.

Example

For example, one could compare DocsRequested to the GetDocumentCount method of the ResultCollection class to determine if there are possibly more documents to be retrieved.

The StartIndex and DocsRequested properties (that is, the start and size parameters to the Execute method) allow for “chunking” of search results. The idea is to repeatedly call Execute while increasing the start parameter by the increment specified by size. For example, the following psuedo-code will return the first 100 results the first time through the loop. The second time through the loop, it will return documents 101 through 200, and so on.

int start=1, size=100
,.// return results in chunks of 100 documents
while not done
   results = query.execute(start, size)
   if (results.GetDocumentCount() < query.DocsRequested)
      done = true
      // we got fewer documents than we asked for so we're done executing this ⇒
      // query
   if (results.GetDocumentCount() = 0)
      done = true
      // no more documents being returned so we're done executing this query

   // do something with the results

   start = start + size
end-while