Skip to content

Commit 8ecb0eb

Browse files
authored
Semantic Search Code Changes (Azure#14857)
* Semantic Search Code Changes * Fix Linter * Fix Formatting * Marked fields of AnswerResult as required * Added Code Changes for Knowledge Store * Code Changes for AnswerResult
1 parent acaccac commit 8ecb0eb

File tree

15 files changed

+534
-29
lines changed

15 files changed

+534
-29
lines changed

sdk/search/search-documents/recordings/node/searchclient/recording_search_with_semantic_ranking.js

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/search/search-documents/recordings/node/searchclient/recording_search_with_speller.js

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/search/search-documents/review/search-documents.api.md

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ export interface AnalyzeResult {
3636
// @public
3737
export type AnalyzeTextOptions = OperationOptions & AnalyzeRequest;
3838

39+
// @public
40+
export interface AnswerResult {
41+
[property: string]: any;
42+
readonly highlights?: string | null;
43+
readonly key: string;
44+
readonly score: number;
45+
readonly text: string;
46+
}
47+
48+
// @public
49+
export type Answers = string;
50+
3951
// @public
4052
export type AsciiFoldingTokenFilter = BaseTokenFilter & {
4153
odatatype: "#Microsoft.Azure.Search.AsciiFoldingTokenFilter";
@@ -163,6 +175,13 @@ export type BM25Similarity = Similarity & {
163175
b?: number | null;
164176
};
165177

178+
// @public
179+
export interface CaptionResult {
180+
[property: string]: any;
181+
readonly highlights?: string | null;
182+
readonly text?: string;
183+
}
184+
166185
// @public
167186
export type CharFilter = MappingCharFilter | PatternReplaceCharFilter;
168187

@@ -782,6 +801,12 @@ export enum KnownAnalyzerNames {
782801
ZhHantMicrosoft = "zh-Hant.microsoft"
783802
}
784803

804+
// @public
805+
export const enum KnownAnswers {
806+
Extractive = "extractive",
807+
None = "none"
808+
}
809+
785810
// @public
786811
export const enum KnownBlobIndexerDataToExtract {
787812
AllMetadata = "allMetadata",
@@ -1044,6 +1069,12 @@ export const enum KnownOcrSkillLanguage {
10441069
ZhHant = "zh-Hant"
10451070
}
10461071

1072+
// @public
1073+
export const enum KnownQueryLanguage {
1074+
EnUs = "en-us",
1075+
None = "none"
1076+
}
1077+
10471078
// @public
10481079
export const enum KnownRegexFlags {
10491080
CanonEq = "CANON_EQ",
@@ -1085,6 +1116,12 @@ export const enum KnownSentimentSkillLanguage {
10851116
Tr = "tr"
10861117
}
10871118

1119+
// @public
1120+
export const enum KnownSpeller {
1121+
Lexicon = "lexicon",
1122+
None = "none"
1123+
}
1124+
10881125
// @public
10891126
export const enum KnownSplitSkillLanguage {
10901127
Da = "da",
@@ -1494,6 +1531,9 @@ export type PhoneticTokenFilter = BaseTokenFilter & {
14941531
replaceOriginalTokens?: boolean;
14951532
};
14961533

1534+
// @public
1535+
export type QueryLanguage = string;
1536+
14971537
// @public
14981538
export type QueryType = "simple" | "full" | "semantic";
14991539

@@ -1569,6 +1609,7 @@ export interface SearchDocumentsResult<T> extends SearchDocumentsResultBase {
15691609

15701610
// @public
15711611
export interface SearchDocumentsResultBase {
1612+
readonly answers?: AnswerResult[] | null;
15721613
readonly count?: number;
15731614
readonly coverage?: number;
15741615
readonly facets?: {
@@ -1709,6 +1750,44 @@ export interface SearchIndexerError {
17091750
readonly statusCode: number;
17101751
}
17111752

1753+
// @public
1754+
export interface SearchIndexerKnowledgeStore {
1755+
projections: SearchIndexerKnowledgeStoreProjection[];
1756+
storageConnectionString: string;
1757+
}
1758+
1759+
// @public
1760+
export type SearchIndexerKnowledgeStoreBlobProjectionSelector = SearchIndexerKnowledgeStoreProjectionSelector & {
1761+
storageContainer: string;
1762+
};
1763+
1764+
// @public
1765+
export type SearchIndexerKnowledgeStoreFileProjectionSelector = SearchIndexerKnowledgeStoreBlobProjectionSelector & {};
1766+
1767+
// @public
1768+
export type SearchIndexerKnowledgeStoreObjectProjectionSelector = SearchIndexerKnowledgeStoreBlobProjectionSelector & {};
1769+
1770+
// @public
1771+
export interface SearchIndexerKnowledgeStoreProjection {
1772+
files?: SearchIndexerKnowledgeStoreFileProjectionSelector[];
1773+
objects?: SearchIndexerKnowledgeStoreObjectProjectionSelector[];
1774+
tables?: SearchIndexerKnowledgeStoreTableProjectionSelector[];
1775+
}
1776+
1777+
// @public
1778+
export interface SearchIndexerKnowledgeStoreProjectionSelector {
1779+
generatedKeyName?: string;
1780+
inputs?: InputFieldMappingEntry[];
1781+
referenceKeyName?: string;
1782+
source?: string;
1783+
sourceContext?: string;
1784+
}
1785+
1786+
// @public
1787+
export type SearchIndexerKnowledgeStoreTableProjectionSelector = SearchIndexerKnowledgeStoreProjectionSelector & {
1788+
tableName: string;
1789+
};
1790+
17121791
// @public (undocumented)
17131792
export interface SearchIndexerLimits {
17141793
readonly maxDocumentContentCharactersToExtract?: number;
@@ -1725,6 +1804,7 @@ export interface SearchIndexerSkillset {
17251804
description?: string;
17261805
encryptionKey?: SearchResourceEncryptionKey | null;
17271806
etag?: string;
1807+
knowledgeStore?: SearchIndexerKnowledgeStore;
17281808
name: string;
17291809
skills: SearchIndexerSkill[];
17301810
}
@@ -1813,6 +1893,7 @@ export type SearchOptions<Fields> = OperationOptions & SearchRequestOptions<Fiel
18131893

18141894
// @public
18151895
export interface SearchRequest {
1896+
answers?: Answers;
18161897
facets?: string[];
18171898
filter?: string;
18181899
highlightFields?: string;
@@ -1821,6 +1902,7 @@ export interface SearchRequest {
18211902
includeTotalCount?: boolean;
18221903
minimumCoverage?: number;
18231904
orderBy?: string;
1905+
queryLanguage?: QueryLanguage;
18241906
queryType?: QueryType;
18251907
scoringParameters?: string[];
18261908
scoringProfile?: string;
@@ -1831,11 +1913,13 @@ export interface SearchRequest {
18311913
select?: string;
18321914
sessionId?: string;
18331915
skip?: number;
1916+
speller?: Speller;
18341917
top?: number;
18351918
}
18361919

18371920
// @public
18381921
export interface SearchRequestOptions<Fields> {
1922+
answers?: Answers;
18391923
facets?: string[];
18401924
filter?: string;
18411925
highlightFields?: string;
@@ -1844,6 +1928,7 @@ export interface SearchRequestOptions<Fields> {
18441928
includeTotalCount?: boolean;
18451929
minimumCoverage?: number;
18461930
orderBy?: string[];
1931+
queryLanguage?: QueryLanguage;
18471932
queryType?: QueryType;
18481933
scoringParameters?: string[];
18491934
scoringProfile?: string;
@@ -1853,6 +1938,7 @@ export interface SearchRequestOptions<Fields> {
18531938
select?: Fields[];
18541939
sessionId?: string;
18551940
skip?: number;
1941+
speller?: Speller;
18561942
top?: number;
18571943
}
18581944

@@ -1868,9 +1954,11 @@ export interface SearchResourceEncryptionKey {
18681954
// @public
18691955
export type SearchResult<T> = {
18701956
readonly score: number;
1957+
readonly rerankerScore?: number;
18711958
readonly highlights?: {
18721959
[k in keyof T]?: string[];
18731960
};
1961+
readonly captions?: CaptionResult[] | null;
18741962
document: T;
18751963
};
18761964

@@ -1902,7 +1990,7 @@ export interface ServiceCounters {
19021990
documentCounter: ResourceCounter;
19031991
indexCounter: ResourceCounter;
19041992
indexerCounter: ResourceCounter;
1905-
skillsetCounter: ResourceCounter;
1993+
skillsetCounter?: ResourceCounter;
19061994
storageSizeCounter: ResourceCounter;
19071995
synonymMapCounter: ResourceCounter;
19081996
}
@@ -1972,6 +2060,9 @@ export type SoftDeleteColumnDeletionDetectionPolicy = BaseDataDeletionDetectionP
19722060
softDeleteMarkerValue?: string;
19732061
};
19742062

2063+
// @public
2064+
export type Speller = string;
2065+
19752066
// @public
19762067
export type SplitSkill = BaseSearchIndexerSkill & {
19772068
odatatype: "#Microsoft.Skills.Text.SplitSkill";

sdk/search/search-documents/src/generated/data/models/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export interface SearchDocumentsResult {
4848
* The answers query results for the search operation; null if the answers query parameter was not specified or set to 'none'.
4949
* NOTE: This property will not be serialized. It can only be populated by the server.
5050
*/
51-
readonly answers?: { [propertyName: string]: AnswerResult[] } | null;
51+
readonly answers?: AnswerResult[] | null;
5252
/**
5353
* Continuation JSON payload returned when Azure Cognitive Search can't return all the requested results in a single Search response. You can use this JSON along with @odata.nextLink to formulate another POST Search request to get the next part of the search response.
5454
* NOTE: This property will not be serialized. It can only be populated by the server.
@@ -85,17 +85,17 @@ export interface AnswerResult {
8585
* The score value represents how relevant the answer is to the the query relative to other answers returned for the query.
8686
* NOTE: This property will not be serialized. It can only be populated by the server.
8787
*/
88-
readonly score?: number;
88+
readonly score: number;
8989
/**
9090
* The key of the document the answer was extracted from.
9191
* NOTE: This property will not be serialized. It can only be populated by the server.
9292
*/
93-
readonly key?: string;
93+
readonly key: string;
9494
/**
9595
* The text passage extracted from the document contents as the answer.
9696
* NOTE: This property will not be serialized. It can only be populated by the server.
9797
*/
98-
readonly text?: string;
98+
readonly text: string;
9999
/**
100100
* Same text passage as in the Text property with highlighted text phrases most relevant to the query.
101101
* NOTE: This property will not be serialized. It can only be populated by the server.
@@ -174,7 +174,7 @@ export interface SearchResult {
174174
* Captions are the most representative passages from the document relatively to the search query. They are often used as document summary. Captions are only returned for queries of type 'semantic'.
175175
* NOTE: This property will not be serialized. It can only be populated by the server.
176176
*/
177-
readonly captions?: { [propertyName: string]: CaptionResult[] } | null;
177+
readonly captions?: CaptionResult[] | null;
178178
}
179179

180180
/** Captions are the most representative passages from the document relatively to the search query. They are often used as document summary. Captions are only returned for queries of type 'semantic'.. */

sdk/search/search-documents/src/generated/data/models/mappers.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,11 @@ export const SearchDocumentsResult: coreHttp.CompositeMapper = {
8282
readOnly: true,
8383
nullable: true,
8484
type: {
85-
name: "Dictionary",
86-
value: {
85+
name: "Sequence",
86+
element: {
8787
type: {
88-
name: "Sequence",
89-
element: {
90-
type: { name: "Composite", className: "AnswerResult" }
91-
}
88+
name: "Composite",
89+
className: "AnswerResult"
9290
}
9391
}
9492
}
@@ -150,20 +148,23 @@ export const AnswerResult: coreHttp.CompositeMapper = {
150148
modelProperties: {
151149
score: {
152150
serializedName: "score",
151+
required: true,
153152
readOnly: true,
154153
type: {
155154
name: "Number"
156155
}
157156
},
158157
key: {
159158
serializedName: "key",
159+
required: true,
160160
readOnly: true,
161161
type: {
162162
name: "String"
163163
}
164164
},
165165
text: {
166166
serializedName: "text",
167+
required: true,
167168
readOnly: true,
168169
type: {
169170
name: "String"
@@ -372,13 +373,11 @@ export const SearchResult: coreHttp.CompositeMapper = {
372373
readOnly: true,
373374
nullable: true,
374375
type: {
375-
name: "Dictionary",
376-
value: {
376+
name: "Sequence",
377+
element: {
377378
type: {
378-
name: "Sequence",
379-
element: {
380-
type: { name: "Composite", className: "CaptionResult" }
381-
}
379+
name: "Composite",
380+
className: "CaptionResult"
382381
}
383382
}
384383
}

0 commit comments

Comments
 (0)