From 800634c4980886fd1fd64c3e7c6d6a0cb87d8b1c Mon Sep 17 00:00:00 2001 From: wes Date: Sun, 2 Apr 2017 16:50:15 -0400 Subject: [PATCH] remove useless code --- src/search.py | 59 --------------------------------------------------- 1 file changed, 59 deletions(-) diff --git a/src/search.py b/src/search.py index 05ac9af..033aa50 100755 --- a/src/search.py +++ b/src/search.py @@ -22,22 +22,6 @@ def summarize(text): return " ".join(splitted[0:6]) + ".." return text -def sectionToJSON(section): - return { - "prof" : section.prof, - "sem" : section.sem, - "day" : section.day - } - -def classToJSON(clss): - return { - "title" : clss.title, - "sections" : map(sectionToJSON, clss.sections), - "dept" : clss.dept, - "code" : clss.code, - "books" : list(clss.books) if clss.books else [] - } - def hashsec(course): """ Hash a course into a usable id @@ -61,48 +45,6 @@ def hashsec(course): h.update(code + title + course["sections"][0]["sem"]) return int(h.hexdigest(), 16) -def createIndex(name): - """ - This creates a new index in elasticsearch - An index is like a schema in a regular database - """ - indices = elasticsearch.client.IndicesClient(es) - - print(indices.create(name)) - with open("../course.json", "r") as mapping: - print(indices.put_mapping("course", loads(mapping.read()), name)) - -def indexListing(course): - """ - Index a specific course in the database (using the courses index) - example, - { - 'books': [], - 'dept': 'COLLAB', - 'code': '2C03', - 'sections': [ - { - 'prof': 'Lisa Pender', - 'sem': '2015/09/08 - 2015/12/08', - 'day': 'Mo' - }, - { - 'prof': 'Staff', - 'sem': '2015/09/08 - 2015/12/08', - 'day': 'Th' - } - ], - 'title': 'COLLAB 2C03 - Sociology I' - } - - """ - json_course = classToJSON(course) - courseID = hashsec(json_course) - print(es.index(index="oersearch", - doc_type="course", - id=courseID, - body=json_course)) - def termSearch(field): """ Make a term search (exact match) @@ -196,7 +138,6 @@ def search_courses(terms): return results - searchers = { "title" : search("title"), "loc" : search("loc"),