Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const indexTypeToIndexSelectOption: Record<IndexType, string> = {
'1': '1 (asc)',
'-1': '-1 (desc)',
'2dsphere': '2dsphere',
text: 'text',
text: 'text (full text search)',
};

export async function createIndex(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ import { useTelemetry } from '@mongodb-js/compass-telemetry/provider';
/**
* Current allowed types for indexes.
*/
const INDEX_TYPES = ['1 (asc)', '-1 (desc)', '2dsphere', 'text', 'columnstore'];
const INDEX_TYPES = [
'1 (asc)',
'-1 (desc)',
'2dsphere',
'text (full text search)',
'columnstore',
];

/**
* Default values for field name and type as presented in the UI.
Expand Down Expand Up @@ -96,7 +102,7 @@ function CreateIndexFields({
track('New Index Field Added', {
context: 'Create Index Modal',
});
}, [onAddFieldClick]);
}, [onAddFieldClick, track]);

const comboboxOptions = schemaFields.map((value) => ({ value }));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('create-index module', function () {
describe('#createIndexFormSubmitted', function () {
beforeEach(function () {
store.dispatch(updateFieldName(0, 'foo'));
store.dispatch(fieldTypeUpdated(0, 'text'));
store.dispatch(fieldTypeUpdated(0, 'text (full text search)'));
});

it('validates collation', function () {
Expand Down
5 changes: 4 additions & 1 deletion packages/compass-indexes/src/modules/create-index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,10 @@ function fieldTypeToIndexDirection(type: string): IndexDirection {
if (type === '-1 (desc)') {
return -1;
}
if (type === 'text' || type === '2dsphere') {
if (type === 'text (full text search)') {
return 'text';
}
Comment on lines +543 to +545
Copy link
Preview

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original condition if (type === 'text' || type === '2dsphere') on line 546 still includes the old 'text' check, but this code path is now unreachable since 'text (full text search)' is handled above. The condition should be updated to only check for '2dsphere' or the old 'text' condition should be removed entirely.

Copilot uses AI. Check for mistakes.

if (type === '2dsphere') {
return type;
}
throw new Error(`Unsupported field type: ${type}`);
Expand Down