mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 15:06:55 +00:00
Users/srnara/mongo index (#229)
* added placeholder * Added check box * Added tolltip width constant * Add telemetry * formatting error * formatting error * support only for mongo v 3.6 accounts * resolved comment
This commit is contained in:
parent
70c7d84bdb
commit
4b0b63b56b
@ -104,6 +104,7 @@
|
|||||||
@newCollectionPaneInputWidth: 300px;
|
@newCollectionPaneInputWidth: 300px;
|
||||||
@tooltipTextWidth: 280px;
|
@tooltipTextWidth: 280px;
|
||||||
@sharedCollectionThroughputTooltipTextWidth: 150px;
|
@sharedCollectionThroughputTooltipTextWidth: 150px;
|
||||||
|
@mongoWildcardIndexTooltipWidth: 150px;
|
||||||
@addContainerPaneThroughputInfoWidth: 370px;
|
@addContainerPaneThroughputInfoWidth: 370px;
|
||||||
@optionsInfoWidth: 210px;
|
@optionsInfoWidth: 210px;
|
||||||
@noFixedCollectionsTooltipWidth: 196px;
|
@noFixedCollectionsTooltipWidth: 196px;
|
||||||
|
@ -1565,6 +1565,10 @@ p {
|
|||||||
min-width: @tooltipTextWidth;
|
min-width: @tooltipTextWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mongoWildcardIndexTooltipWidth {
|
||||||
|
min-width: @mongoWildcardIndexTooltipWidth;
|
||||||
|
}
|
||||||
|
|
||||||
.sharedCollectionThroughputTooltipWidth {
|
.sharedCollectionThroughputTooltipWidth {
|
||||||
min-width: @sharedCollectionThroughputTooltipTextWidth;
|
min-width: @sharedCollectionThroughputTooltipTextWidth;
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,8 @@ import { refreshCachedResources } from "../DataAccessUtilityBase";
|
|||||||
import { sendNotificationForError } from "./sendNotificationForError";
|
import { sendNotificationForError } from "./sendNotificationForError";
|
||||||
import { userContext } from "../../UserContext";
|
import { userContext } from "../../UserContext";
|
||||||
import { createDatabase } from "./createDatabase";
|
import { createDatabase } from "./createDatabase";
|
||||||
|
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||||
|
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||||
|
|
||||||
export const createCollection = async (params: DataModels.CreateCollectionParams): Promise<DataModels.Collection> => {
|
export const createCollection = async (params: DataModels.CreateCollectionParams): Promise<DataModels.Collection> => {
|
||||||
let collection: DataModels.Collection;
|
let collection: DataModels.Collection;
|
||||||
@ -138,6 +140,7 @@ const createSqlContainer = async (params: DataModels.CreateCollectionParams): Pr
|
|||||||
};
|
};
|
||||||
|
|
||||||
const createMongoCollection = async (params: DataModels.CreateCollectionParams): Promise<DataModels.Collection> => {
|
const createMongoCollection = async (params: DataModels.CreateCollectionParams): Promise<DataModels.Collection> => {
|
||||||
|
const mongoWildcardIndexOnAllFields: ARMTypes.MongoIndex[] = [{ key: { keys: ["$**"] } }, { key: { keys: ["_id"] } }];
|
||||||
try {
|
try {
|
||||||
const getResponse = await getMongoDBCollection(
|
const getResponse = await getMongoDBCollection(
|
||||||
userContext.subscriptionId,
|
userContext.subscriptionId,
|
||||||
@ -166,6 +169,9 @@ const createMongoCollection = async (params: DataModels.CreateCollectionParams):
|
|||||||
const partitionKeyPath: string = params.partitionKey.paths[0];
|
const partitionKeyPath: string = params.partitionKey.paths[0];
|
||||||
resource.shardKey = { [partitionKeyPath]: "Hash" };
|
resource.shardKey = { [partitionKeyPath]: "Hash" };
|
||||||
}
|
}
|
||||||
|
if (params.createMongoWildcardIndex) {
|
||||||
|
resource.indexes = mongoWildcardIndexOnAllFields;
|
||||||
|
}
|
||||||
|
|
||||||
const rpPayload: ARMTypes.MongoDBCollectionCreateUpdateParameters = {
|
const rpPayload: ARMTypes.MongoDBCollectionCreateUpdateParameters = {
|
||||||
properties: {
|
properties: {
|
||||||
@ -182,6 +188,13 @@ const createMongoCollection = async (params: DataModels.CreateCollectionParams):
|
|||||||
params.collectionId,
|
params.collectionId,
|
||||||
rpPayload
|
rpPayload
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (params.createMongoWildcardIndex) {
|
||||||
|
TelemetryProcessor.trace(Action.CreateMongoCollectionWithWildcardIndex, ActionModifiers.Mark, {
|
||||||
|
message: "Mongo Collection created with wildcard index on all fields."
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return createResponse && (createResponse.properties.resource as DataModels.Collection);
|
return createResponse && (createResponse.properties.resource as DataModels.Collection);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -287,6 +287,7 @@ export interface CreateCollectionParams {
|
|||||||
indexingPolicy?: IndexingPolicy;
|
indexingPolicy?: IndexingPolicy;
|
||||||
partitionKey?: PartitionKey;
|
partitionKey?: PartitionKey;
|
||||||
uniqueKeyPolicy?: UniqueKeyPolicy;
|
uniqueKeyPolicy?: UniqueKeyPolicy;
|
||||||
|
createMongoWildcardIndex?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ReadDatabaseOfferParams {
|
export interface ReadDatabaseOfferParams {
|
||||||
|
@ -133,6 +133,7 @@ export default class Explorer {
|
|||||||
public isPreferredApiGraph: ko.Computed<boolean>;
|
public isPreferredApiGraph: ko.Computed<boolean>;
|
||||||
public isPreferredApiTable: ko.Computed<boolean>;
|
public isPreferredApiTable: ko.Computed<boolean>;
|
||||||
public isFixedCollectionWithSharedThroughputSupported: ko.Computed<boolean>;
|
public isFixedCollectionWithSharedThroughputSupported: ko.Computed<boolean>;
|
||||||
|
public isEnableMongoCapabilityPresent: ko.Computed<boolean>;
|
||||||
public isServerlessEnabled: ko.Computed<boolean>;
|
public isServerlessEnabled: ko.Computed<boolean>;
|
||||||
public isEmulator: boolean;
|
public isEmulator: boolean;
|
||||||
public isAccountReady: ko.Observable<boolean>;
|
public isAccountReady: ko.Observable<boolean>;
|
||||||
@ -522,22 +523,7 @@ export default class Explorer {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const capabilities = this.databaseAccount().properties && this.databaseAccount().properties.capabilities;
|
return this.isEnableMongoCapabilityPresent();
|
||||||
|
|
||||||
if (!capabilities) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < capabilities.length; i++) {
|
|
||||||
if (typeof capabilities[i] === "object") {
|
|
||||||
if (capabilities[i].name === Constants.CapabilityNames.EnableMongo) {
|
|
||||||
// version 3.6
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.isServerlessEnabled = ko.computed(
|
this.isServerlessEnabled = ko.computed(
|
||||||
@ -569,6 +555,21 @@ export default class Explorer {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.isEnableMongoCapabilityPresent = ko.computed(() => {
|
||||||
|
const capabilities = this.databaseAccount && this.databaseAccount()?.properties?.capabilities;
|
||||||
|
if (!capabilities) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < capabilities.length; i++) {
|
||||||
|
if (typeof capabilities[i] === "object" && capabilities[i].name === Constants.CapabilityNames.EnableMongo) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
this.isHostedDataExplorerEnabled = ko.computed<boolean>(
|
this.isHostedDataExplorerEnabled = ko.computed<boolean>(
|
||||||
() =>
|
() =>
|
||||||
this.getPlatformType() === PlatformType.Portal &&
|
this.getPlatformType() === PlatformType.Portal &&
|
||||||
|
@ -418,7 +418,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- large parition key - end -->
|
<!-- large parition key - end -->
|
||||||
|
|
||||||
<!-- Provision collection throughput - start -->
|
|
||||||
<!-- ko if: canConfigureThroughput -->
|
<!-- ko if: canConfigureThroughput -->
|
||||||
<!-- Provision collection throughput checkbox - start -->
|
<!-- Provision collection throughput checkbox - start -->
|
||||||
<div class="pkPadding" data-bind="visible: databaseHasSharedOffer() && !databaseCreateNew()">
|
<div class="pkPadding" data-bind="visible: databaseHasSharedOffer() && !databaseCreateNew()">
|
||||||
@ -511,6 +510,23 @@
|
|||||||
<!-- /ko -->
|
<!-- /ko -->
|
||||||
<!-- Provision collection throughput - end -->
|
<!-- Provision collection throughput - end -->
|
||||||
|
|
||||||
|
<!-- Custom indexes for mongo checkbox - start -->
|
||||||
|
<div class="pkPadding" data-bind="visible: container.isEnableMongoCapabilityPresent()">
|
||||||
|
<p>
|
||||||
|
<span class="addCollectionLabel">Indexing</span>
|
||||||
|
</p>
|
||||||
|
<input type="checkbox" id="mongoWildcardIndex" title="mongoWildcardIndex"
|
||||||
|
data-bind="checked: shouldCreateMongoWildcardIndex" />
|
||||||
|
<span>Create a Wildcard Index on all fields</span>
|
||||||
|
<span class="infoTooltip" role="tooltip" tabindex="0">
|
||||||
|
<img class="infoImg" src="/info-bubble.svg" alt="More information">
|
||||||
|
<span class="tooltiptext mongoWildcardIndexTooltipWidth">
|
||||||
|
By default, only the field _id is indexed. Creating a wildcard index on all fields will quickly optimize query performance and is recommended during development.
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<!-- Custom indexes for mongo checkbox - end -->
|
||||||
|
|
||||||
<!-- Enable analytical storage - start -->
|
<!-- Enable analytical storage - start -->
|
||||||
<div class="enableAnalyticalStorage pkPadding" aria-label="Enable Analytical Store"
|
<div class="enableAnalyticalStorage pkPadding" aria-label="Enable Analytical Store"
|
||||||
data-bind="visible: isSynapseLinkSupported">
|
data-bind="visible: isSynapseLinkSupported">
|
||||||
|
@ -99,6 +99,7 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||||||
public ruToolTipText: ko.Computed<string>;
|
public ruToolTipText: ko.Computed<string>;
|
||||||
public canConfigureThroughput: ko.PureComputed<boolean>;
|
public canConfigureThroughput: ko.PureComputed<boolean>;
|
||||||
public showUpsellMessage: ko.PureComputed<boolean>;
|
public showUpsellMessage: ko.PureComputed<boolean>;
|
||||||
|
public shouldCreateMongoWildcardIndex: ko.Observable<boolean>;
|
||||||
|
|
||||||
private _databaseOffers: HashMap<DataModels.Offer>;
|
private _databaseOffers: HashMap<DataModels.Offer>;
|
||||||
private _isSynapseLinkEnabled: ko.Computed<boolean>;
|
private _isSynapseLinkEnabled: ko.Computed<boolean>;
|
||||||
@ -660,6 +661,8 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||||||
changedSelectedValueTo: value ? ActionModifiers.IndexAll : ActionModifiers.NoIndex
|
changedSelectedValueTo: value ? ActionModifiers.IndexAll : ActionModifiers.NoIndex
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.shouldCreateMongoWildcardIndex = ko.observable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getSharedThroughputDefault(): boolean {
|
public getSharedThroughputDefault(): boolean {
|
||||||
@ -832,9 +835,10 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||||||
let collectionId: string = this.collectionId().trim();
|
let collectionId: string = this.collectionId().trim();
|
||||||
|
|
||||||
let indexingPolicy: DataModels.IndexingPolicy;
|
let indexingPolicy: DataModels.IndexingPolicy;
|
||||||
|
let createMongoWildcardIndex: boolean;
|
||||||
// todo - remove mongo indexing policy ticket # 616274
|
// todo - remove mongo indexing policy ticket # 616274
|
||||||
if (this.container.isPreferredApiMongoDB()) {
|
if (this.container.isPreferredApiMongoDB()) {
|
||||||
indexingPolicy = SharedConstants.IndexingPolicies.Mongo;
|
createMongoWildcardIndex = this.shouldCreateMongoWildcardIndex();
|
||||||
} else if (this.showIndexingOptionsForSharedThroughput()) {
|
} else if (this.showIndexingOptionsForSharedThroughput()) {
|
||||||
if (this.useIndexingForSharedThroughput()) {
|
if (this.useIndexingForSharedThroughput()) {
|
||||||
indexingPolicy = SharedConstants.IndexingPolicies.AllPropertiesIndexed;
|
indexingPolicy = SharedConstants.IndexingPolicies.AllPropertiesIndexed;
|
||||||
@ -864,7 +868,8 @@ export default class AddCollectionPane extends ContextualPaneBase {
|
|||||||
autoPilotMaxThroughput,
|
autoPilotMaxThroughput,
|
||||||
indexingPolicy,
|
indexingPolicy,
|
||||||
partitionKey,
|
partitionKey,
|
||||||
uniqueKeyPolicy
|
uniqueKeyPolicy,
|
||||||
|
createMongoWildcardIndex
|
||||||
};
|
};
|
||||||
|
|
||||||
createCollection(createCollectionParams).then(
|
createCollection(createCollectionParams).then(
|
||||||
|
@ -228,42 +228,6 @@ export class IndexingPolicies {
|
|||||||
],
|
],
|
||||||
excludedPaths: <any>[]
|
excludedPaths: <any>[]
|
||||||
};
|
};
|
||||||
|
|
||||||
// todo - remove mongo indexing policy ticket # 616274
|
|
||||||
public static Mongo = {
|
|
||||||
indexingMode: "consistent",
|
|
||||||
automatic: true,
|
|
||||||
includedPaths: [
|
|
||||||
{
|
|
||||||
path: "/*",
|
|
||||||
indexes: [
|
|
||||||
{
|
|
||||||
kind: "Range",
|
|
||||||
dataType: "Number",
|
|
||||||
precision: -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kind: "Range",
|
|
||||||
dataType: "String",
|
|
||||||
precision: -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kind: "Spatial",
|
|
||||||
dataType: "Point"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kind: "Spatial",
|
|
||||||
dataType: "LineString"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kind: "Spatial",
|
|
||||||
dataType: "Polygon"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
excludedPaths: <any>[]
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SubscriptionUtilMappings {
|
export class SubscriptionUtilMappings {
|
||||||
|
@ -71,7 +71,8 @@ export enum Action {
|
|||||||
NotebooksGitHubManageRepo,
|
NotebooksGitHubManageRepo,
|
||||||
NotebooksGitHubCommit,
|
NotebooksGitHubCommit,
|
||||||
NotebooksGitHubDisconnect,
|
NotebooksGitHubDisconnect,
|
||||||
OpenTerminal
|
OpenTerminal,
|
||||||
|
CreateMongoCollectionWithWildcardIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ActionModifiers = {
|
export const ActionModifiers = {
|
||||||
|
Loading…
Reference in New Issue
Block a user