def execute(self):
        out = []
        for position in range(
                self._s.to_dict()["from"],
                self._s.to_dict()["from"] + self._s.to_dict()["size"]):
            result = template.copy()
            result["highlight"] = {
                "name": ["<mark>" + str(position) + "</mark>"]
            }
            result["fields"]["name"] = str(position)
            result["fields"]["name_escaped"] = str(position)
            result["fields"]["id"] = position
            out.append(Hit(result))
        hits = AttrList(out)
        hits.__setattr__("total", len(out) * 2)

        return AttrDict({"hits": hits, "facets": get_aggregations()})
Example #2
0
    def execute(self):
        out = []
        for position in range(
            self._s.to_dict()["from"],
            self._s.to_dict()["from"] + self._s.to_dict()["size"],
        ):
            result = template.copy()
            result["highlight"] = {"name": ["<mark>" + str(position) + "</mark>"]}
            result["fields"] = {
                "id": position,
                "name": str(position),
                "name_escaped": str(position),
                "type": "file",
                "type_translated": "File",
                "created": "2017-11-24T09:06:05.159381+00:00",
                "modified": "2017-12-01T10:56:37.297771+00:00",
            }
            out.append(Hit(result))
        hits = AttrList(out)
        hits.__setattr__("total", len(out) * 2)

        return AttrDict({"hits": hits, "facets": get_aggregations()})
class discussion(Document):
    parent = Text()
    child = AttrList([])
    created_by = Text()
    created_time = Date()
    isChild = Boolean()
    likeCount = Integer()
    comment = Text()

    class Index:
        name = 'discussion_fourm'

    def save(self, **kwargs):
        if not self.parent: return None
        if not self.created_time: self.created_time = datetime.now()
        if not self.likeCount: self.likeCount = 0
        if not self.isChild: self.isChild = False
        if not self.created_by: self.created_by = "Admin"
        if not self.comment: self.comment = ""
        timestr = time.strftime("%Y%m%d-%H%M%S")
        discussionId = "DISS" + "-" + timestr
        self.meta.id = discussionId
        super(discussion, self).save(**kwargs)
        return self
 def execute(self):
     hits = AttrList([Hit(template)])
     hits.__setattr__("total", 1)
     return AttrDict({"hits": hits, "facets": get_aggregations()})
 def execute(self):
     hits = AttrList([Hit(template.copy())])
     hits.__setattr__("total", {"value": 1, "relation": "eq"})
     return AttrDict({"hits": hits, "facets": get_aggregations()})