-1

lucene.net 总是以这种方式将索引数据存储在平面文件中......这是创建索引并将索引数据存储在平面文件中的示例代码。

String sql = "select id, firstname, lastname, phone, email from person";
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
    Document doc = new Document();
    doc.add(new Field("id", rs,getString("id"), Field.Store.YES, Field.Index.UN_TOKENIZED));
    doc.add(new Field("firstname", rs,getString("firstname"), Field.Store.YES, Field.Index.TOKENIZED));  
    // ... repeat for each column in result set
    writer.addDocument(doc);
}

所以请指导我如何将 lucene.net 索引数据存储到 sql server 表而不是平面文件....有可能....如果可以,请指导我。谢谢

4

1 回答 1

1

The whole idea of using Lucene is not to use a database. Lucene index files are optmized to do what it does best, search.

If you want to use a database and since you are using SqlServer go with FullText Search instead.

Lucene is an option for database servers that does not have full text search capabilities (of course it does more, but the primary usage is that).

于 2013-11-12T18:33:36.420 回答