Search code examples
pythonsolrsunburnt

Sunburnt solr wildcard *:*


I need a way of Using the solr wildcard : in sunburnt solr or is there another way of specifying 'all documents' from index then refining.Here is the code

....
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()

Solution

  • Sure: for this exact reason you can just use an empty query - this will work:

    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'])