2018-10-26 09:10:46 +00:00
|
|
|
from elasticsearch_dsl import Document, Date, Keyword, Text, Boolean
|
2018-10-19 18:23:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Question(Document):
|
|
|
|
title = Text(analyzer="snowball")
|
2018-10-23 11:16:23 +00:00
|
|
|
body = Text(
|
|
|
|
analyzer="snowball",
|
|
|
|
fielddata=True,
|
|
|
|
)
|
2018-10-19 18:23:52 +00:00
|
|
|
category = Keyword()
|
|
|
|
date = Date()
|
2018-10-26 09:10:46 +00:00
|
|
|
answers = Text(analyzer="snowball")
|
|
|
|
|
|
|
|
dead = Boolean()
|
|
|
|
error = Boolean()
|
2018-10-19 18:23:52 +00:00
|
|
|
|
|
|
|
class Index:
|
|
|
|
name = "goeievraag"
|
|
|
|
|
|
|
|
def save(self, **kwargs):
|
|
|
|
return super(Question, self).save(**kwargs)
|
|
|
|
|
|
|
|
def url(self):
|
|
|
|
id_ = self.meta.id
|
|
|
|
return f"https://www.startpagina.nl/v/vraag/{id_}/"
|
|
|
|
|
|
|
|
def summary(self, length=128):
|
|
|
|
if len(self.body) > length:
|
|
|
|
return self.body[:length - 3] + "..."
|
|
|
|
|
|
|
|
return self.body
|