Search.PerformSearch in Knowledge Center 12

I am using the API documentation for Tridion docs 13, but I am using Knowledge Center 12. About Search.PerformSearch, it says that results are no longer cached and the caller has to manage retrieving results in chunks. I'm guessing that what I am seeing is the old behavior.

If I request 0 hits, it returns the number of hits, without the results. But, if I request 1000, it returns the first 1000, over and over, rather than retrieving the next chunk.

If I request all of the hits, it returns them all in that call, e.g. PerformSearch(query, 3214, out result), returns 3214 hits.

How can I retrieve results in chunks? Or, can I? 

 

Parents
  • Hi Kendall,

    If you want to retrieve them in chunks as referenced in the documentation they actually mean that you have to use the following flow. (although it is not really chunked).

    Either request all hits and only retrieve the metadata for blocks of 1000. You can in this approach cache the results so you do not have to re-run the query.

    1/ Request all hits for your search query.
    2/ Retrieve metadata for the items 1 to 1000
    3/ Retrieve metadata for the items 1001 to 2000
    ....

    Either request for each new chunk that you need to retrieve again your query with the number of hits increased.

    1/ Request 1000 hits for your search query.
    2/ Retrieve the metadata for the items 1 to 1000
    3/ Request 2000 hits for your search query.
    4/ Retrieve the metadata only for the items from 1001 to 2000.
    etc....

    As said it is not really chunked, but you can at least limit the number of objects for which the metadata needs to be returned.

    Kind Regards,

    Raf

Reply
  • Hi Kendall,

    If you want to retrieve them in chunks as referenced in the documentation they actually mean that you have to use the following flow. (although it is not really chunked).

    Either request all hits and only retrieve the metadata for blocks of 1000. You can in this approach cache the results so you do not have to re-run the query.

    1/ Request all hits for your search query.
    2/ Retrieve metadata for the items 1 to 1000
    3/ Retrieve metadata for the items 1001 to 2000
    ....

    Either request for each new chunk that you need to retrieve again your query with the number of hits increased.

    1/ Request 1000 hits for your search query.
    2/ Retrieve the metadata for the items 1 to 1000
    3/ Request 2000 hits for your search query.
    4/ Retrieve the metadata only for the items from 1001 to 2000.
    etc....

    As said it is not really chunked, but you can at least limit the number of objects for which the metadata needs to be returned.

    Kind Regards,

    Raf

Children
  • How do you retrieve items 1001 and up? What I see is this:

    PerformSearch(query, 0, out result) -> returns 3124
    PerformSearch(query, 1000, out result) -> result contains metadata for 1 - 1000
    PerformSearch(query, 1000, out result) -> result contains metadata 1 - 1000, again, not 1001 - 2001

    Or:

    PerformSearch(query, 1000, out result) -> result contains metadata for 1 - 1000
    PerformSearch(query, 2000, out result) -> result contains metadata 1 - 2000

    Or:

    PerformSearch(query, 999999999, out result) -> result contains metadata for 1 - 3124

    Or:

    var n = PerformSearch(query, 0, out result) -> n is 3124
    PerformSearch(query, n, out result) -> result contains metadata for 1 - 3124

    So, I guess I should always request all the results?