Join us this Friday for AI in Action at the Virtual Happy Hour! This free virtual event is open to all—enroll now on Academy and don’t miss out.

 

UnifiedSearchQuery only returns 100 results maximum

Vote:
 

I have a UnifiedDirectory with 4500+ files in it. When I perform a search using a UnifiedSearchQuery, the UnifiedSearchHitCollection capacity gets reset to 128 and the count returns 100 during the query - for pretty much every query. There's no way the search returns exactly 100 results for most of the criteria. How do I override this behaviour and get all ranked files? There is zero help in the SDK.

		UnifiedSearchHitCollection searchresult = new UnifiedSearchHitCollection();
		searchresult.Capacity = 999;
                query.FreeTextQuery = txtSearchValue;
                searchresult = dir.Search(query);

Thanks in advance.

#122431
Jun 02, 2015 15:13
Vote:
 

Hi,

It looks like the page size == 100, is used as a constant and there is no elegant way to change it.

Maybe you could try to use a trick (I didn't test it):

// change the implementation of SearchHandler
        public class ExtendedSearchHandler: SearchHandler
        {
            public override SearchResults GetSearchResults(IQueryExpression queryExpression, string namedIndexingService, Collection<string> namedIndexes,
                                                           int page, int pageSize)
            {
                pageSize = 10000;
                return base.GetSearchResults(queryExpression, namedIndexingService, namedIndexes, page, pageSize);
            }
        }


//
// use your code below
//
// replace the instance of searchHandler
SearchHandler.Instance = new ExtendedSearchHandler();

UnifiedSearchHitCollection searchresult = new UnifiedSearchHitCollection();
searchresult.Capacity = 999;
        query.FreeTextQuery = txtSearchValue;
        searchresult = dir.Search(query);
#122451
Jun 02, 2015 22:25
Vote:
 

Hi, thanks Grzegorz. I will give this a shot.

#122473
Jun 03, 2015 11:06
Vote:
 

Grzegorz, you are a total legend. Worked first time! Thanks again! :D

#122489
Jun 03, 2015 12:33
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.