【问题标题】:How to search for file content using NHibernate.Search and Lucene.Net如何使用 NHibernate.Search 和 Lucene.Net 搜索文件内容
【发布时间】:2012-12-05 14:24:33
【问题描述】:

我已将 Lucene.net 和 nhibernate.search 集成在一起。我有一个包含文件路径的域对象,该文件路径指向磁盘上的一个文件,该文件具有文件内容。如何使用 Lucene.Net/nhibernate.search 搜索已保存文件的文件内容?

每次我保存/删除/更新域对象时,一些侦听器都会自动更改我的索引。

[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; }
    }
}

【问题讨论】:

    标签: nhibernate search lucene.net nhibernate.search


    【解决方案1】:

    您必须首先使用 Lucene.Net 索引该文件内容

    【讨论】:

    • 这是我的场景:我使用 nhibernate 保存一个文件域对象。该对象有一些属性,包括文件路径等。我的域对象正在使用 lucene.net 进行索引。现在我正在尝试进入我使用 nhibernate 搜索保存的文件,并在该文件的文件内容中找到匹配的字符串。
    • 我认为,只要您没有为文件本身编制索引(通读并使用 lucene.net 编制索引),您就无法搜索内容。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-22
    相关资源
    最近更新 更多