0

我使用 Springs-Hibernate 框架和 MySQL 数据库构建了一个基于 java 的 Web 应用程序。我想使用 lucene 在我的应用程序中集成搜索功能。由于我是 lucene 新手,任何人都可以帮助我从我的数据库中索引数据并实现搜索功能的步骤吗?

4

2 回答 2

0

您可以首先下载 Lucene 4.x 并编写代码以从数据库中获取每一行。

然后使用本文档中给出的示例对其进行索引: http: //lucene.apache.org/core/4_4_0/core/overview-summary.html#overview_description

对于您的用例,示例的这一部分需要遍历所有行以对其进行索引。

Document doc = new Document();
String text = "This is the text to be indexed.";
doc.add(new Field("fieldname", text, TextField.TYPE_STORED));
iwriter.addDocument(doc);

虽然我建议使用 Solr ( http://www.apache.org/dyn/closer.cgi/lucene/solr/4.4.0 ),这是一个基于 lucene 构建的搜索应用程序。它提供了一种广泛的方法来索引关系数据库中的文档。 http://wiki.apache.org/solr/DataImportHandler

于 2013-09-27T09:54:14.987 回答
0

当需要在 Hibernate 映射数据库上实现基于 Lucene 的搜索引擎时,您肯定想查看Hibernate Search

于 2017-03-08T20:31:48.317 回答