rghat
rghat

Reputation: 35

How to search for file content using NHibernate.Search and Lucene.Net

I have integrated Lucene.net and nhibernate.search together. I have a domain object that contains a file path, and this file path leads to a file on disc, which has file content. How would I use Lucene.Net/nhibernate.search to search through the file content of a saved file?

My index is being changed automatically with some listeners every time i save/delete/update the domain object.

[Indexed]
public class Book {
    private int id;
    private string name;
    private string filename;

    public Book() {
    }

    public Book(int id,string name, string filename) {
        this.id = id;
        this.name = name;
        this.filename = filename;
    }

    [DocumentId]
    public virtual int Id {
        get { return id; }
        set { id = value; }
    }

    [Field(Index.Tokenized, Store = Store.Yes)]
    public virtual string Name {
        get { return name; }
        set { name = value; }
    }  

    [Field(Index.Tokenized, Store = Store.Yes)]
    public virtual string FileName {
        get { return filename; }
        set { filename = value; }
    }
}

Upvotes: 0

Views: 268

Answers (1)

Johan Haest
Johan Haest

Reputation: 4421

You will have to index that file content first with Lucene.Net

Upvotes: 0

Related Questions