I am new to sunburnt and am looking to incorporate it in Django.
Why can I not use a variable to define the field in which I want to query, e.g. at the moment, I have to check query string and then assign the actual solr schema field as shown below inside the query().
query = request.GET['q']
field = request.GET['field']
if field == 'all':
field_query = solr.query(text=query)
elif field == 'title':
field_query = solr.query(title=query)
elif field == 'author':
field_query = solr.query(author=query)
elif field == 'company':
field_query = solr.query(company=query)
elif field == 'keywords':
field_query = solr.query(keywords=query)
elif field == 'year':
field_query = solr.query(year=query)
whereas, this would be so much simpler.
query = request.GET['q']
field = request.GET['field']
if field == 'all':
field_query = solr.query(text=query)
else:
field_query = solr.query(field=query) #note field here which is not defined in solr schema but is a python variable
Thanks for your help in advance.