我正在尝试对呼呼结果应用过滤器。当我应用不带python函数的过滤器时,我得到了结果。然而,当我将过滤器放入python函数中时,我得到了'AttributeError:'Term‘对象没有'Term’属性。请参阅此处的示例要点:https://gist.github.com/akeahey/b6713a32cdff0ca2a58b63fdceab99be
发布于 2020-07-11 00:46:28
在这段代码中:
def filtered():
#search for term in individual
with iy.searcher() as searcher:
query = QueryParser("content", iy.schema).parse("example")
allow_q = query.Term("ind_id", "123")
results = searcher.search(query, filter=allow_q, limit=None)
print(results, len(results))将解析后的查询赋值给变量query会掩盖创建query.Term对象的能力。
请尝试以下操作:
def filtered():
#search for term in individual
with iy.searcher() as searcher:
parsedq = QueryParser("content", iy.schema).parse("example")
allow_q = query.Term("ind_id", "123")
results = searcher.search(parsedq, filter=allow_q, limit=None)
print(results, len(results))https://stackoverflow.com/questions/62763761
复制相似问题