@@ -24,8 +24,10 @@ def basic_search(): | |||
sort = request.form.get('sort') | |||
else: | |||
sort = 'relevance' | |||
results = solr.solr_search(core, sort, search) | |||
return render_template('search.html', results=results, search=search, core=core, sort=sort) | |||
search_results = solr.solr_search(core, sort, search) | |||
results = search_results[0] | |||
num_found = search_results[1] | |||
return render_template('search.html', results=results, num_found=num_found, search=search, core=core, sort=sort) | |||
# route for id_search page | |||
@search.route('/search/id/') | |||
@@ -39,7 +41,8 @@ def id_search(): | |||
else: | |||
sort = 'relevance' | |||
id = request.args.get('id') | |||
results = solr.solr_search(core, sort, search, id) | |||
search_results = solr.solr_search(core, sort, search, id) | |||
results = search_results[0] | |||
for result in results: | |||
publication_details = ops.get_publication_details(result['doc_ref']) |
@@ -32,7 +32,9 @@ def solr_search(core, sort, search=None, id=None): | |||
# turn the API response into useful Json | |||
json = request.json() | |||
if (json['response']['numFound'] == 0): | |||
num_found = json['response']['numFound'] | |||
if (num_found == 0): | |||
output = 'no results found' | |||
else: | |||
output = [] | |||
@@ -44,7 +46,7 @@ def solr_search(core, sort, search=None, id=None): | |||
# parse result | |||
result_output = parse_result(id, content) | |||
output.append(result_output) | |||
return output | |||
return output, num_found | |||
def parse_result(id, input): | |||
@@ -13,7 +13,6 @@ | |||
<p class="mt-2 text-center">a <span id="time"></span> minute read out of 6375081 minutes reading time</p> | |||
<a href="{{ url_for('main.index') }}" class="h1 text-left"> ⇽ </a> | |||
</div> | |||
</div> | |||
<div id="alltext"> |
@@ -6,6 +6,7 @@ | |||
<div class="col m-5"> | |||
<a href="{{ url_for('main.index') }}" class="h1 text-left"> ⇽ </a> | |||
<p class="h1 text-center">a timeline of inventions</p> | |||
<p class="mt-2 text-center">{{ num_found }} patents found out of 320,000</p> | |||
</div> | |||
</div> | |||