Skip to content

Commit

Permalink
Implemented search using elasticsearch
Browse files Browse the repository at this point in the history
  • Loading branch information
mhk19 committed Apr 10, 2020
1 parent ddfdeb3 commit cbc58f0
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions rest_api/documents.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from django_elasticsearch_dsl import Document, Index
from rest_api.models import Course, Department, File

courses = Index('courses')
departments = Index('departments')
files = Index('files')

@courses.doc_type
class CourseDocument(Document):
class Django:
model = Course

fields = [
'id',
'title',
'code',
]

@departments.doc_type
class DepartmentDocument(Document):
class Django:
model = Department

fields = [
'id',
'title',
'abbreviation',
]

@files.doc_type
class FileDocument(Document):
class Django:
model = File

fields = [
'id',
'title',
'fileext',
'filetype'
]

0 comments on commit cbc58f0

Please sign in to comment.