issues-search

use whoosh to search github issues.

Implemented in Python using Flask, Whoosh and Mistune.

notes

had to update how the update process worked:

  • seems inefficient, but re-adding every document every index update
  • works fine if not updating all the time
  • gonna need to grab the content every time anyway
  • need to add a field that's the content's hash
  • compare indexed content's hash with fetched content's hash

when changing the schema:

  • the schema changes, so the document addition changes (args)
  • but also,
    • in issues_app.py we call the search() method on our Search object
    • in issues_search.py, search() method calls create_search_result()
    • create_search_result() extracts particular fields and bundles them up
    • the search results are ultimately returned to the app's /search endpoint, which passes them to a template as-is: search.html
    • keyword: entries = result
    • therefore, search.html and create_search_result() must also change to reflect changes in field names

summary of how to change the schema:

  • issues_app.py:
    • just combines the schema with the template, nothing to update
  • issues_search.py:
    • main place where schema is defined/used
    • Search class defines Schema object, main definition
    • add_issue() (equally important) which defines how to extract the fields defined in the schema from the document
    • create_search_result() (also important) which packages up the search results for the template to deal with
  • search.html: the search.html template uses a different variable namespace than the Python file issues_search.py or the flask app
    • The create_search-result() method of issues_search.py defines how search results are parsed and packaged for the search.html template
    • Jinja variables used in search.html should be defined in create_search_result() method of issues_search.py
Description
use whoosh to search across issues in a github repository
Readme 5.6 MiB
Languages
Python 53.4%
CSS 39.1%
HTML 7.5%