在GAE Search API的Python版本中查询搜索索引时,首先返回的是搜索具有与标题匹配的文档的项目的最佳实践,然后返回与正文相匹配的文档?
例如给出:
body = """This is the body of the document,
with a set of words"""
my_document = search.Document(
fields=[
search.TextField(name='title', value='A Set Of Words'),
search.TextField(name='body', value=body),
])
Run Code Online (Sandbox Code Playgroud)
如果可能的话,如何Document使用此优先级返回的结果对上述表单的s 的索引执行搜索,其中要搜索的短语位于变量中qs:
title匹配的文件qs; 然后qs单词匹配的文档.似乎正确的解决方案是使用a MatchScorer,但我可能在此处不合适,因为我之前没有使用过此搜索功能.从文档中不清楚如何使用MatchScorer,但我假设一个子类并重载一些函数 - 但由于这没有记录,我没有深入研究代码,我不能肯定地说.
这里有什么我想念的,或者这是正确的策略?我是否想念记录这类事情的地方?
为了清楚起见,这是一个更详细的预期结果的例子:
documents = [
dict(title="Alpha", body="A"), # "Alpha"
dict(title="Beta", body="B Two"), # "Beta"
dict(title="Alpha Two", body="A"), # "Alpha2"
]
for doc in documents:
search.Document(
fields=[
search.TextField(name="title", …Run Code Online (Sandbox Code Playgroud)