3

我需要一种使用 solr 通配符的方法在 sunburnt solr 中,或者是否有另一种方法可以从索引中指定“所有文档”然后精炼。这是代码

....
si = sunburnt.SolrInterface(url=solr_url,http_connection=h)
search_terms = {SEARCH_TERMS_COMIN_FROM_A_FORM}

#!This is where I need help!
result = si.query(WILDCARD)#I need all the docs from the index

#then I can do this
if search_terms['province']:
    result = result.query(province=search_terms['province'])
if search_terms['town']:
    result = result.query(town=search_terms['town'])
.......#two other similar if statement blocks
#finally
results = result.execute()
4

1 回答 1

6

当然:出于这个确切原因,您可以只使用一个空查询 - 这将起作用:

result = si.query()

if search_terms['province']:
    result = result.query(province=search_terms['province'])
if search_terms['town']:
    result = result.query(town=search_terms['town'])
于 2012-05-21T16:16:14.210 回答