Index properties but not file?

Member since: 2004

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?


#122800 Jun 15, 2015 8:48
  • Member since: 2006

    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


    #122804 Jun 15, 2015 11:49
  • Member since: 2004

    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?

    #122912 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());


    #123067 Jun 24, 2015 11:33
  • Member since: 2004

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

    #123117 Jun 25, 2015 10:41