Exclude pages from Search

Vote:
 

Hi,

I have a content Search in my code. But my certain Page Types are like System pages just for display of results. The only diffrenec in my code  between other pages and system pages are that the file name in create page type is  under the system folder in my code. How do I exclude them from search.??

#45927
Nov 23, 2010 5:40
Vote:
 

Others might have better ideas, but off the top of my head...

I think you'd need to exclude them with critieria. Create a boolean property called "Exclude from Search" (or use the existing "Exclude from Menus") and add a criteria element to only match on those where this isn't checked.

For files, move the non-searchable files to a separate VPP and don't include it in the SearchLocations property.

 

#45928
Nov 23, 2010 5:54
Vote:
 

Hi, thanks for the reply

All  my pages are of diffrent type and so i have to create creteria for all the pages .How do I map this creteria with my search?

#45929
Nov 23, 2010 6:30
Vote:
 

You'll need to create that same property (named the same) on each Page Type, yes.  Then, do something like this:

<EPiServer:SearchDataSource PageLink="<%# PageReference.StartPage %>" runat="server">
<Criteria>
    <EPiServer:PropertyCriteriaControl Condition="Equal" Type="Boolean" Name="ExcludeFromSearch" Value="False" Required="true" runat="server" />
</Criteria>
</EPiServer:SearchDataSource>
    

I also just noticed that the SearchDataSource has a property called "EnableVisibleInMenu".  You could use this to exclude pages where "Show in Menus" is not checked.  That might be an easy way to filter out non-searchable pages.

#45930
Nov 23, 2010 6:47
Vote:
 

hi,

I have creted a property in my page type "selected/not selected" with same name. Now when i am searching any text in my text box  nothing is showing up in my search.

#45933
Nov 23, 2010 8:11
Vote:
 

Replace Value="False" with IsNull="True". And use a Dynamic Property instead of one for each page.

BR Jens

#55788
Dec 16, 2011 10:54
Vote:
 

You could also use something like this

            // Exclude the following page types
            foreach (PageType pageType in Constants.ExcludedPageTypes.Search)
            {
                FilterCompareTo pageTypeComparer = new FilterCompareTo("PageTypeID", pageType.ID.ToString())
                                                       {Condition = CompareCondition.NotEqual};
                pageTypeComparer.Filter(e.Pages);
            }

            // Remove all pages that are set to be hidden from the search
            new FilterCompareTo("HideFromSearch", null).Filter(e.Pages);

The above will filter out pages depending on properties also a set number of pagetypes you do not want to show

I just created a FilterMethod and passed this into the SearchDataSource :

searchDataSource.Filter += FilterSearchResults;

#55794
Dec 16, 2011 12:05