Browse Source

new mapping using the persistence API

master
wes 7 years ago
parent
commit
cd50456b61
  1. 37
      src/mapping.py

37
src/mapping.py

@ -0,0 +1,37 @@
from elasticsearch_dsl import DocType, Date, Nested, Boolean, \
analyzer, InnerObjectWrapper, Completion, Keyword, Text, Object
from elasticsearch_dsl.connections import connections
connections.create_connection(hosts=["localhost"])
class TextBook(InnerObjectWrapper):
pass
class Section(InnerObjectWrapper):
pass
class Course(DocType):
textbook = Object(
doc_class=TextBook,
properties = {
"author" : Text(),
"title" : Text(),
"price" : Text()
}
)
sections = Object(
doc_class=Section,
properties = {
"sem" : Keyword(),
"title" : Text(),
"prof" : Text(),
"loc" : Text(),
"time" : Text(),
"day" : Text()
}
)
class Meta:
index = "course_test"
Loading…
Cancel
Save