コード例 #1
0
 class PostIndex(DeclarativeIndex):
     name = "test-post"
     mappings = {
         "properties": {
             "title": Text(),
             "published_from": Date(),
             "created_at": Date(),
         }
     }
     document = PostDocument
コード例 #2
0
ファイル: test_document.py プロジェクト: alkemics/pandagg
class User(InnerDocSource):

    id: int = Long(required=True)
    signed_up: str = Date()
    username: str = Text(fields={"keyword": Keyword()}, required=True, multiple=False)
    email = Text(fields={"keyword": Keyword()})
    location = Text(fields={"keyword": Keyword()})
コード例 #3
0
ファイル: test_document.py プロジェクト: alkemics/pandagg
    class AutoArchivedPost(DocumentSource):

        updated = Date(required=True)
        archived = Boolean()

        def _post_init_(self) -> None:
            # automatically archive post that hasn't been updated in a while
            if self.updated and self.updated < "2020":
                self.archived = True
コード例 #4
0
ファイル: test_document.py プロジェクト: alkemics/pandagg
    class AutoDatePost(DocumentSource):

        author = Object(properties=User, required=True)
        updated = Date(required=True)
        body = Text(required=True)
        comments = Nested(properties=Comment, multiple=True)

        def _pre_save_op_(self):
            if self.updated is None:
                # TODO - handle datetime serialization
                self.updated = "2021-01-01"
コード例 #5
0
class PostTemplate(DeclarativeIndexTemplate):
    name = "test-template"
    index_patterns = "test-post*"
    template = {
        "mappings": {
            "properties": {
                "title": Text(),
                "published_from": Date()
            }
        },
        "settings": {
            "number_of_shards": 1
        },
        "aliases": {
            "post": {}
        },
    }
コード例 #6
0
ファイル: test_document.py プロジェクト: alkemics/pandagg
class Post(DocumentSource):

    author = Object(properties=User, required=True)
    created = Date(required=True)
    body = Text(required=True)
    comments = Nested(properties=Comment, multiple=True)
コード例 #7
0
ファイル: test_document.py プロジェクト: alkemics/pandagg
class Comment(InnerDocSource):

    author = Object(properties=User, required=True)
    created = Date(required=True)
    content = Text(required=True)
コード例 #8
0
 class PostDocument(DocumentSource):
     title = Text()
     published_from = Date()
コード例 #9
0
class Post(DeclarativeIndex):
    name = "test-post"
    mappings = {"properties": {"title": Text(), "published_from": Date()}}
    settings = {"number_of_shards": 1}
    aliases = {"post": {}}