使用Google App Engine和JDO进行全文搜索? [英] full-text search using Google App Engine and JDO?

查看:162
本文介绍了使用Google App Engine和JDO进行全文搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有JDO的Google App Engine(Java)。我怎样才能做到JDO相当于

I'm using Google App Engine (Java) with JDO. How can I do the JDO equivalent of

select * from table where field like '%foo%'

到目前为止,我唯一看到的建议是使用Lucene。我很惊讶这个基本功能在开箱即用的GAE上是不可能的。

The only recommendation I have seen so far is to use Lucene. I'm kind of surprised that something this basic is not possible on out-of-the-box GAE.

推荐答案

您可以在App Engine上不会进行这种类型的子字符串搜索。原因是App Engine数据存储构建的是可伸缩的,并拒绝执行它无法满足索引的任何查询。索引这样的查询几乎是不可能的,因为它需要搜索每条记录的'field'属性的全部匹配项。任何运行此查询的关系数据库都将通过执行全表扫描并单独检查每条记录来执行它 - 不可伸缩,至少可以说。

You can't do substring searches of that sort on App Engine. The reason for this is that the App Engine datastore is built to be scalable, and refuses to execute any query it can't satisfy with an index. Indexing a query like this is next to impossible, because it requires searching the entirety of each record's 'field' property for a match. Any relational database you run this query on will execute it by doing a full table scan and checking each record individually - unscalable, to say the least.

解决方案与您一样已经发现,是使用全文索引,比如Lucene。在App Engine上有用于运行Lucene的库,例如 GAELucene 。这也给你适当的全文搜索的力量,而不是天真的子串匹配。

The solution, as you've already found out, is to use full-text indexing, such as Lucene. There are libraries for running Lucene on App Engine, such as GAELucene. This also gives you the power of proper full-text search, rather than naive substring matching.

这篇关于使用Google App Engine和JDO进行全文搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆