-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Code changes to add muli api support #14706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -92,6 +92,7 @@ export type CharFilterUnion = | |
| | CharFilter | ||
| | MappingCharFilter | ||
| | PatternReplaceCharFilter; | ||
| export type LexicalNormalizerUnion = LexicalNormalizer | CustomNormalizer; | ||
| export type SimilarityUnion = Similarity | ClassicSimilarity | BM25Similarity; | ||
|
|
||
| /** Represents a datasource definition, which can be used to configure an indexer. */ | ||
|
|
@@ -595,7 +596,7 @@ export interface SearchIndex { | |
| /** The character filters for the index. */ | ||
| charFilters?: CharFilterUnion[]; | ||
| /** The normalizers for the index. */ | ||
| normalizers?: LexicalNormalizer[]; | ||
| normalizers?: LexicalNormalizerUnion[]; | ||
| /** A description of an encryption key that you create in Azure Key Vault. This key is used to provide an additional level of encryption-at-rest for your data when you want full assurance that no one, not even Microsoft, can decrypt your data in Azure Cognitive Search. Once you have encrypted your data, it will always remain encrypted. Azure Cognitive Search will ignore attempts to set this property to null. You can change this property as needed if you want to rotate your encryption key; Your data will be unaffected. Encryption with customer-managed keys is not available for free search services, and is only available for paid services created on or after January 1, 2019. */ | ||
| encryptionKey?: SearchResourceEncryptionKey | null; | ||
| /** The type of similarity algorithm to be used when scoring and ranking the documents matching a search query. The similarity algorithm can only be defined at index creation time and cannot be modified on existing indexes. If null, the ClassicSimilarity algorithm is used. */ | ||
|
|
@@ -761,8 +762,8 @@ export interface CharFilter { | |
|
|
||
| /** Base type for normalizers. */ | ||
| export interface LexicalNormalizer { | ||
| /** Identifies the concrete type of the normalizer. */ | ||
| odatatype: string; | ||
| /** Polymorphic discriminator, which specifies the different types this object can be */ | ||
| odatatype: "#Microsoft.Azure.Search.CustomNormalizer"; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused about this. Why would a generic
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @xirzec Yeah. It was little confusing to me too. Let me explain with an example. For the following swagger: "Similarity": {
"discriminator": "@odata.type",
.........
}
"ClassicSimilarity": {
"x-ms-discriminator-value": "#Microsoft.Azure.Search.ClassicSimilarity",
.........
}
"BM25Similarity": {
"x-ms-discriminator-value": "#Microsoft.Azure.Search.BM25Similarity",
.........
}For the above swagger, the SDK will be generated as: export interface Similarity {
odatatype: "#Microsoft.Azure.Search.ClassicSimilarity" | "#Microsoft.Azure.Search.BM25Similarity";
.........
}
export type ClassicSimilarity = Similarity & {
odatatype: "#Microsoft.Azure.Search.ClassicSimilarity";
.........
};
export type BM25Similarity = Similarity & {
odatatype: "#Microsoft.Azure.Search.BM25Similarity";
.........
}In the above code, look at the Now, let us look into the "LexicalNormalizer": {
"discriminator": "@odata.type",
......
}
"CustomNormalizer": {
"x-ms-discriminator-value": "#Microsoft.Azure.Search.CustomNormalizer",
..........
}For the above swagger, the SDK looks like: export interface LexicalNormalizer {
odatatype: "#Microsoft.Azure.Search.CustomNormalizer";
.........
}
export type CustomNormalizer = LexicalNormalizer & {
odatatype: "#Microsoft.Azure.Search.CustomNormalizer";
.........
}In the above code the base class But, consider there is another normalizer in the swagger such as this: "SampleNormalizer": {
"x-ms-discriminator-value": "#Microsoft.Azure.Search.SampleNormalizer",
..........
}then the resulting SDK will look like: export interface LexicalNormalizer {
odatatype: "#Microsoft.Azure.Search.CustomNormalizer" | "#Microsoft.Azure.Search.SampleNormalizer";
.........
}
export type CustomNormalizer = LexicalNormalizer & {
odatatype: "#Microsoft.Azure.Search.CustomNormalizer";
.........
}
export type SampleNormalizer = LexicalNormalizer & {
odatatype: "#Microsoft.Azure.Search.SampleNormalizer";
.........
}The confusion is that we do not have more than one sub type of normalizer, it is looking a little odd. Am I making sense?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ohh! This does make sense and helps a lot. Thanks! 👍 |
||
| /** The name of the normalizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. It cannot end in '.microsoft' nor '.lucene', nor be named 'asciifolding', 'standard', 'lowercase', 'uppercase', or 'elision'. */ | ||
| name: string; | ||
| } | ||
|
|
@@ -1654,6 +1655,8 @@ export type PatternReplaceCharFilter = CharFilter & { | |
|
|
||
| /** Allows you to configure normalization for filterable, sortable, and facetable fields, which by default operate with strict matching. This is a user-defined configuration consisting of at least one or more filters, which modify the token that is stored. */ | ||
| export type CustomNormalizer = LexicalNormalizer & { | ||
| /** Polymorphic discriminator, which specifies the different types this object can be */ | ||
| odatatype: "#Microsoft.Azure.Search.CustomNormalizer"; | ||
| /** A list of token filters used to filter out or modify the input token. For example, you can specify a lowercase filter that converts all characters to lowercase. The filters are run in the order in which they are listed. */ | ||
| tokenFilters?: TokenFilterName[]; | ||
| /** A list of character filters used to prepare input text before it is processed. For instance, they can replace certain characters or symbols. The filters are run in the order in which they are listed. */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like having multiple optional parameters. This forces anyone who wants to pass
optionsto passundefinedtoapiVersionif they don't want to set it, which feels bad.Why can't
apiVersionlive onSearchIndexClientOptions?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I will change it for all the 3 clients in the next commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xirzec Updated in the latest commit