November Happy Hour will be moved to Thursday December 5th.

Files always come after pages in search results.

Vote:
 

I've been using the built in EPiServer search data source to search through the pages and uploaded files on a project.  The resulting set seems to be fine, but all files always seem to come after pages.

The code used to create the searchdatasource:

            var searchDataSource = new SearchDataSource
                                       {
                                           SearchQuery = updatedSearchString,
                                           PageLink = this.SearchRoot,
                                           SearchFiles = true,
                                           SearchLocations = "~/Global/,~/PageFiles/",
                                           LanguageBranches = this.Languages,
                                           OnlyWholeWords = true
                                       };

 

SearchString returns the text from the search textbox.

The only modification being done with linq before binding(albeit quite a bit in the one modification):


var results = searchDataSource.Select(new DataSourceSelectArguments()).OfType<PageData>().Where(p => p["ExcludeFromSearchResults"] == null && !p.PageName.ToUpperInvariant().EndsWith(".XML")).Skip((pager.CurrentPageNumber * pager.PageWeight) - pager.PageWeight).Take(pager.PageWeight);

The purpose there is to ensure that anything with the ExcludeFromSearchResults page property enabled is ignored, and ignore any XML files.  Doing this after the query already has results is ugly, but I wanted to make sure files and pages would search as we expected before putting more time into optimizing the query.

Pager is a custom paging control we wrap around the repeater, PageWeight is the number of results being displayed per page.

Every set of search results seems to be ordered EPiServer Pages, then files.  The pages and files both appear to be properly sorted by relevance in their own right, but the list is always pages followed by files. 

Is there a way to get the two sets of results to be intermixed(when appropriate)?

#42765
Aug 31, 2010 17:57
Vote:
 

A bit of an update. A coworker came across Fredrik Haglund's blog post http://blog.fredrikhaglund.se/blog/2007/11/03/properties-with-special-functionality-in-episerver/

After reading that I decided to try and order results by PageRank descending and add the pagerank to the output of the search page.

This successfully mixed the search results, but every file seems to have a PageRank of 500.

Is there a way to get file search results to have differing Page Ranks?

Another question would probably be is this behaviour abnormal, and do I need to fix my file indexing?

 

Edit:
Digging into this a coworker found the following line in reflector
       UnifiedSearchHit hit = new UnifiedSearchHit(searchHitVirtualPath, 500, file.Name, query2.CreateHtmlPreview(doc));


#45428
Edited, Nov 05, 2010 16:01
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.