This content is archived. See latest version here.

Last updated: Jun 10 2014


Most of our plans allow you to index attachments, meaning files such as Word and PDF documents. For a full list of supported formats see the Apache Tika documentation. To index attachments using the .NET API you create an instance of a class that has a property of type Attachment (found in the EPiServer.Find namespace). The Attachment class constructor has a single parameter of type Func<FileStream>. There is also a class named FileAttachment (also in the EPiServer.Find namespace) that instead requires a file path as a constructor parameter.


As an example, assume we create a class named Document:

public class Document
    public string Name { get; set; }
    public Attachment Attachment { get; set; }

We can then index an instance of the Document class to index a Word document along with some meta data (Name in this example).

var path = "TestData/Memoirs.docx";

var document = new Document()
    Name = "My memoirs",
    Attachment = new FileAttachment(path);


We are now able to search for the contents of the indexed Word document. For instance, assuming it contained the word "Banana" the result variable below would cointain a hit.

var result = client.Search<Document>()

Important note

At the moment there is an issue in the REST API that will cause an exception the first time a an instance of a type with an Attachment property (Document in this example) is indexed. This only happens the first time and after that everything will work as expected.