Skip to content

Commit

Permalink
Added cosmosdb indexing policy as code
Browse files Browse the repository at this point in the history
  • Loading branch information
lwitkowski committed Feb 18, 2025
1 parent be9a0e8 commit 5789a7b
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions backend/src/offers_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import uuid
from datetime import datetime, UTC

from azure.cosmos import PartitionKey, ThroughputProperties
from azure.cosmos import PartitionKey, ThroughputProperties, IndexingMode

from db import database
from my_logging import *
Expand All @@ -14,7 +14,30 @@
container = database.create_container_if_not_exists(
id="offers",
partition_key=PartitionKey(path="/id"),
offer_throughput=ThroughputProperties(offer_throughput="600")
offer_throughput=ThroughputProperties(offer_throughput="600"),
indexing_policy=dict(
automatic=True,
indexingMode=IndexingMode.Consistent,
includedPaths=[
dict(path="/published_at/?"),
dict(path="/url/?"),
dict(path="/classified/?"),
],
excludedPaths=[
dict(path="/*")
],
compositeIndexes=[
[
dict(path="/category", order="ascending"),
dict(path="/published_at", order="descending")
],
[
dict(path="/manufacturer", order="ascending"),
dict(path="/model", order="ascending"),
dict(path="/published_at", order="descending")
]
]
)
)


Expand Down

0 comments on commit 5789a7b

Please sign in to comment.