使用 ndb 模型通过 Google 应用引擎进行全文搜索

发布于 2025-01-05 06:57:06 字数 310 浏览 2 评论 0原文

我已经使用下一个数据库模块(ndb)制作了一个谷歌应用程序来创建我的模型。现在的问题是我想在这些模型的字段上部署搜索,并且我找到了两个模块可以做到这一点:1.官方附带的谷歌应用程序引擎(appengine/google/ext/search)和2.gae文本搜索(http://code.google.com/p/gae-text-search/)。这两者都为旧的数据库模块属性提供了可搜索模型。有什么方法可以使用 ndb 和 google app engine 1.6.2 进行全文搜索。另外我想将这些搜索查询存储到数据存储中,我怎样才能实现这一点?我正在使用 python 2.7 进行开发。提前致谢。

I have made a google app using next db module (ndb) to create my models. Now the problem is i want to deploy search over the fields of these models, and i have found two modules to do that: 1. The officially shipped with google app engine (appengine/google/ext/search) and 2. gae text search (http://code.google.com/p/gae-text-search/). Both of these provide the Searchable Model for the old db module properties. Is there any way i can do full text search using ndb and google app engine 1.6.2. Also i want to store those search queries to the datastore, how can i achieve that too? I am using python 2.7 for my development. Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

离线来电— 2025-01-12 06:57:06

最好的解决方案是等到App Engine的全文搜索发布。他们目前处于可信测试阶段,所以很快就会推出。如果您现在推出自己的解决方案,您可能会在几个月后重做它。

The best solution is to wait until app engine's full text search is released. They are currently in trusted tester phase, so it's coming soon. If you roll your own solution now, you may end up redoing it in a few months.

回忆那么伤 2025-01-12 06:57:06

从:
https://cloud.google.com/appengine/docs/python/search/

搜索 API 提供了一个模型来索引包含以下内容的文档:
结构化数据。您可以搜索索引,并组织和呈现
搜索结果。 API 支持字符串字段的全文匹配。
文档和索引保存在单独的持久存储中
针对搜索操作进行了优化。搜索 API 可以索引任意数字
文件。

执行搜索:

index.search("rose water")

索引对象:

from datetime import datetime
from google.appengine.api import search 

my_document = search.Document(
    fields=[
       search.TextField(name='customer', value='Joe Jackson'),
       search.HtmlField(name='comment', value='this is <em>marked up</em> text'),
       search.NumberField(name='number_of_visits', value=7), 
       search.DateField(name='last_visit', value=datetime.now()),
       search.DateField(name='birthday', value=datetime(year=1960, month=6, day=19)),
       search.GeoField(name='home_location', value=search.GeoPoint(37.619, -122.37))
       ])

From:
https://cloud.google.com/appengine/docs/python/search/

The Search API provides a model for indexing documents that contain
structured data. You can search an index, and organize and present
search results. The API supports full text matching on string fields.
Documents and indexes are saved in a separate persistent store
optimized for search operations. The Search API can index any number
of documents.

Performing a search:

index.search("rose water")

Indexing an object:

from datetime import datetime
from google.appengine.api import search 

my_document = search.Document(
    fields=[
       search.TextField(name='customer', value='Joe Jackson'),
       search.HtmlField(name='comment', value='this is <em>marked up</em> text'),
       search.NumberField(name='number_of_visits', value=7), 
       search.DateField(name='last_visit', value=datetime.now()),
       search.DateField(name='birthday', value=datetime(year=1960, month=6, day=19)),
       search.GeoField(name='home_location', value=search.GeoPoint(37.619, -122.37))
       ])
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文