我构建了一个数据库,我希望能够使用GAE中的Search API进行搜索。我点击了Google上关于API的教程,但我缺少的一件事是如何将数据存储类型转换为“文档”。有什么好的教程吗?谢谢如何在我的GAE数据存储上实现搜索API?
2
A
回答
3
db.Model ndb.Model不能转换为search.Document。
为什么?因为它没有太多的价值。
我给你一些例子 - 你有字符串“这-是黑标签”在db.StringProperty()如何将它转换:
- 你可以使用它作为原子 - 所以比赛将是如果完全匹配
- 您可以将其用作字符串 - 因此它会被分成'this','is','black','tag',而不是标记为't','th','thi','this ” ...
- 您可以决定是不可见的,因为在搜索忍不住给虚假点击
您需要自己设计搜索功能,它应该是手动设计,即答案。
你只需要:
- 创建search.Document
- 添加字段
- 添加文档索引
阅读参考:https://developers.google.com/appengine/docs/python/search/documentclass
0
不幸的是,这是不可能的。
看看索引构造函数(python),我们可以确定在早期阶段实现了一些尝试,但它从未真正起作用。指定索引的来源现在已经被弃用了一段时间,并且不再工作。
这里的构造是pydoc:(?)
class Index(object):
[...]
def __init__(self, name, namespace=None, source=SEARCH):
"""Initializer.
Args:
name: The name of the index. An index name must be a visible printable
ASCII string not starting with '!'. Whitespace characters are excluded.
namespace: The namespace of the index name. If not set, then the current
namespace is used.
source: Deprecated as of 1.7.6. The source of
the index:
SEARCH - The Index was created by adding documents throught this
search API.
DATASTORE - The Index was created as a side-effect of putting entities
into Datastore.
CLOUD_STORAGE - The Index was created as a side-effect of adding
objects into a Cloud Storage bucket.
[...]
"""
因此,至少就目前而言,唯一的解决办法,就像Tim Hoffman提到的,是从你的数据存储的数据分别处理您的文件和索引。
您仍然可以向https://code.google.com/p/googleappengine/issues/list提交功能请求,并在那里发送。
0
我有成千上万的实体,我想建立一个索引,然后使用mapreduce为我的实体构建索引,并且可以通过搜索API进行搜索。 MapReduce的工作是
- name: buildindex
mapper:
input_reader: mapreduce.input_readers.DatastoreInputReader
handler: main.buildindex
params:
- name: entity_kind
default: main.Article
功能
def buildindex(entity):
try:
doc = search.Document(doc_id=str(entity.key()), fields=[
search.TextField(name='title', value=entity.title),
search.TextField(name='text', value=entity.text),
])
search.Index(name='myIndex').put(doc)
except Exception, e:
logging.exception('Mapreduce has exception:%s' % str(e))
相关问题
- 1. 搜索GAE数据存储属性
- 2. 将GAE搜索API与数据存储集成
- 3. Appengine搜索API vs数据存储
- 4. 如何使存储的S3存储桶数据在marklogic中搜索8 REST API
- 5. 如何检查gae数据存储中是否存在实体?
- 6. 如何在GAE JDO实现类似的搜索的3
- 7. 如何在Google数据存储中有效地搜索实体
- 8. 如何在我的数据库中实现“搜索”?
- 9. GAE搜索API现在支持部分搜索
- 10. GAE低级Java数据存储API
- 11. 数据存储API和GAE/PHP
- 12. 在GAE数据存储
- 13. 在GAE数据存储
- 14. 按索引查询GAE数据存储
- 15. GAE数据存储索引未创建
- 16. 如何在jqgrid上实现搜索?
- 17. GAE - 爪哇 - 数据存储实体
- 18. GAE数据存储实体关系
- 19. 搜索blob存储数据
- 20. 如何在存储在Azure存储上的视频中搜索
- 21. 如何在php中为GAE数据存储生成实体ID?
- 22. GAE呈现“无”,但我可以在数据存储查看器中看到数据存储实体
- 23. 数据存储在本地主机上,但不在gae数据存储上?
- 24. 搜索存储在树中的数据
- 25. 如何在GAE数据存储区中正确保存数据?
- 26. DDD - 如何实现高性能的存储库搜索
- 27. 通过密钥从GAE数据存储检索实体
- 28. 在GAE上保存数据:日志与数据存储
- 29. 如何在couchdb/NoSQL数据存储上实现IMAP服务器?
- 30. 如何在GAE上使用数据存储区游标与jpa
编写的代码拷贝属性值从数据存储实体到搜索API文档。 –