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
/Daniel
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?
Hi,
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 &&
ContentIndexer.Instance.Conventions.ShouldIndexAttachmentConvention.ShouldIndexAttachment(mediaData).Value)
{
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:
client.Conventions.ForInstancesOf<$FileType$>()
.ExcludeField(x => ((IContentMedia) x).SearchAttachment())
.IncludeField(x => x.SearchAttachment());
/Henrik
Thank you Henrik for the clarification. I've implemented this and hopefully have a happier customer now. :)
Hi,
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?
/Erik