7

到目前为止,我知道指南针可以处理这项工作。但是用指南针索引看起来相当昂贵。有没有更轻的替代品?

4

5 回答 5

6

老实说,我不知道 Lucene 在索引方面是否会比 Compass 更轻(为什么会这样,Compass 不为此使用 Lucene 吗?)。

无论如何,因为您要求替代品,所以有GAELucene。我在下面引用它的公告

受到讨论“我可以在 google app engine 中运行 Lucene 吗? ”的启发,我实现了一个基于 google datastore 的 Lucene 组件 GAELucene,它可以帮助您在 google app engine 上运行搜索应用程序。

GAELucene 的主要 clazz 包括:

  • GAEDirectory - 基于谷歌数据存储的只读目录。
  • GAEFile——代表一个索引文件,文件的字节内容会被分割成多个GAEFileContent。
  • GAEFileContent - 代表一段索引文件。
  • GAECategory - 不同索引的标识符。
  • GAEIndexInput - 内存驻留的IndexInput?像 RAMInputStream 这样的实现。
  • GAEIndexReader - IndexReader 的包装器?缓存在 GAEIndexReaderPool 中的
  • GAEIndexReaderPool - GAEIndexReader 池

以下代码片段演示了使用 GAELucene 进行搜索:

Query queryObject = parserQuery(request);
GAEIndexReaderPool readerPool = GAEIndexReaderPool.getInstance();
GAEIndexReader indexReader = readerPool.borrowReader(INDEX_CATEGORY_DEMO);
IndexSearcher searcher = newIndexSearcher(indexReader);
Hits hits = searcher.search(queryObject);
readerPool.returnReader(indexReader);

我强烈建议阅读关于 nabble 的整个讨论,内容非常丰富。

以防万一,关于 Compass,Shay Banon 写了一篇博文,详细介绍了如何在 App Engine 中使用 Compass:http ://www.kimchy.org/searchable-google-appengine-with-compass/

于 2010-01-03T20:04:56.710 回答
4

Apache Lucene是 Java 中全文索引的事实上的选择。看起来Compass Core包含“Lucene Directory 的实现,用于在数据库中存储索引(使用 Jdbc)。它与 Compass 代码库分离,可以与纯 Lucene 应用程序一起使用。” 加上大量的其他东西。您可以尝试仅分离 Lucence 组件,从而剥离几个库并使其更轻量级。要么完全放弃 Compass 并使用纯朴素的 Lucene。

于 2010-01-03T18:46:44.423 回答
1

对于 Google App Engine,我见过的唯一索引库是appengine-search ,在这个页面上有如何使用它的描述。不过我还没试过。

我使用过Lucene(Compass 所基于的),发现它以相对较低的费用工作得很好。索引是一项任务,您可以在适用于您的应用程序的时间安排。

此 SO 线程中提到了一些替代索引项目,包括Xapianminion。不过,我还没有检查过其中任何一个,因为 Lucene 完成了我需要的一切。

于 2010-01-03T18:57:57.140 回答
0

Google App 引擎内部搜索似乎更好,甚至支持同义词:

https://developers.google.com/appengine/docs/java/search/

于 2013-04-30T19:44:47.217 回答
0

如果你想在 GAE 上运行 Lucene,你也可以看看LuGAEne。它是 Lucene 的GAE目录的实现。

用法其实很简单,只需将 Lucene 的标准目录之一替换为GaeDirectory

Directory directory = new GaeDirectory("MyIndex");
Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_43);
IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_43, analyzer);
IndexWriter writer = new IndexWriter(directory, config);
...

gaelucene似乎处于“维护模式”(自 2009 年 9 月以来没有提交),当您在应用程序中使用Objectify版本 4 时, lucene-appengine(尚未)工作。

免责声明:我是 LuGAEne 的作者。

于 2013-06-15T07:23:56.273 回答