Add French, German, and Spanish to Full Text Search (Update container only) (#2228)

* Add multiple languages for Full Text Search Policy

* fix tests

* show multiple languages for multi language support enabled accounts

* addressed comments

---------

Co-authored-by: Asier Isayas <aisayas@microsoft.com>
This commit is contained in:
asier-isayas
2025-10-24 12:15:12 -07:00
committed by GitHub
parent 31ec3c08bc
commit ff1eb6a78e
5 changed files with 38 additions and 5 deletions

View File

@@ -89,7 +89,7 @@ export class CapabilityNames {
public static readonly EnableMongo: string = "EnableMongo"; public static readonly EnableMongo: string = "EnableMongo";
public static readonly EnableServerless: string = "EnableServerless"; public static readonly EnableServerless: string = "EnableServerless";
public static readonly EnableNoSQLVectorSearch: string = "EnableNoSQLVectorSearch"; public static readonly EnableNoSQLVectorSearch: string = "EnableNoSQLVectorSearch";
public static readonly EnableNoSQLFullTextSearch: string = "EnableNoSQLFullTextSearch"; public static readonly EnableNoSQLFullTextSearchPreviewFeatures: string = "EnableNoSQLFullTextSearchPreviewFeatures";
} }
export enum CapacityMode { export enum CapacityMode {

View File

@@ -12,6 +12,7 @@ import {
import { FullTextIndex, FullTextPath, FullTextPolicy } from "Contracts/DataModels"; import { FullTextIndex, FullTextPath, FullTextPolicy } from "Contracts/DataModels";
import { CollapsibleSectionComponent } from "Explorer/Controls/CollapsiblePanel/CollapsibleSectionComponent"; import { CollapsibleSectionComponent } from "Explorer/Controls/CollapsiblePanel/CollapsibleSectionComponent";
import * as React from "react"; import * as React from "react";
import { isFullTextSearchPreviewFeaturesEnabled } from "Utils/CapabilityUtils";
export interface FullTextPoliciesComponentProps { export interface FullTextPoliciesComponentProps {
fullTextPolicy: FullTextPolicy; fullTextPolicy: FullTextPolicy;
@@ -22,6 +23,7 @@ export interface FullTextPoliciesComponentProps {
) => void; ) => void;
discardChanges?: boolean; discardChanges?: boolean;
onChangesDiscarded?: () => void; onChangesDiscarded?: () => void;
englishOnly?: boolean;
} }
export interface FullTextPolicyData { export interface FullTextPolicyData {
@@ -66,6 +68,7 @@ export const FullTextPoliciesComponent: React.FunctionComponent<FullTextPolicies
onFullTextPathChange, onFullTextPathChange,
discardChanges, discardChanges,
onChangesDiscarded, onChangesDiscarded,
englishOnly,
}): JSX.Element => { }): JSX.Element => {
const getFullTextPathError = (path: string, index?: number): string => { const getFullTextPathError = (path: string, index?: number): string => {
let error = ""; let error = "";
@@ -87,6 +90,7 @@ export const FullTextPoliciesComponent: React.FunctionComponent<FullTextPolicies
if (!fullTextPolicy) { if (!fullTextPolicy) {
fullTextPolicy = { defaultLanguage: getFullTextLanguageOptions()[0].key as never, fullTextPaths: [] }; fullTextPolicy = { defaultLanguage: getFullTextLanguageOptions()[0].key as never, fullTextPaths: [] };
} }
return fullTextPolicy.fullTextPaths.map((fullTextPath: FullTextPath) => ({ return fullTextPolicy.fullTextPaths.map((fullTextPath: FullTextPath) => ({
...fullTextPath, ...fullTextPath,
pathError: getFullTextPathError(fullTextPath.path), pathError: getFullTextPathError(fullTextPath.path),
@@ -166,7 +170,7 @@ export const FullTextPoliciesComponent: React.FunctionComponent<FullTextPolicies
<Dropdown <Dropdown
required={true} required={true}
styles={dropdownStyles} styles={dropdownStyles}
options={getFullTextLanguageOptions()} options={getFullTextLanguageOptions(englishOnly)}
selectedKey={defaultLanguage} selectedKey={defaultLanguage}
onChange={(_event: React.FormEvent<HTMLDivElement>, option: IDropdownOption) => onChange={(_event: React.FormEvent<HTMLDivElement>, option: IDropdownOption) =>
setDefaultLanguage(option.key as never) setDefaultLanguage(option.key as never)
@@ -211,7 +215,7 @@ export const FullTextPoliciesComponent: React.FunctionComponent<FullTextPolicies
<Dropdown <Dropdown
required={true} required={true}
styles={dropdownStyles} styles={dropdownStyles}
options={getFullTextLanguageOptions()} options={getFullTextLanguageOptions(englishOnly)}
selectedKey={fullTextPolicy.language} selectedKey={fullTextPolicy.language}
onChange={(_event: React.FormEvent<HTMLDivElement>, option: IDropdownOption) => onChange={(_event: React.FormEvent<HTMLDivElement>, option: IDropdownOption) =>
onFullTextPathPolicyChange(index, option) onFullTextPathPolicyChange(index, option)
@@ -229,11 +233,30 @@ export const FullTextPoliciesComponent: React.FunctionComponent<FullTextPolicies
); );
}; };
export const getFullTextLanguageOptions = (): IDropdownOption[] => { export const getFullTextLanguageOptions = (englishOnly?: boolean): IDropdownOption[] => {
return [ const multiLanguageSupportEnabled: boolean = isFullTextSearchPreviewFeaturesEnabled() && !englishOnly;
const fullTextLanguageOptions: IDropdownOption[] = [
{ {
key: "en-US", key: "en-US",
text: "English (US)", text: "English (US)",
}, },
...(multiLanguageSupportEnabled
? [
{
key: "fr-FR",
text: "French",
},
{
key: "de-DE",
text: "German",
},
{
key: "es-ES",
text: "Spanish",
},
]
: []),
]; ];
return fullTextLanguageOptions;
}; };

View File

@@ -893,6 +893,8 @@ export class AddCollectionPanel extends React.Component<AddCollectionPanelProps,
) => { ) => {
this.setState({ fullTextPolicy, fullTextIndexes, fullTextPolicyValidated }); this.setState({ fullTextPolicy, fullTextIndexes, fullTextPolicyValidated });
}} }}
// Remove when multi language support on container create issue is fixed
englishOnly={true}
/> />
</Stack> </Stack>
</Stack> </Stack>

View File

@@ -516,6 +516,7 @@ exports[`AddCollectionPanel should render Default properly 1`] = `
} }
> >
<FullTextPoliciesComponent <FullTextPoliciesComponent
englishOnly={true}
fullTextPolicy={ fullTextPolicy={
{ {
"defaultLanguage": "en-US", "defaultLanguage": "en-US",

View File

@@ -24,3 +24,10 @@ export const isVectorSearchEnabled = (): boolean => {
(isCapabilityEnabled(Constants.CapabilityNames.EnableNoSQLVectorSearch) || isFabricNative()) (isCapabilityEnabled(Constants.CapabilityNames.EnableNoSQLVectorSearch) || isFabricNative())
); );
}; };
export const isFullTextSearchPreviewFeaturesEnabled = (): boolean => {
return (
userContext.apiType === "SQL" &&
isCapabilityEnabled(Constants.CapabilityNames.EnableNoSQLFullTextSearchPreviewFeatures)
);
};