Vote count:
0
I am trying to improve my Solr search efficiency and realized I have a huge bottleneck in the results request function in my views.py file. I have now discovered that implementing Solr deep paging is the way forward however I am struggling to understand where it fits in to my code. Below is a snippet of my views.py:
def results(request):
""" Perform the search and display the results. """
request.method == 'GET':
query = request.GET.get('q', '')
# Setup a Solr instance and perform search.
solr = search.Search(query)
results = solr.get_results()
# Retrieve all the keys from the query.
index = search.Search.get_keys(results)
# Retrieves total count of hits in a document
term_count = solr.term_count(results)
# Combine into a single results object
combined_results = []
for result in results:
saved_item = ''
combined_result = [result, saved_item]
combined_results.append(combined_result)
# Create the page data
paginator = Paginator(list(combined_results), 10) # Show 25 contacts per page
page = request.GET.get('page')
# Render the page using the Solr results
return render(request, 'solr_search/results.html', {'results': list(combined_results),
'index': index,
'query_term': query,
'term_count': term_count,
'data': pag_data
})
I have read the following articles so I understand how the deep paging and cursor mark works:
However, I haven't come across any real examples of how to fit it into my code.
How would I go about doing this? Or if you have any advice/experience on the Deep Paging with Solr in Python/Django then that will also be very helpful.
asked 17 secs ago
What is the best way to implement the Solr Cursormark in Django/Python?
Aucun commentaire:
Enregistrer un commentaire