Skip to content

Commit

Permalink
added indexes for BIDocument
Browse files Browse the repository at this point in the history
  • Loading branch information
mlodic committed Nov 16, 2023
1 parent 2e68133 commit 2d368c5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion certego_saas/ext/upload/elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __repr__(self):
from mongoengine import fields as mongo_fields

except ImportError:
from django.db.models import JSONField, Model
from django.db.models import Index, JSONField, Model
from django.db.models import fields as django_fields

class BIDocument(__BIDocumentInterface, Model):
Expand All @@ -79,6 +79,16 @@ class BIDocument(__BIDocumentInterface, Model):
count = django_fields.PositiveIntegerField()
kwargs = JSONField()

class Meta:
indexes = [
Index(
fields=[
"index",
"time",
]
)
]

else:

class BIDocument(__BIDocumentInterface, Document):
Expand All @@ -89,3 +99,4 @@ class BIDocument(__BIDocumentInterface, Document):
category = mongo_fields.StringField(required=True)
count = mongo_fields.IntField(required=True, min_value=0)
kwargs = mongo_fields.DictField(required=False)
meta = {"indexes": ["index", "time"]}

0 comments on commit 2d368c5

Please sign in to comment.