Преглед на файлове

added 'number found' to search page

solr_update
Simon Bowie преди 2 години
родител
ревизия
c146646aad
променени са 4 файла, в които са добавени 11 реда и са изтрити 6 реда
  1. +6
    -3
      web/app/search.py
  2. +4
    -2
      web/app/solr.py
  3. +0
    -1
      web/app/templates/abstracts.html
  4. +1
    -0
      web/app/templates/search.html

+ 6
- 3
web/app/search.py Целия файл

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

+ 4
- 2
web/app/solr.py Целия файл

@@ -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):


+ 0
- 1
web/app/templates/abstracts.html Целия файл

@@ -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">

+ 1
- 0
web/app/templates/search.html Целия файл

@@ -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>


Loading…
Отказ
Запис