使用 Whoosh 在 App Engine 上进行全文搜索

发布于 2024-07-25 08:54:54 字数 1454 浏览 9 评论 0原文

我需要使用 Google App Engine 进行全文搜索。 我发现了该项目 Whoosh 只要我使用App Engine 开发环境...当我将应用程序上传到 App Engine 时,我收到以下 TraceBack。 对于我的测试,我使用该项目中提供的示例应用程序。 知道我做错了什么吗?

<type 'exceptions.ImportError'>: cannot import name loads
Traceback (most recent call last):
  File "/base/data/home/apps/myapp/1.334374478538362709/hello.py", line 6, in <module>
    from whoosh import store
  File "/base/data/home/apps/myapp/1.334374478538362709/whoosh/__init__.py", line 17, in <module>
    from whoosh.index import open_dir, create_in
  File "/base/data/home/apps/myapp/1.334374478538362709/whoosh/index.py", line 31, in <module>
    from whoosh import fields, store
  File "/base/data/home/apps/myapp/1.334374478538362709/whoosh/store.py", line 27, in <module>
    from whoosh import tables
  File "/base/data/home/apps/myapp/1.334374478538362709/whoosh/tables.py", line 43, in <module>
    from marshal import loads

这是我的 Python 文件中的导入。

# Whoosh ----------------------------------------------------------------------
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'utils')))
from whoosh.fields import Schema, STORED, ID, KEYWORD, TEXT
from whoosh.index import getdatastoreindex
from whoosh.qparser import QueryParser, MultifieldParser

预先感谢您的帮助!

I need to do full text searching with Google App Engine. I found the project Whoosh and it works really well, as long as I use the App Engine Development Environement... When I upload my application to App Engine, I am getting the following TraceBack. For my tests, I am using the example application provided in this project. Any idea of what I am doing wrong?

<type 'exceptions.ImportError'>: cannot import name loads
Traceback (most recent call last):
  File "/base/data/home/apps/myapp/1.334374478538362709/hello.py", line 6, in <module>
    from whoosh import store
  File "/base/data/home/apps/myapp/1.334374478538362709/whoosh/__init__.py", line 17, in <module>
    from whoosh.index import open_dir, create_in
  File "/base/data/home/apps/myapp/1.334374478538362709/whoosh/index.py", line 31, in <module>
    from whoosh import fields, store
  File "/base/data/home/apps/myapp/1.334374478538362709/whoosh/store.py", line 27, in <module>
    from whoosh import tables
  File "/base/data/home/apps/myapp/1.334374478538362709/whoosh/tables.py", line 43, in <module>
    from marshal import loads

Here is the import I have in my Python file.

# Whoosh ----------------------------------------------------------------------
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'utils')))
from whoosh.fields import Schema, STORED, ID, KEYWORD, TEXT
from whoosh.index import getdatastoreindex
from whoosh.qparser import QueryParser, MultifieldParser

Thank you in advance for your help!

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

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

发布评论

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

评论(4

淡淡の花香 2024-08-01 08:54:54

应用程序引擎不支持 marshal 模块。 它在那里,但它是空的。 那个元帅在开发中正常工作。 环境已注册为问题

请参阅文档

您可以尝试以下方法来对元帅模块进行猴子修补。 在执行任何其他导入之前放置以下代码:

import pickle
import marshal
marshal.loads = pickle.loads
marshal.dumps = pickle.dumps # I assume it needs dumps also

我还没有尝试过这个,所以我完全不知道它是否会起作用! 另请注意,pickle 加载/转储比 marshal 加载/转储慢。

The marshal module is not supported on app engine. It is there, but it is empty. That marshal is working as normal in the dev. environment has been registered as an issue.

See the documentation.

You could try the following to monkeypatch the marshal module. Put the following code before you do any other imports:

import pickle
import marshal
marshal.loads = pickle.loads
marshal.dumps = pickle.dumps # I assume it needs dumps also

I have not tried this, so I have absolutely no idea if it will work! Also be aware that pickle loads/dumps is slower than marshal loads/dumps.

围归者 2024-08-01 08:54:54

请参阅此处的评论#71:
http://code.google.com/p/googleappengine/issues/detail?id=217&q=Whoosh&colspec=ID%20Type%20Status%20Priority%20Stars%20Owner%20Summary %20Log%20Component#c71

这不是我的工具,但它说:

我通过移植 创建了全文搜索 api http://whoosh.ca/ 所以它是可用的
在 AppEngine 上。 (它将索引存储在数据存储中)

您可以从 http://github.com 下载它/tallstreet/Whoosh-AppEngine/tree/master

它包含 Whooshes 的所有功能,包括:

1 个 Pythonic API。
2 字段索引和搜索。
3 快速索引和检索
4 可插拔评分算法(包括BM25F)、文本分析、存储、发布
格式等
5 通过 pyparsing 解析的强大查询语言。
6 纯Python拼写检查器

See comment #71 here:
http://code.google.com/p/googleappengine/issues/detail?id=217&q=Whoosh&colspec=ID%20Type%20Status%20Priority%20Stars%20Owner%20Summary%20Log%20Component#c71:

It's not my tool, but it says:

I have created a full text search api by porting http://whoosh.ca/ so it is avaliable
on AppEngine. (it stores the index in the datastore)

You can download it from http://github.com/tallstreet/Whoosh-AppEngine/tree/master

It includes all of Whooshes features including:

1 Pythonic API.
2 Fielded indexing and search.
3 Fast indexing and retrieval
4 Pluggable scoring algorithm (including BM25F), text analysis, storage, posting
format, etc.
5 Powerful query language parsed by pyparsing.
6 Pure Python spell-checker

往日情怀 2024-08-01 08:54:54

这是有关实现全文搜索的官方示例:http: //code.google.com/p/guestbook-example-appengine-full-text-search/

我目前正在阅读它,因为我需要实现它,也许它也会对其他人有所帮助。

This is an official example about implementing full text search: http://code.google.com/p/guestbook-example-appengine-full-text-search/

I'm currently reading through it as I'm in the need of implementing it, maybe it will help others also.

蓝海似她心 2024-08-01 08:54:54

您也许可以通过下载并使用 Whoosh 版本 Whoosh-Appengine 来解决您的问题它专门针对与 Google App Engine 配合使用。

You could probably solve your problems by downloading and using Whoosh-Appengine, the Whoosh version that's specifically targeted to working with Google App Engine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文