根据https://developers.google.com/appengine/docs/python/datastore/datamodeling :
The datastore supports two value types for storing text: short text strings up to 500 >characters in length, and long text strings up to one megabyte in length. Short strings are >indexed and can be used in query filter conditions and sort orders. Long strings are not >indexed and cannot be used in filter conditions or sort orders.
这对我来说是一个问题,因为我的网站上充斥着政府文件的文本。该网站的全部目的是使这些文档易于访问,即可搜索。然后我还阅读了:https://developers.google.com/appengine/training/fts_intro/ :
Search can query any data, so long as that data is described by a search document.
我根本不清楚我实际上可以对大型文本字段文档进行全文搜索,因为搜索对象显然与数据存储实体不同。所以,我的问题是: 如果您有一大块文本,并且无法对其进行索引、过滤或排序,是否可以使用搜索 api 找到它,或者无索引规则也适用于此吗?如果是这样,那么如何有效地使用 GAE 处理大型文本文档呢? 谢谢。
最佳答案
使用类似 django-watson 的内容用于全文搜索。
示例模型代码:
import watson
class Document (models.Model):
#: Title for the item
title = models.CharField(max_length=45, blank=False,
help_text="Document title")
#: Description for the item.
description = models.TextField(blank=False,
help_text="Description of the document")
#: Document text for searching
doc_text = models.TextField(blank=False,
help_text="Searchable document text")
watson.register(Document.objects.all(), fields=("title", "description",
"doc_text"))
关于python - 如何搜索包含 blob 或长字符串的网页内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21392513/