diff --git a/src/Contracts/DataModels.ts b/src/Contracts/DataModels.ts index c03ec0a2d..5ef3a8094 100644 --- a/src/Contracts/DataModels.ts +++ b/src/Contracts/DataModels.ts @@ -553,6 +553,7 @@ export interface GraphParameters extends RpParameters { pk: string; coll: string; cd: Boolean; + indexingPolicy?: IndexingPolicy; } export interface CreationRequest { @@ -570,6 +571,7 @@ export interface SqlCollectionParameters extends RpParameters { coll: string; cd: Boolean; analyticalStorageTtl?: number; + indexingPolicy?: IndexingPolicy; } export interface MongoCreationRequest extends CreationRequest { @@ -588,6 +590,7 @@ export interface GraphCreationRequest extends CreationRequest { resource: { id: string; partitionKey: {}; + indexingPolicy?: IndexingPolicy; }; options: RpOptions; }; @@ -613,6 +616,7 @@ export interface SqlCollectionCreationRequest extends CreationRequest { id: string; partitionKey: {}; analyticalStorageTtl?: number; + indexingPolicy?: IndexingPolicy; }; options: RpOptions; }; diff --git a/src/Explorer/Panes/AddCollectionPane.ts b/src/Explorer/Panes/AddCollectionPane.ts index 5df974ffa..2d8d57e70 100644 --- a/src/Explorer/Panes/AddCollectionPane.ts +++ b/src/Explorer/Panes/AddCollectionPane.ts @@ -889,6 +889,7 @@ export default class AddCollectionPane extends ContextualPaneBase implements Vie this.container.armEndpoint(), databaseId, collectionId, + indexingPolicy, offerThroughput, partitionKeyPath, partitionKey.version, @@ -908,6 +909,7 @@ export default class AddCollectionPane extends ContextualPaneBase implements Vie databaseId, this._getAnalyticalStorageTtl(), collectionId, + indexingPolicy, offerThroughput, partitionKeyPath, partitionKey.version, diff --git a/src/Shared/AddCollectionUtility.test.ts b/src/Shared/AddCollectionUtility.test.ts index 48fb560e0..f459e3a41 100644 --- a/src/Shared/AddCollectionUtility.test.ts +++ b/src/Shared/AddCollectionUtility.test.ts @@ -1,3 +1,4 @@ +import * as SharedConstants from "../Shared/Constants"; import { AddDbUtilities } from "../Shared/AddDatabaseUtility"; import { CreateCollectionUtilities, CreateSqlCollectionUtilities, Utilities } from "./AddCollectionUtility"; jest.mock("AddDatabaseUtility"); @@ -19,6 +20,7 @@ describe("Add Collection Utitlity", () => { rg: "b1", st: true, defaultTtl: -1, + indexingPolicy: SharedConstants.IndexingPolicies.AllPropertiesIndexed, partitionKeyVersion: 2 }; const additionalOptions = {}; @@ -28,6 +30,7 @@ describe("Add Collection Utitlity", () => { properties.db, properties.defaultTtl, properties.coll, + properties.indexingPolicy, properties.offerThroughput, properties.pk, properties.partitionKeyVersion, @@ -55,6 +58,7 @@ describe("Add Collection Utitlity", () => { rg: "b1", st: true, analyticalStorageTtl: -1, + indexingPolicy: SharedConstants.IndexingPolicies.AllPropertiesIndexed, partitionKeyVersion: 2 }; const additionalOptions = {}; @@ -65,6 +69,7 @@ describe("Add Collection Utitlity", () => { properties.db, properties.analyticalStorageTtl, properties.coll, + properties.indexingPolicy, properties.offerThroughput, properties.pk, properties.partitionKeyVersion, @@ -95,6 +100,7 @@ describe("Add Collection Utitlity", () => { sid: "a1", rg: "b1", st: true, + indexingPolicy: SharedConstants.IndexingPolicies.AllPropertiesIndexed, partitionKeyVersion: 2 }; const additionalOptions = {}; @@ -103,6 +109,7 @@ describe("Add Collection Utitlity", () => { armEndpoint, properties.db, properties.coll, + properties.indexingPolicy, properties.offerThroughput, properties.pk, properties.partitionKeyVersion, @@ -127,6 +134,7 @@ describe("Add Collection Utitlity", () => { sid: "a1", rg: "b1", st: true, + indexingPolicy: SharedConstants.IndexingPolicies.AllPropertiesIndexed, partitionKeyVersion: 2 }; const additionalOptions = {}; @@ -136,6 +144,7 @@ describe("Add Collection Utitlity", () => { armEndpoint, properties.db, properties.coll, + properties.indexingPolicy, properties.offerThroughput, properties.pk, properties.partitionKeyVersion, diff --git a/src/Shared/AddCollectionUtility.ts b/src/Shared/AddCollectionUtility.ts index 5f5323dba..563c4470a 100644 --- a/src/Shared/AddCollectionUtility.ts +++ b/src/Shared/AddCollectionUtility.ts @@ -18,6 +18,7 @@ export class CreateSqlCollectionUtilities { databaseId: string, analyticalStorageTtl: number, collectionId: string, + indexingPolicy: DataModels.IndexingPolicy, offerThroughput: number, partitionKey: string, partitionKeyVersion: number, @@ -41,6 +42,7 @@ export class CreateSqlCollectionUtilities { rg, dba, analyticalStorageTtl, + indexingPolicy, partitionKeyVersion }; @@ -75,6 +77,10 @@ export class CreateSqlCollectionUtilities { rpPayloadToCreateCollection.properties.resource.analyticalStorageTtl = params.analyticalStorageTtl; } + if (params.indexingPolicy) { + rpPayloadToCreateCollection.properties.resource.indexingPolicy = params.indexingPolicy; + } + if (!params.st) { if (rpOptions) { rpPayloadToCreateCollection.properties.options = rpOptions; @@ -117,6 +123,7 @@ export class CreateCollectionUtilities { armEndpoint: string, databaseId: string, collectionId: string, + indexingPolicy: DataModels.IndexingPolicy, offerThroughput: number, partitionKey: string, partitionKeyVersion: number, @@ -137,6 +144,7 @@ export class CreateCollectionUtilities { sid, rg, dba, + indexingPolicy, partitionKeyVersion }; @@ -167,6 +175,10 @@ export class CreateCollectionUtilities { } }; + if (params.indexingPolicy) { + rpPayloadToCreateCollection.properties.resource.indexingPolicy = params.indexingPolicy; + } + if (!params.st) { if (rpOptions) { rpPayloadToCreateCollection.properties.options = rpOptions;