我正在使用 Google App Engine 搜索 API(https://developers.google.com/appengine/docs/python/search/)。我已经索引了所有实体并且搜索工作正常。但只有当我搜索完全匹配时,它才会返回 0 个结果。例如:
from google.appengine.api import search
_INDEX_NAME = 'searchall'
query_string ="United Kingdom"
query = search.Query(query_string=query_string)
index = search.Index(name=_INDEX_NAME)
print index.search(query)
如果我运行以下脚本,我会得到如下结果:
search.SearchResults(results='[search.ScoredDocument(doc_id='c475fd24-34ba-42bd-a3b5-d9a48d880012', fields='[search.TextField(name='name', value='United Kingdom')]', language='en', order_id='45395666'), search.ScoredDocument(doc_id='5fa757d1-05bf-4012-93ff-79dd4b77a878', fields='[search.TextField(name='name', value='United Kingdom')]', language='en', order_id='45395201')]', number_found='2')
但如果我将其更改query_string
为"United Kin"
或"United"
返回 0 结果如下:
search.SearchResults(number_found='0')
我想将此 API 用于普通搜索和 AutoSuggest。实现这一目标的最佳方法是什么?