Try our conversational search powered by Generative AI!

Index properties but not file?


we have files that are quite big, and we see no reason to index them in find. But we would like to index the properties on the filetype. Is there a way to index the properties of the file but not the file it self? Or is this handled automagically?


Jun 15, 2015 8:48

Hi, have you tried setting PdfFile.BinaryData to null?

Here is some indexing conventions 

ContentIndexer.Instance.Conventions.ForInstancesOf<PdfFile>().ShouldIndex(x => x.FileSizeInKb < 20000);
SearchClient.Instance.Conventions.ForInstancesOf<PdfFile>().IncludeField(x => x.SetCustomProperties());

We have solved the matter by setting an limit aprox 20 mb

Let me know it that worked


Jun 15, 2015 11:49

Hi Daniel, we have a convention that allows files up to 30MB, but we need to index properties of a 500MB file.. How would you null the BinaryData just for some specific files when indexing?

Jun 17, 2015 15:34


The binary data of a IContentMedia item is passed to the index using the SearchAttachment extension. In order to skip passing the data (while having all other properties passed) you have to override the default SearchAttachment extension and set it to null if the file exceeds your limit:

First create a SearchAttachment() extension for they type (it has to be named SearchAttachment for UnifiedSearch to work properly):

public static Attachment SearchAttachment(this $FileType$ mediaData)


            if (ContentIndexer.Instance.Conventions.ShouldIndexAttachmentConvention.ShouldIndexAttachment(mediaData).HasValue &&



                if (mediaData.BinaryData.IsNotNull())


                    using (var stream = mediaData.BinaryData.OpenRead())


                        if (stream.Length < $FileSize$)


                            return new Attachment(() => mediaData.BinaryData.OpenRead());





            return null;


and add it to your conventions by overriding the default convention on IContentMedia:


                .ExcludeField(x => ((IContentMedia) x).SearchAttachment())

                .IncludeField(x => x.SearchAttachment());


Jun 24, 2015 11:33

Thank you Henrik for the clarification. I've implemented this and hopefully have a happier customer now. :)

Jun 25, 2015 10:41
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.