Hi & welcome to the forum.
If you want to exclude items from the search, you'll need to define that in your SearchClient conventions as described here:
https://world.episerver.com/documentation/developer-guides/search-navigation/Integration/cms-integration/Indexing/
The basics would be to create an IInitializableModule and specify your indexing rules there e.g.
[ModuleDependency(typeof(InitializationModule))]
public class FindInitialization : IInitializableModule
{
public void Initialize(InitializationEngine context)
{
ContentIndexer.Instance.Conventions.ForInstancesOf<MyMediaType>().ShouldIndex(x => false);
}
public void Uninitialize(InitializationEngine context)
{
}
}
Something to be aware of though is that, by excluding items from search, that excludes them from all areas where search is used such as the search boxes above the blocks, media and file tree in the CMS so you won't be able to search for those files.
Generally I'd go for your option 2 approach unless there's a particular reason to be careful about what's being indexed.
I'd have to agree with Paul on this as well. I've been having some issues with the "remove from index" approach I had implimented, in that it would remove things that it ought not to remove.
So I'm rewriting it to have more filters. I am finding that the unified search is a bit trickier to filter, just as a word of warning.
Best of luck
I'm fairly new to episerver and this is also my first question in the forum! So any and all pointers are appriciated.
As the title implies I'd like to exclude certain files from the search. Specifically different media files (.jpg, .png, .svg, .gif). I've followed these resources (create project, basic search) to index and implement the search page in my epi cms project. The search works. Although, all of the resources in my cms have been indexed which means that they turn up as search results. I'd like to change that. In my mind I have two options:
1) Exlude the files from being indexed in the first place
OR
2) Filter the data returned from the search (either by whitelisting och blacklisting certain file types) inside of my controller
Personally I would like to go with the first approach but the indexing is a black box to me. What is concidered best practice? Am I missing a third or fourth solution?
My code is identical to the example code in the links above btw.
Happy new year to everybody!