class MeetingDocument(DocType):
    location = GeoPointField()
    sort_date = DateField()

    agenda_items = NestedField(attr="agendaitem_set",
                               properties={
                                   "key": StringField(),
                                   "title": StringField(),
                                   "position": IntegerField(),
                                   "public": BooleanField(),
                               })

    @staticmethod
    def prepare_location(instance: Meeting):
        if instance.location:
            return instance.location.coordinates()

    class Meta:
        model = Meeting

        fields = [
            'id',
            'name',
            'short_name',
            'start',
            'end',
            'created',
            'modified',
        ]
class FileDocument(Document):
    autocomplete = TextField(attr="name_autocomplete",
                             analyzer=autocomplete_analyzer)
    coordinates = GeoPointField(attr="coordinates")
    person_ids = IntegerField(attr="person_ids")
    description = TextField(attr="description", analyzer=text_analyzer)
    # Elasticsearch wants `index_options: "offsets"` for the highlighter for large texts
    parsed_text = TextField(attr="parsed_text",
                            analyzer=text_analyzer,
                            index_options="offsets")

    def get_queryset(self):
        return (File.objects.prefetch_related("locations").prefetch_related(
            "mentioned_persons").order_by("id"))

    class Index:
        name = settings.ELASTICSEARCH_PREFIX + "-file"

    class Django:
        model = File
        queryset_pagination = settings.ELASTICSEARCH_QUERYSET_PAGINATION

        fields = [
            "id",
            "name",
            "filename",
            "page_count",
            "created",
            "modified",
            "sort_date",
        ]
class FileDocument(DocType):
    autocomplete = TextField(attr="name_autocomplete", analyzer=autocomplete_analyzer)
    coordinates = GeoPointField(attr="coordinates")
    person_ids = IntegerField(attr="person_ids")
    description = TextField(attr="description", analyzer=text_analyzer)
    # Elasticsearch wants `index_options: "offsets"` for the highlighter for large texts
    parsed_text = TextField(
        attr="parsed_text", analyzer=text_analyzer, index_options="offsets"
    )

    def get_queryset(self):
        return (
            File.objects.prefetch_related("locations")
            .prefetch_related("mentioned_persons")
            .order_by("id")
        )

    class Meta:
        model = File
        queryset_pagination = 500

        fields = [
            "id",
            "name",
            "filename",
            "page_count",
            "created",
            "modified",
            "sort_date",
        ]
Esempio n. 4
0
class MeetingDocument(DocType):
    location = GeoPointField()
    sort_date = DateField()

    agenda_items = NestedField(
        attr="agendaitem_set",
        properties={
            "key": TextField(),
            "name": TextField(analyzer=text_analyzer),
            "position": IntegerField(),
            "public": BooleanField(),
        },
    )

    @staticmethod
    def prepare_location(instance: Meeting) -> Optional[Dict[str, Any]]:
        if instance.location:
            return instance.location.coordinates()

    def get_queryset(self):
        return (Meeting.objects.prefetch_related(
            "agendaitem_set").prefetch_related("location").order_by("id"))

    class Meta:
        model = Meeting
        queryset_pagination = 500

        fields = [
            "id", "name", "short_name", "start", "end", "created", "modified"
        ]
Esempio n. 5
0
class FileDocument(DocType):
    coordinates = GeoPointField(attr="coordinates")

    class Meta:
        model = File

        fields = [
            'id',
            'name',
            'description',
            'displayed_filename',
            'parsed_text',
            'created',
            'modified',
        ]
Esempio n. 6
0
class FileDocument(DocType):
    autocomplete = StringField(attr="name_autocomplete",
                               analyzer=autocomplete_analyzer)
    coordinates = GeoPointField(attr="coordinates")
    person_ids = IntegerField(attr="person_ids")

    class Meta:
        model = File

        fields = [
            'id',
            'name',
            'description',
            'displayed_filename',
            'page_count',
            'parsed_text',
            'created',
            'modified',
            'sort_date',
        ]