Browse Source

added 'number found' to search page

solr_update
Simon Bowie 2 years ago
parent
commit
c146646aad
4 changed files with 11 additions and 6 deletions
  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 View File

sort = request.form.get('sort') sort = request.form.get('sort')
else: else:
sort = 'relevance' 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 # route for id_search page
@search.route('/search/id/') @search.route('/search/id/')
else: else:
sort = 'relevance' sort = 'relevance'
id = request.args.get('id') 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: for result in results:
publication_details = ops.get_publication_details(result['doc_ref']) publication_details = ops.get_publication_details(result['doc_ref'])

+ 4
- 2
web/app/solr.py View File

# turn the API response into useful Json # turn the API response into useful Json
json = request.json() json = request.json()


if (json['response']['numFound'] == 0):
num_found = json['response']['numFound']

if (num_found == 0):
output = 'no results found' output = 'no results found'
else: else:
output = [] output = []
# parse result # parse result
result_output = parse_result(id, content) result_output = parse_result(id, content)
output.append(result_output) output.append(result_output)
return output
return output, num_found


def parse_result(id, input): def parse_result(id, input):



+ 0
- 1
web/app/templates/abstracts.html View File

<p class="mt-2 text-center">a <span id="time"></span> minute read out of 6375081 minutes reading time</p> <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> <a href="{{ url_for('main.index') }}" class="h1 text-left"> ⇽ </a>
</div> </div>

</div> </div>


<div id="alltext"> <div id="alltext">

+ 1
- 0
web/app/templates/search.html View File

<div class="col m-5"> <div class="col m-5">
<a href="{{ url_for('main.index') }}" class="h1 text-left"> ⇽ </a> <a href="{{ url_for('main.index') }}" class="h1 text-left"> ⇽ </a>
<p class="h1 text-center">a timeline of inventions</p> <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>
</div> </div>



Loading…
Cancel
Save