如何使用NHibernate.search和Lucene.Net搜索文件内容
我已将Lucene.net和nhibernate.search集成在一起。我有一个域对象,它包含一个文件路径,这个文件路径指向光盘上的一个文件,其中包含文件内容。如何使用Lucene.Net/nhibernate.search搜索已保存文件的文件内容 每次保存/删除/更新域对象时,某些侦听器都会自动更改我的索引如何使用NHibernate.search和Lucene.Net搜索文件内容,nhibernate,search,lucene.net,nhibernate.search,Nhibernate,Search,Lucene.net,Nhibernate.search,我已将Lucene.net和nhibernate.search集成在一起。我有一个域对象,它包含一个文件路径,这个文件路径指向光盘上的一个文件,其中包含文件内容。如何使用Lucene.Net/nhibernate.search搜索已保存文件的文件内容 每次保存/删除/更新域对象时,某些侦听器都会自动更改我的索引 [Indexed] public class Book { private int id; private string name; private string
[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; }
}
}
您必须首先使用Lucene.Net为该文件内容编制索引,这是我的场景:我使用nhibernate保存一个文件域对象。此对象有一些属性,包括文件路径等。我的域对象正在使用lucene.net编制索引。现在我尝试进入我用nhibernate search保存的文件,并在该文件的文件内容中找到一个字符串匹配项。我认为,只要您没有为文件本身编制索引(阅读并使用lucene.net对其编制索引),就无法搜索内容。