Try our conversational search powered by Generative AI!

Excluding images from search results

Vote:
 

Hi, does anyone know how to exclude images from search results? For example, I have images with the word "Cancun" in the file name. When I search "Cancun," those images show up in the search results. In Find > Configure, should I give the Title property less weight?

#187644
Jan 30, 2018 17:35
Vote:
 

Hi Andrea, how does your Search query looks like?

If you have a baseclass for your pagetypes then I would suggest to search for that instead of IContent.Another option, that is not better, but possible is to exclude images to get indexed. The downfall with that is that you can't search for images then if you need to do that later :)

#187645
Jan 30, 2018 17:48
Vote:
 

Hi,

You can also use filter in your query to exclude images,

query.Filter(p => !p.MatchTypeHierarchy(typeof(ImageData)))

#187656
Jan 31, 2018 8:05
Vote:
 

Hi Guys,

A bit related to this question.... But does anyone has a example of excluding anything of MediaData And ImageData (media files) from being indexed.  So only content should be indexed.

It should be in a initializationmodule right?

I would appreciate a nice way to achieve this 

#188233
Edited, Feb 15, 2018 10:59
Vote:
 

Hi,

Yes you should do this in initialization module. You can exclude media data by changing indexing conventions,

ContentIndexer.Instance.Conventions.ForInstancesOf<MediaData>().ShouldIndex(p => false);

#188234
Feb 15, 2018 11:17
Vote:
 

OK ik have this initialization module, but still i see these documentTypes in the epi find overview..

Is my module not good.. am i missing something?

ofcourse cleared the index first

[InitializableModule]
    [ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
    public class SearchInitialization : IInitializableModule
    {
        public void Initialize(InitializationEngine context)
        {            
            ContentIndexer.Instance.Conventions
              .ForInstancesOf<ImageFile>()
              .ShouldIndex(x => false);

            ContentIndexer.Instance.Conventions
             .ForInstancesOf<GenericMedia>()
             .ShouldIndex(x => false);

            ContentIndexer.Instance.Conventions
             .ForInstancesOf<TimelinePeriodFolder>()
             .ShouldIndex(x => false);

            ContentIndexer.Instance.Conventions
              .ForInstancesOf<ContentAssetFolder>()
              .ShouldIndex(x => false);

          

        public void Uninitialize(InitializationEngine context)
        {
            //Add uninitialization logic
        }
   }

#188239
Edited, Feb 15, 2018 12:26
Vote:
 

Have you cleared your find index and indexed again?

#188241
Feb 15, 2018 12:29
Vote:
 

@Jari ofcourse... Cleared the index and started again. 

#188243
Feb 15, 2018 12:37
* 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.