Skip to content

Commit 1bf98f0

Browse files
authored
Search Regeneration (Azure#34943)
Search Swagger Regeneration
1 parent 1865f1d commit 1bf98f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2309
-47
lines changed

sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/SearchAsyncClient.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,8 @@ private Mono<SearchPagedResponse> search(SearchRequest request, String continuat
857857
SearchPagedResponse page = new SearchPagedResponse(
858858
new SimpleResponse<>(response, getSearchResults(result, serializer)),
859859
createContinuationToken(result, serviceVersion), result.getFacets(), result.getCount(),
860-
result.getCoverage(), result.getAnswers());
860+
result.getCoverage(), result.getAnswers(), result.getSemanticPartialResponseReason(),
861+
result.getSemanticPartialResponseType());
861862
if (continuationToken == null) {
862863
firstPageResponseWrapper.setFirstPageResponse(page);
863864
}
@@ -1077,19 +1078,24 @@ static SearchRequest createSearchRequest(String searchText, SearchOptions option
10771078
static String createSearchRequestAnswers(SearchOptions searchOptions) {
10781079
QueryAnswerType answer = searchOptions.getAnswers();
10791080
Integer answersCount = searchOptions.getAnswersCount();
1081+
Double answerThreshold = searchOptions.getAnswerThreshold();
10801082

10811083
// No answer has been defined.
10821084
if (answer == null) {
10831085
return null;
10841086
}
10851087

1086-
// No count, just send the QueryAnswer.
1087-
if (answersCount == null) {
1088-
return answer.toString();
1089-
}
1088+
String answerString = answer.toString();
10901089

1091-
// Answer and count, format it as the service expects.
1092-
return answer + "|count-" + answersCount;
1090+
if (answersCount != null && answerThreshold != null) {
1091+
return answerString + "|count-" + answersCount + ",threshold-" + answerThreshold;
1092+
} else if (answersCount != null && answerThreshold == null) {
1093+
return answerString + "|count-" + answersCount;
1094+
} else if (answersCount == null && answerThreshold != null) {
1095+
return answerString + "|threshold-" + answerThreshold;
1096+
} else {
1097+
return answerString;
1098+
}
10931099
}
10941100

10951101
static String createSearchRequestCaptions(SearchOptions searchOptions) {

sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/SearchClient.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import com.azure.search.documents.util.SuggestPagedResponse;
4343

4444
import java.util.List;
45+
import java.util.Map;
4546
import java.util.function.Function;
4647
import java.util.stream.Collectors;
4748

@@ -618,7 +619,7 @@ public <T> Response<T> getDocumentWithResponse(String key, Class<T> modelClass,
618619
Context context) {
619620

620621
try {
621-
Response<Object> response = restClient.getDocuments()
622+
Response<Map<String, Object>> response = restClient.getDocuments()
622623
.getWithResponse(key, selectedFields, null, Utility.enableSyncRestProxy(context));
623624

624625
return new SimpleResponse<>(response, serializer.deserializeFromBytes(
@@ -778,7 +779,8 @@ private SearchPagedResponse search(SearchRequest request, String continuationTok
778779
SearchPagedResponse page = new SearchPagedResponse(
779780
new SimpleResponse<>(response, getSearchResults(result, serializer)),
780781
createContinuationToken(result, serviceVersion), result.getFacets(), result.getCount(),
781-
result.getCoverage(), result.getAnswers());
782+
result.getCoverage(), result.getAnswers(), result.getSemanticPartialResponseReason(),
783+
result.getSemanticPartialResponseType());
782784
if (continuationToken == null) {
783785
firstPageResponseWrapper.setFirstPageResponse(page);
784786
}

sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/DocumentsImpl.java

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,15 @@
3333
import com.azure.search.documents.models.AutocompleteMode;
3434
import com.azure.search.documents.models.AutocompleteResult;
3535
import com.azure.search.documents.models.IndexDocumentsResult;
36+
import com.azure.search.documents.models.QueryDebugMode;
3637
import com.azure.search.documents.models.QueryLanguage;
3738
import com.azure.search.documents.models.QuerySpellerType;
3839
import com.azure.search.documents.models.QueryType;
3940
import com.azure.search.documents.models.ScoringStatistics;
4041
import com.azure.search.documents.models.SearchMode;
42+
import com.azure.search.documents.models.SemanticErrorHandling;
4143
import java.util.List;
44+
import java.util.Map;
4245
import java.util.Objects;
4346
import java.util.UUID;
4447
import java.util.stream.Collectors;
@@ -113,6 +116,9 @@ Mono<Response<SearchDocumentsResult>> searchGet(
113116
@QueryParam(value = "scoringParameter", multipleQueryParams = true) List<String> scoringParameters,
114117
@QueryParam("scoringProfile") String scoringProfile,
115118
@QueryParam("semanticConfiguration") String semanticConfiguration,
119+
@QueryParam("semanticErrorHandling") SemanticErrorHandling semanticErrorHandling,
120+
@QueryParam("semanticMaxWaitInMilliseconds") Integer semanticMaxWaitInMilliseconds,
121+
@QueryParam("debug") QueryDebugMode debug,
116122
@QueryParam("searchFields") String searchFields,
117123
@QueryParam("queryLanguage") QueryLanguage queryLanguage,
118124
@QueryParam("speller") QuerySpellerType speller,
@@ -149,6 +155,9 @@ Response<SearchDocumentsResult> searchGetSync(
149155
@QueryParam(value = "scoringParameter", multipleQueryParams = true) List<String> scoringParameters,
150156
@QueryParam("scoringProfile") String scoringProfile,
151157
@QueryParam("semanticConfiguration") String semanticConfiguration,
158+
@QueryParam("semanticErrorHandling") SemanticErrorHandling semanticErrorHandling,
159+
@QueryParam("semanticMaxWaitInMilliseconds") Integer semanticMaxWaitInMilliseconds,
160+
@QueryParam("debug") QueryDebugMode debug,
152161
@QueryParam("searchFields") String searchFields,
153162
@QueryParam("queryLanguage") QueryLanguage queryLanguage,
154163
@QueryParam("speller") QuerySpellerType speller,
@@ -193,7 +202,7 @@ Response<SearchDocumentsResult> searchPostSync(
193202
@Get("/docs('{key}')")
194203
@ExpectedResponses({200})
195204
@UnexpectedResponseExceptionType(SearchErrorException.class)
196-
Mono<Response<Object>> get(
205+
Mono<Response<Map<String, Object>>> get(
197206
@HostParam("endpoint") String endpoint,
198207
@HostParam("indexName") String indexName,
199208
@PathParam("key") String key,
@@ -206,7 +215,7 @@ Mono<Response<Object>> get(
206215
@Get("/docs('{key}')")
207216
@ExpectedResponses({200})
208217
@UnexpectedResponseExceptionType(SearchErrorException.class)
209-
Response<Object> getSync(
218+
Response<Map<String, Object>> getSync(
210219
@HostParam("endpoint") String endpoint,
211220
@HostParam("indexName") String indexName,
212221
@PathParam("key") String key,
@@ -652,10 +661,11 @@ public SearchDocumentsResult searchPost(SearchRequest searchRequest, RequestOpti
652661
* @throws IllegalArgumentException thrown if parameters fail the validation.
653662
* @throws SearchErrorException thrown if the request is rejected by server.
654663
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
655-
* @return any object along with {@link Response} on successful completion of {@link Mono}.
664+
* @return a document retrieved via a document lookup operation along with {@link Response} on successful completion
665+
* of {@link Mono}.
656666
*/
657667
@ServiceMethod(returns = ReturnType.SINGLE)
658-
public Mono<Response<Object>> getWithResponseAsync(
668+
public Mono<Response<Map<String, Object>>> getWithResponseAsync(
659669
String key, List<String> selectedFields, RequestOptions requestOptions) {
660670
final String accept = "application/json; odata.metadata=none";
661671
UUID xMsClientRequestIdInternal = null;
@@ -693,10 +703,11 @@ public Mono<Response<Object>> getWithResponseAsync(
693703
* @throws IllegalArgumentException thrown if parameters fail the validation.
694704
* @throws SearchErrorException thrown if the request is rejected by server.
695705
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
696-
* @return any object along with {@link Response} on successful completion of {@link Mono}.
706+
* @return a document retrieved via a document lookup operation along with {@link Response} on successful completion
707+
* of {@link Mono}.
697708
*/
698709
@ServiceMethod(returns = ReturnType.SINGLE)
699-
public Mono<Response<Object>> getWithResponseAsync(
710+
public Mono<Response<Map<String, Object>>> getWithResponseAsync(
700711
String key, List<String> selectedFields, RequestOptions requestOptions, Context context) {
701712
final String accept = "application/json; odata.metadata=none";
702713
UUID xMsClientRequestIdInternal = null;
@@ -731,10 +742,10 @@ public Mono<Response<Object>> getWithResponseAsync(
731742
* @throws IllegalArgumentException thrown if parameters fail the validation.
732743
* @throws SearchErrorException thrown if the request is rejected by server.
733744
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
734-
* @return any object on successful completion of {@link Mono}.
745+
* @return a document retrieved via a document lookup operation on successful completion of {@link Mono}.
735746
*/
736747
@ServiceMethod(returns = ReturnType.SINGLE)
737-
public Mono<Object> getAsync(String key, List<String> selectedFields, RequestOptions requestOptions) {
748+
public Mono<Map<String, Object>> getAsync(String key, List<String> selectedFields, RequestOptions requestOptions) {
738749
return getWithResponseAsync(key, selectedFields, requestOptions)
739750
.flatMap(res -> Mono.justOrEmpty(res.getValue()));
740751
}
@@ -750,10 +761,10 @@ public Mono<Object> getAsync(String key, List<String> selectedFields, RequestOpt
750761
* @throws IllegalArgumentException thrown if parameters fail the validation.
751762
* @throws SearchErrorException thrown if the request is rejected by server.
752763
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
753-
* @return any object on successful completion of {@link Mono}.
764+
* @return a document retrieved via a document lookup operation on successful completion of {@link Mono}.
754765
*/
755766
@ServiceMethod(returns = ReturnType.SINGLE)
756-
public Mono<Object> getAsync(
767+
public Mono<Map<String, Object>> getAsync(
757768
String key, List<String> selectedFields, RequestOptions requestOptions, Context context) {
758769
return getWithResponseAsync(key, selectedFields, requestOptions, context)
759770
.flatMap(res -> Mono.justOrEmpty(res.getValue()));
@@ -770,10 +781,10 @@ public Mono<Object> getAsync(
770781
* @throws IllegalArgumentException thrown if parameters fail the validation.
771782
* @throws SearchErrorException thrown if the request is rejected by server.
772783
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
773-
* @return any object along with {@link Response}.
784+
* @return a document retrieved via a document lookup operation along with {@link Response}.
774785
*/
775786
@ServiceMethod(returns = ReturnType.SINGLE)
776-
public Response<Object> getWithResponse(
787+
public Response<Map<String, Object>> getWithResponse(
777788
String key, List<String> selectedFields, RequestOptions requestOptions, Context context) {
778789
final String accept = "application/json; odata.metadata=none";
779790
UUID xMsClientRequestIdInternal = null;
@@ -808,10 +819,10 @@ public Response<Object> getWithResponse(
808819
* @throws IllegalArgumentException thrown if parameters fail the validation.
809820
* @throws SearchErrorException thrown if the request is rejected by server.
810821
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
811-
* @return any object.
822+
* @return a document retrieved via a document lookup operation.
812823
*/
813824
@ServiceMethod(returns = ReturnType.SINGLE)
814-
public Object get(String key, List<String> selectedFields, RequestOptions requestOptions) {
825+
public Map<String, Object> get(String key, List<String> selectedFields, RequestOptions requestOptions) {
815826
return getWithResponse(key, selectedFields, requestOptions, Context.NONE).getValue();
816827
}
817828

sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/SearchResultConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static SearchResult map(com.azure.search.documents.implementation.models.
3232
SearchResultHelper.setCaptions(searchResult, obj.getCaptions());
3333
SearchResultHelper.setAdditionalProperties(searchResult, new SearchDocument(obj.getAdditionalProperties()));
3434
SearchResultHelper.setJsonSerializer(searchResult, (JsonSerializer) serializer);
35-
35+
SearchResultHelper.setDocumentDebugInfo(searchResult, obj.getDocumentDebugInfo());
3636
return searchResult;
3737
}
3838

sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/SearchResultHelper.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.azure.core.util.serializer.JsonSerializer;
77
import com.azure.search.documents.SearchDocument;
88
import com.azure.search.documents.models.CaptionResult;
9+
import com.azure.search.documents.models.DocumentDebugInfo;
910
import com.azure.search.documents.models.SearchResult;
1011

1112
import java.util.List;
@@ -28,6 +29,7 @@ public interface SearchResultAccessor {
2829
void setJsonSerializer(SearchResult searchResult, JsonSerializer jsonSerializer);
2930
void setRerankerScore(SearchResult searchResult, Double rerankerScore);
3031
void setCaptions(SearchResult searchResult, List<CaptionResult> captions);
32+
void setDocumentDebugInfo(SearchResult searchResult, List<DocumentDebugInfo> documentDebugInfo);
3133
}
3234

3335
/**
@@ -58,4 +60,8 @@ static void setRerankerScore(SearchResult searchResult, Double rerankerScore) {
5860
static void setCaptions(SearchResult searchResult, List<CaptionResult> captions) {
5961
accessor.setCaptions(searchResult, captions);
6062
}
63+
64+
static void setDocumentDebugInfo(SearchResult searchResult, List<DocumentDebugInfo> documentDebugInfo) {
65+
accessor.setDocumentDebugInfo(searchResult, documentDebugInfo);
66+
}
6167
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
//
4+
// Code generated by Microsoft (R) AutoRest Code Generator.
5+
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
6+
7+
package com.azure.search.documents.implementation.models;
8+
9+
import com.azure.core.util.ExpandableStringEnum;
10+
import java.util.Collection;
11+
12+
/** The way the field was used for the semantic enrichment process. */
13+
public final class QueryResultDocumentSemanticFieldState
14+
extends ExpandableStringEnum<QueryResultDocumentSemanticFieldState> {
15+
/** The field was fully used for semantic enrichment. */
16+
public static final QueryResultDocumentSemanticFieldState USED = fromString("used");
17+
18+
/** The field was not used for semantic enrichment. */
19+
public static final QueryResultDocumentSemanticFieldState UNUSED = fromString("unused");
20+
21+
/** The field was partially used for semantic enrichment. */
22+
public static final QueryResultDocumentSemanticFieldState PARTIAL = fromString("partial");
23+
24+
/**
25+
* Creates a new instance of QueryResultDocumentSemanticFieldState value.
26+
*
27+
* @deprecated Use the {@link #fromString(String)} factory method.
28+
*/
29+
@Deprecated
30+
public QueryResultDocumentSemanticFieldState() {}
31+
32+
/**
33+
* Creates or finds a QueryResultDocumentSemanticFieldState from its string representation.
34+
*
35+
* @param name a name to look for.
36+
* @return the corresponding QueryResultDocumentSemanticFieldState.
37+
*/
38+
public static QueryResultDocumentSemanticFieldState fromString(String name) {
39+
return fromString(name, QueryResultDocumentSemanticFieldState.class);
40+
}
41+
42+
/**
43+
* Gets known QueryResultDocumentSemanticFieldState values.
44+
*
45+
* @return known QueryResultDocumentSemanticFieldState values.
46+
*/
47+
public static Collection<QueryResultDocumentSemanticFieldState> values() {
48+
return values(QueryResultDocumentSemanticFieldState.class);
49+
}
50+
}

0 commit comments

Comments
 (0)