From 1bf98f0a19d1a4e99e846fbc19d84487cf13800d Mon Sep 17 00:00:00 2001 From: Jair Myree <67484440+jairmyree@users.noreply.github.com> Date: Mon, 26 Jun 2023 10:49:34 -0700 Subject: [PATCH] Search Regeneration (#34943) Search Swagger Regeneration --- .../search/documents/SearchAsyncClient.java | 20 +- .../azure/search/documents/SearchClient.java | 6 +- .../implementation/DocumentsImpl.java | 39 ++-- .../converters/SearchResultConverter.java | 2 +- .../converters/SearchResultHelper.java | 6 + ...QueryResultDocumentSemanticFieldState.java | 50 +++++ .../models/SearchDocumentsResult.java | 46 +++++ .../implementation/models/SearchOptions.java | 105 +++++++++- .../implementation/models/SearchRequest.java | 136 ++++++++++++- .../implementation/models/SearchResult.java | 22 +++ .../implementation/models/Vector.java | 138 +++++++++++++ .../util/SearchPagedResponseAccessHelper.java | 37 ++++ .../models/EntityRecognitionSkillV1.java | 2 +- .../models/SentimentSkillV1.java | 2 +- .../EntityRecognitionSkillLanguage.java | 2 +- .../indexes/models/HnswParameters.java | 184 ++++++++++++++++++ ...nswVectorSearchAlgorithmConfiguration.java | 127 ++++++++++++ .../documents/indexes/models/SearchField.java | 63 ++++++ .../indexes/models/SearchFieldDataType.java | 6 + .../documents/indexes/models/SearchIndex.java | 30 +++ .../indexes/models/SearchIndexStatistics.java | 19 ++ .../indexes/models/SearchIndexerCache.java | 37 ++++ .../models/SearchIndexerKnowledgeStore.java | 43 +++- .../indexes/models/SearchServiceCounters.java | 32 +++ .../indexes/models/SemanticSettings.java | 33 +++- .../models/SentimentSkillLanguage.java | 2 +- .../indexes/models/VectorSearch.java | 88 +++++++++ .../VectorSearchAlgorithmConfiguration.java | 89 +++++++++ .../models/VectorSearchAlgorithmMetric.java | 49 +++++ .../documents/indexes/models/WebApiSkill.java | 80 ++++++++ .../documents/models/DocumentDebugInfo.java | 69 +++++++ .../documents/models/QueryAnswerType.java | 4 +- .../documents/models/QueryDebugMode.java | 46 +++++ .../QueryResultDocumentRerankerInput.java | 106 ++++++++++ .../QueryResultDocumentSemanticField.java | 91 +++++++++ .../documents/models/SearchOptions.java | 129 +++++++++++- .../search/documents/models/SearchResult.java | 29 +++ .../documents/models/SemanticDebugInfo.java | 130 +++++++++++++ .../models/SemanticErrorHandling.java | 52 +++++ .../models/SemanticPartialResponseReason.java | 52 +++++ .../models/SemanticPartialResponseType.java | 49 +++++ .../documents/util/SearchPagedFlux.java | 30 +++ .../documents/util/SearchPagedIterable.java | 20 ++ .../documents/util/SearchPagedResponse.java | 45 ++++- .../azure-search-documents/swagger/README.md | 9 +- 45 files changed, 2309 insertions(+), 47 deletions(-) create mode 100644 sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/QueryResultDocumentSemanticFieldState.java create mode 100644 sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/Vector.java create mode 100644 sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/HnswParameters.java create mode 100644 sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/HnswVectorSearchAlgorithmConfiguration.java create mode 100644 sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/VectorSearch.java create mode 100644 sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/VectorSearchAlgorithmConfiguration.java create mode 100644 sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/VectorSearchAlgorithmMetric.java create mode 100644 sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/DocumentDebugInfo.java create mode 100644 sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/QueryDebugMode.java create mode 100644 sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/QueryResultDocumentRerankerInput.java create mode 100644 sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/QueryResultDocumentSemanticField.java create mode 100644 sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SemanticDebugInfo.java create mode 100644 sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SemanticErrorHandling.java create mode 100644 sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SemanticPartialResponseReason.java create mode 100644 sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SemanticPartialResponseType.java diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/SearchAsyncClient.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/SearchAsyncClient.java index 71b06dfe0b7d6..007364cdb196a 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/SearchAsyncClient.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/SearchAsyncClient.java @@ -857,7 +857,8 @@ private Mono search(SearchRequest request, String continuat SearchPagedResponse page = new SearchPagedResponse( new SimpleResponse<>(response, getSearchResults(result, serializer)), createContinuationToken(result, serviceVersion), result.getFacets(), result.getCount(), - result.getCoverage(), result.getAnswers()); + result.getCoverage(), result.getAnswers(), result.getSemanticPartialResponseReason(), + result.getSemanticPartialResponseType()); if (continuationToken == null) { firstPageResponseWrapper.setFirstPageResponse(page); } @@ -1077,19 +1078,24 @@ static SearchRequest createSearchRequest(String searchText, SearchOptions option static String createSearchRequestAnswers(SearchOptions searchOptions) { QueryAnswerType answer = searchOptions.getAnswers(); Integer answersCount = searchOptions.getAnswersCount(); + Double answerThreshold = searchOptions.getAnswerThreshold(); // No answer has been defined. if (answer == null) { return null; } - // No count, just send the QueryAnswer. - if (answersCount == null) { - return answer.toString(); - } + String answerString = answer.toString(); - // Answer and count, format it as the service expects. - return answer + "|count-" + answersCount; + if (answersCount != null && answerThreshold != null) { + return answerString + "|count-" + answersCount + ",threshold-" + answerThreshold; + } else if (answersCount != null && answerThreshold == null) { + return answerString + "|count-" + answersCount; + } else if (answersCount == null && answerThreshold != null) { + return answerString + "|threshold-" + answerThreshold; + } else { + return answerString; + } } static String createSearchRequestCaptions(SearchOptions searchOptions) { diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/SearchClient.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/SearchClient.java index 4da2b57cee111..4c12bb22fe461 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/SearchClient.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/SearchClient.java @@ -42,6 +42,7 @@ import com.azure.search.documents.util.SuggestPagedResponse; import java.util.List; +import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; @@ -618,7 +619,7 @@ public Response getDocumentWithResponse(String key, Class modelClass, Context context) { try { - Response response = restClient.getDocuments() + Response> response = restClient.getDocuments() .getWithResponse(key, selectedFields, null, Utility.enableSyncRestProxy(context)); return new SimpleResponse<>(response, serializer.deserializeFromBytes( @@ -778,7 +779,8 @@ private SearchPagedResponse search(SearchRequest request, String continuationTok SearchPagedResponse page = new SearchPagedResponse( new SimpleResponse<>(response, getSearchResults(result, serializer)), createContinuationToken(result, serviceVersion), result.getFacets(), result.getCount(), - result.getCoverage(), result.getAnswers()); + result.getCoverage(), result.getAnswers(), result.getSemanticPartialResponseReason(), + result.getSemanticPartialResponseType()); if (continuationToken == null) { firstPageResponseWrapper.setFirstPageResponse(page); } diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/DocumentsImpl.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/DocumentsImpl.java index 3866f7e1e3b59..f56ef534d7836 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/DocumentsImpl.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/DocumentsImpl.java @@ -33,12 +33,15 @@ import com.azure.search.documents.models.AutocompleteMode; import com.azure.search.documents.models.AutocompleteResult; import com.azure.search.documents.models.IndexDocumentsResult; +import com.azure.search.documents.models.QueryDebugMode; import com.azure.search.documents.models.QueryLanguage; import com.azure.search.documents.models.QuerySpellerType; import com.azure.search.documents.models.QueryType; import com.azure.search.documents.models.ScoringStatistics; import com.azure.search.documents.models.SearchMode; +import com.azure.search.documents.models.SemanticErrorHandling; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.UUID; import java.util.stream.Collectors; @@ -113,6 +116,9 @@ Mono> searchGet( @QueryParam(value = "scoringParameter", multipleQueryParams = true) List scoringParameters, @QueryParam("scoringProfile") String scoringProfile, @QueryParam("semanticConfiguration") String semanticConfiguration, + @QueryParam("semanticErrorHandling") SemanticErrorHandling semanticErrorHandling, + @QueryParam("semanticMaxWaitInMilliseconds") Integer semanticMaxWaitInMilliseconds, + @QueryParam("debug") QueryDebugMode debug, @QueryParam("searchFields") String searchFields, @QueryParam("queryLanguage") QueryLanguage queryLanguage, @QueryParam("speller") QuerySpellerType speller, @@ -149,6 +155,9 @@ Response searchGetSync( @QueryParam(value = "scoringParameter", multipleQueryParams = true) List scoringParameters, @QueryParam("scoringProfile") String scoringProfile, @QueryParam("semanticConfiguration") String semanticConfiguration, + @QueryParam("semanticErrorHandling") SemanticErrorHandling semanticErrorHandling, + @QueryParam("semanticMaxWaitInMilliseconds") Integer semanticMaxWaitInMilliseconds, + @QueryParam("debug") QueryDebugMode debug, @QueryParam("searchFields") String searchFields, @QueryParam("queryLanguage") QueryLanguage queryLanguage, @QueryParam("speller") QuerySpellerType speller, @@ -193,7 +202,7 @@ Response searchPostSync( @Get("/docs('{key}')") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(SearchErrorException.class) - Mono> get( + Mono>> get( @HostParam("endpoint") String endpoint, @HostParam("indexName") String indexName, @PathParam("key") String key, @@ -206,7 +215,7 @@ Mono> get( @Get("/docs('{key}')") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(SearchErrorException.class) - Response getSync( + Response> getSync( @HostParam("endpoint") String endpoint, @HostParam("indexName") String indexName, @PathParam("key") String key, @@ -652,10 +661,11 @@ public SearchDocumentsResult searchPost(SearchRequest searchRequest, RequestOpti * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws SearchErrorException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return any object along with {@link Response} on successful completion of {@link Mono}. + * @return a document retrieved via a document lookup operation along with {@link Response} on successful completion + * of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getWithResponseAsync( + public Mono>> getWithResponseAsync( String key, List selectedFields, RequestOptions requestOptions) { final String accept = "application/json; odata.metadata=none"; UUID xMsClientRequestIdInternal = null; @@ -693,10 +703,11 @@ public Mono> getWithResponseAsync( * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws SearchErrorException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return any object along with {@link Response} on successful completion of {@link Mono}. + * @return a document retrieved via a document lookup operation along with {@link Response} on successful completion + * of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getWithResponseAsync( + public Mono>> getWithResponseAsync( String key, List selectedFields, RequestOptions requestOptions, Context context) { final String accept = "application/json; odata.metadata=none"; UUID xMsClientRequestIdInternal = null; @@ -731,10 +742,10 @@ public Mono> getWithResponseAsync( * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws SearchErrorException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return any object on successful completion of {@link Mono}. + * @return a document retrieved via a document lookup operation on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getAsync(String key, List selectedFields, RequestOptions requestOptions) { + public Mono> getAsync(String key, List selectedFields, RequestOptions requestOptions) { return getWithResponseAsync(key, selectedFields, requestOptions) .flatMap(res -> Mono.justOrEmpty(res.getValue())); } @@ -750,10 +761,10 @@ public Mono getAsync(String key, List selectedFields, RequestOpt * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws SearchErrorException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return any object on successful completion of {@link Mono}. + * @return a document retrieved via a document lookup operation on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getAsync( + public Mono> getAsync( String key, List selectedFields, RequestOptions requestOptions, Context context) { return getWithResponseAsync(key, selectedFields, requestOptions, context) .flatMap(res -> Mono.justOrEmpty(res.getValue())); @@ -770,10 +781,10 @@ public Mono getAsync( * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws SearchErrorException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return any object along with {@link Response}. + * @return a document retrieved via a document lookup operation along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getWithResponse( + public Response> getWithResponse( String key, List selectedFields, RequestOptions requestOptions, Context context) { final String accept = "application/json; odata.metadata=none"; UUID xMsClientRequestIdInternal = null; @@ -808,10 +819,10 @@ public Response getWithResponse( * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws SearchErrorException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return any object. + * @return a document retrieved via a document lookup operation. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Object get(String key, List selectedFields, RequestOptions requestOptions) { + public Map get(String key, List selectedFields, RequestOptions requestOptions) { return getWithResponse(key, selectedFields, requestOptions, Context.NONE).getValue(); } diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/SearchResultConverter.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/SearchResultConverter.java index 4ac18dcee530d..da9ddd53a095b 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/SearchResultConverter.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/SearchResultConverter.java @@ -32,7 +32,7 @@ public static SearchResult map(com.azure.search.documents.implementation.models. SearchResultHelper.setCaptions(searchResult, obj.getCaptions()); SearchResultHelper.setAdditionalProperties(searchResult, new SearchDocument(obj.getAdditionalProperties())); SearchResultHelper.setJsonSerializer(searchResult, (JsonSerializer) serializer); - + SearchResultHelper.setDocumentDebugInfo(searchResult, obj.getDocumentDebugInfo()); return searchResult; } diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/SearchResultHelper.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/SearchResultHelper.java index 65a8df46c1548..328ddb886554a 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/SearchResultHelper.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/SearchResultHelper.java @@ -6,6 +6,7 @@ import com.azure.core.util.serializer.JsonSerializer; import com.azure.search.documents.SearchDocument; import com.azure.search.documents.models.CaptionResult; +import com.azure.search.documents.models.DocumentDebugInfo; import com.azure.search.documents.models.SearchResult; import java.util.List; @@ -28,6 +29,7 @@ public interface SearchResultAccessor { void setJsonSerializer(SearchResult searchResult, JsonSerializer jsonSerializer); void setRerankerScore(SearchResult searchResult, Double rerankerScore); void setCaptions(SearchResult searchResult, List captions); + void setDocumentDebugInfo(SearchResult searchResult, List documentDebugInfo); } /** @@ -58,4 +60,8 @@ static void setRerankerScore(SearchResult searchResult, Double rerankerScore) { static void setCaptions(SearchResult searchResult, List captions) { accessor.setCaptions(searchResult, captions); } + + static void setDocumentDebugInfo(SearchResult searchResult, List documentDebugInfo) { + accessor.setDocumentDebugInfo(searchResult, documentDebugInfo); + } } diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/QueryResultDocumentSemanticFieldState.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/QueryResultDocumentSemanticFieldState.java new file mode 100644 index 0000000000000..b7ce047b505d8 --- /dev/null +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/QueryResultDocumentSemanticFieldState.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package com.azure.search.documents.implementation.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** The way the field was used for the semantic enrichment process. */ +public final class QueryResultDocumentSemanticFieldState + extends ExpandableStringEnum { + /** The field was fully used for semantic enrichment. */ + public static final QueryResultDocumentSemanticFieldState USED = fromString("used"); + + /** The field was not used for semantic enrichment. */ + public static final QueryResultDocumentSemanticFieldState UNUSED = fromString("unused"); + + /** The field was partially used for semantic enrichment. */ + public static final QueryResultDocumentSemanticFieldState PARTIAL = fromString("partial"); + + /** + * Creates a new instance of QueryResultDocumentSemanticFieldState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public QueryResultDocumentSemanticFieldState() {} + + /** + * Creates or finds a QueryResultDocumentSemanticFieldState from its string representation. + * + * @param name a name to look for. + * @return the corresponding QueryResultDocumentSemanticFieldState. + */ + public static QueryResultDocumentSemanticFieldState fromString(String name) { + return fromString(name, QueryResultDocumentSemanticFieldState.class); + } + + /** + * Gets known QueryResultDocumentSemanticFieldState values. + * + * @return known QueryResultDocumentSemanticFieldState values. + */ + public static Collection values() { + return values(QueryResultDocumentSemanticFieldState.class); + } +} diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/SearchDocumentsResult.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/SearchDocumentsResult.java index da1e0550cc6cf..184f6fb291391 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/SearchDocumentsResult.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/SearchDocumentsResult.java @@ -13,10 +13,13 @@ import com.azure.json.JsonWriter; import com.azure.search.documents.models.AnswerResult; import com.azure.search.documents.models.FacetResult; +import com.azure.search.documents.models.SemanticPartialResponseReason; +import com.azure.search.documents.models.SemanticPartialResponseType; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; /** Response containing search results from an index. */ @Immutable @@ -54,6 +57,16 @@ public final class SearchDocumentsResult implements JsonSerializable writer.writeArray(element, (writer1, element1) -> writer1.writeJson(element1))); jsonWriter.writeArrayField("@search.answers", this.answers, (writer, element) -> writer.writeJson(element)); jsonWriter.writeJsonField("@search.nextPageParameters", this.nextPageParameters); + jsonWriter.writeStringField( + "@search.semanticPartialResponseReason", Objects.toString(this.semanticPartialResponseReason, null)); + jsonWriter.writeStringField( + "@search.semanticPartialResponseType", Objects.toString(this.semanticPartialResponseType, null)); jsonWriter.writeStringField("@odata.nextLink", this.nextLink); return jsonWriter.writeEndObject(); } @@ -184,6 +221,8 @@ public static SearchDocumentsResult fromJson(JsonReader jsonReader) throws IOExc Map> facets = null; List answers = null; SearchRequest nextPageParameters = null; + SemanticPartialResponseReason semanticPartialResponseReason = null; + SemanticPartialResponseType semanticPartialResponseType = null; String nextLink = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); @@ -204,6 +243,11 @@ public static SearchDocumentsResult fromJson(JsonReader jsonReader) throws IOExc answers = reader.readArray(reader1 -> AnswerResult.fromJson(reader1)); } else if ("@search.nextPageParameters".equals(fieldName)) { nextPageParameters = SearchRequest.fromJson(reader); + } else if ("@search.semanticPartialResponseReason".equals(fieldName)) { + semanticPartialResponseReason = + SemanticPartialResponseReason.fromString(reader.getString()); + } else if ("@search.semanticPartialResponseType".equals(fieldName)) { + semanticPartialResponseType = SemanticPartialResponseType.fromString(reader.getString()); } else if ("@odata.nextLink".equals(fieldName)) { nextLink = reader.getString(); } else { @@ -217,6 +261,8 @@ public static SearchDocumentsResult fromJson(JsonReader jsonReader) throws IOExc deserializedSearchDocumentsResult.facets = facets; deserializedSearchDocumentsResult.answers = answers; deserializedSearchDocumentsResult.nextPageParameters = nextPageParameters; + deserializedSearchDocumentsResult.semanticPartialResponseReason = semanticPartialResponseReason; + deserializedSearchDocumentsResult.semanticPartialResponseType = semanticPartialResponseType; deserializedSearchDocumentsResult.nextLink = nextLink; return deserializedSearchDocumentsResult; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/SearchOptions.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/SearchOptions.java index b06f05576ce20..442479e5bf1a4 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/SearchOptions.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/SearchOptions.java @@ -10,11 +10,13 @@ import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; import com.azure.json.JsonWriter; +import com.azure.search.documents.models.QueryDebugMode; import com.azure.search.documents.models.QueryLanguage; import com.azure.search.documents.models.QuerySpellerType; import com.azure.search.documents.models.QueryType; import com.azure.search.documents.models.ScoringStatistics; import com.azure.search.documents.models.SearchMode; +import com.azure.search.documents.models.SemanticErrorHandling; import java.io.IOException; import java.util.List; import java.util.Objects; @@ -95,6 +97,22 @@ public final class SearchOptions implements JsonSerializable { */ private String semanticConfiguration; + /* + * Allows the user to choose whether a semantic call should fail completely, or to return partial results. + */ + private SemanticErrorHandling semanticErrorHandling; + + /* + * Allows the user to set an upper bound on the amount of time it takes for semantic enrichment to finish + * processing before the request fails. + */ + private Integer semanticMaxWaitInMilliseconds; + + /* + * Enables a debugging tool that can be used to further explore your search results. + */ + private QueryDebugMode debug; + /* * The list of field names to which to scope the full-text search. When using fielded search * (fieldName:searchExpression) in a full Lucene query, the field names of each fielded search expression take @@ -116,7 +134,9 @@ public final class SearchOptions implements JsonSerializable { * This parameter is only valid if the query type is 'semantic'. If set, the query returns answers extracted from * key passages in the highest ranked documents. The number of answers returned can be configured by appending the * pipe character '|' followed by the 'count-' option after the answers parameter value, such as - * 'extractive|count-3'. Default count is 1. + * 'extractive|count-3'. Default count is 1. The confidence threshold can be configured by appending the pipe + * character '|' followed by the 'threshold-' option after the answers parameter value, such + * as 'extractive|threshold-0.9'. Default threshold is 0.7. */ private String answers; @@ -450,6 +470,70 @@ public SearchOptions setSemanticConfiguration(String semanticConfiguration) { return this; } + /** + * Get the semanticErrorHandling property: Allows the user to choose whether a semantic call should fail completely, + * or to return partial results. + * + * @return the semanticErrorHandling value. + */ + public SemanticErrorHandling getSemanticErrorHandling() { + return this.semanticErrorHandling; + } + + /** + * Set the semanticErrorHandling property: Allows the user to choose whether a semantic call should fail completely, + * or to return partial results. + * + * @param semanticErrorHandling the semanticErrorHandling value to set. + * @return the SearchOptions object itself. + */ + public SearchOptions setSemanticErrorHandling(SemanticErrorHandling semanticErrorHandling) { + this.semanticErrorHandling = semanticErrorHandling; + return this; + } + + /** + * Get the semanticMaxWaitInMilliseconds property: Allows the user to set an upper bound on the amount of time it + * takes for semantic enrichment to finish processing before the request fails. + * + * @return the semanticMaxWaitInMilliseconds value. + */ + public Integer getSemanticMaxWaitInMilliseconds() { + return this.semanticMaxWaitInMilliseconds; + } + + /** + * Set the semanticMaxWaitInMilliseconds property: Allows the user to set an upper bound on the amount of time it + * takes for semantic enrichment to finish processing before the request fails. + * + * @param semanticMaxWaitInMilliseconds the semanticMaxWaitInMilliseconds value to set. + * @return the SearchOptions object itself. + */ + public SearchOptions setSemanticMaxWaitInMilliseconds(Integer semanticMaxWaitInMilliseconds) { + this.semanticMaxWaitInMilliseconds = semanticMaxWaitInMilliseconds; + return this; + } + + /** + * Get the debug property: Enables a debugging tool that can be used to further explore your search results. + * + * @return the debug value. + */ + public QueryDebugMode getDebug() { + return this.debug; + } + + /** + * Set the debug property: Enables a debugging tool that can be used to further explore your search results. + * + * @param debug the debug value to set. + * @return the SearchOptions object itself. + */ + public SearchOptions setDebug(QueryDebugMode debug) { + this.debug = debug; + return this; + } + /** * Get the searchFields property: The list of field names to which to scope the full-text search. When using fielded * search (fieldName:searchExpression) in a full Lucene query, the field names of each fielded search expression @@ -518,7 +602,9 @@ public SearchOptions setSpeller(QuerySpellerType speller) { * Get the answers property: This parameter is only valid if the query type is 'semantic'. If set, the query returns * answers extracted from key passages in the highest ranked documents. The number of answers returned can be * configured by appending the pipe character '|' followed by the 'count-<number of answers>' option after the - * answers parameter value, such as 'extractive|count-3'. Default count is 1. + * answers parameter value, such as 'extractive|count-3'. Default count is 1. The confidence threshold can be + * configured by appending the pipe character '|' followed by the 'threshold-<confidence threshold>' option + * after the answers parameter value, such as 'extractive|threshold-0.9'. Default threshold is 0.7. * * @return the answers value. */ @@ -530,7 +616,9 @@ public String getAnswers() { * Set the answers property: This parameter is only valid if the query type is 'semantic'. If set, the query returns * answers extracted from key passages in the highest ranked documents. The number of answers returned can be * configured by appending the pipe character '|' followed by the 'count-<number of answers>' option after the - * answers parameter value, such as 'extractive|count-3'. Default count is 1. + * answers parameter value, such as 'extractive|count-3'. Default count is 1. The confidence threshold can be + * configured by appending the pipe character '|' followed by the 'threshold-<confidence threshold>' option + * after the answers parameter value, such as 'extractive|threshold-0.9'. Default threshold is 0.7. * * @param answers the answers value to set. * @return the SearchOptions object itself. @@ -745,6 +833,9 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { "ScoringParameters", this.scoringParameters, (writer, element) -> writer.writeString(element)); jsonWriter.writeStringField("scoringProfile", this.scoringProfile); jsonWriter.writeStringField("semanticConfiguration", this.semanticConfiguration); + jsonWriter.writeStringField("semanticErrorHandling", Objects.toString(this.semanticErrorHandling, null)); + jsonWriter.writeNumberField("semanticMaxWaitInMilliseconds", this.semanticMaxWaitInMilliseconds); + jsonWriter.writeStringField("debug", Objects.toString(this.debug, null)); jsonWriter.writeArrayField("searchFields", this.searchFields, (writer, element) -> writer.writeString(element)); jsonWriter.writeStringField("queryLanguage", Objects.toString(this.queryLanguage, null)); jsonWriter.writeStringField("speller", Objects.toString(this.speller, null)); @@ -804,6 +895,14 @@ public static SearchOptions fromJson(JsonReader jsonReader) throws IOException { deserializedSearchOptions.scoringProfile = reader.getString(); } else if ("semanticConfiguration".equals(fieldName)) { deserializedSearchOptions.semanticConfiguration = reader.getString(); + } else if ("semanticErrorHandling".equals(fieldName)) { + deserializedSearchOptions.semanticErrorHandling = + SemanticErrorHandling.fromString(reader.getString()); + } else if ("semanticMaxWaitInMilliseconds".equals(fieldName)) { + deserializedSearchOptions.semanticMaxWaitInMilliseconds = + reader.getNullable(JsonReader::getInt); + } else if ("debug".equals(fieldName)) { + deserializedSearchOptions.debug = QueryDebugMode.fromString(reader.getString()); } else if ("searchFields".equals(fieldName)) { List searchFields = reader.readArray(reader1 -> reader1.getString()); deserializedSearchOptions.searchFields = searchFields; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/SearchRequest.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/SearchRequest.java index b3f35b1bec50a..ed7eb73a6866a 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/SearchRequest.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/SearchRequest.java @@ -11,11 +11,13 @@ import com.azure.json.JsonSerializable; import com.azure.json.JsonToken; import com.azure.json.JsonWriter; +import com.azure.search.documents.models.QueryDebugMode; import com.azure.search.documents.models.QueryLanguage; import com.azure.search.documents.models.QuerySpellerType; import com.azure.search.documents.models.QueryType; import com.azure.search.documents.models.ScoringStatistics; import com.azure.search.documents.models.SearchMode; +import com.azure.search.documents.models.SemanticErrorHandling; import java.io.IOException; import java.util.List; import java.util.Objects; @@ -112,6 +114,23 @@ public final class SearchRequest implements JsonSerializable { */ private String semanticConfiguration; + /* + * Allows the user to choose whether a semantic call should fail completely (default / current behavior), or to + * return partial results. + */ + private SemanticErrorHandling semanticErrorHandling; + + /* + * Allows the user to set an upper bound on the amount of time it takes for semantic enrichment to finish + * processing before the request fails. + */ + private Integer semanticMaxWaitInMilliseconds; + + /* + * Enables a debugging tool that can be used to further explore your Semantic search results. + */ + private QueryDebugMode debug; + /* * A full-text search query expression; Use "*" or omit this parameter to match all documents. */ @@ -144,7 +163,9 @@ public final class SearchRequest implements JsonSerializable { * This parameter is only valid if the query type is 'semantic'. If set, the query returns answers extracted from * key passages in the highest ranked documents. The number of answers returned can be configured by appending the * pipe character '|' followed by the 'count-' option after the answers parameter value, such as - * 'extractive|count-3'. Default count is 1. + * 'extractive|count-3'. Default count is 1. The confidence threshold can be configured by appending the pipe + * character '|' followed by the 'threshold-' option after the answers parameter value, such + * as 'extractive|threshold-0.9'. Default threshold is 0.7. */ private String answers; @@ -181,6 +202,11 @@ public final class SearchRequest implements JsonSerializable { */ private String semanticFields; + /* + * The query parameters for vector and hybrid search queries. + */ + private Vector vector; + /** Creates an instance of SearchRequest class. */ public SearchRequest() {} @@ -512,6 +538,72 @@ public SearchRequest setSemanticConfiguration(String semanticConfiguration) { return this; } + /** + * Get the semanticErrorHandling property: Allows the user to choose whether a semantic call should fail completely + * (default / current behavior), or to return partial results. + * + * @return the semanticErrorHandling value. + */ + public SemanticErrorHandling getSemanticErrorHandling() { + return this.semanticErrorHandling; + } + + /** + * Set the semanticErrorHandling property: Allows the user to choose whether a semantic call should fail completely + * (default / current behavior), or to return partial results. + * + * @param semanticErrorHandling the semanticErrorHandling value to set. + * @return the SearchRequest object itself. + */ + public SearchRequest setSemanticErrorHandling(SemanticErrorHandling semanticErrorHandling) { + this.semanticErrorHandling = semanticErrorHandling; + return this; + } + + /** + * Get the semanticMaxWaitInMilliseconds property: Allows the user to set an upper bound on the amount of time it + * takes for semantic enrichment to finish processing before the request fails. + * + * @return the semanticMaxWaitInMilliseconds value. + */ + public Integer getSemanticMaxWaitInMilliseconds() { + return this.semanticMaxWaitInMilliseconds; + } + + /** + * Set the semanticMaxWaitInMilliseconds property: Allows the user to set an upper bound on the amount of time it + * takes for semantic enrichment to finish processing before the request fails. + * + * @param semanticMaxWaitInMilliseconds the semanticMaxWaitInMilliseconds value to set. + * @return the SearchRequest object itself. + */ + public SearchRequest setSemanticMaxWaitInMilliseconds(Integer semanticMaxWaitInMilliseconds) { + this.semanticMaxWaitInMilliseconds = semanticMaxWaitInMilliseconds; + return this; + } + + /** + * Get the debug property: Enables a debugging tool that can be used to further explore your Semantic search + * results. + * + * @return the debug value. + */ + public QueryDebugMode getDebug() { + return this.debug; + } + + /** + * Set the debug property: Enables a debugging tool that can be used to further explore your Semantic search + * results. + * + * @param debug the debug value to set. + * @return the SearchRequest object itself. + */ + public SearchRequest setDebug(QueryDebugMode debug) { + this.debug = debug; + return this; + } + /** * Get the searchText property: A full-text search query expression; Use "*" or omit this parameter to match all * documents. @@ -626,7 +718,9 @@ public SearchRequest setSpeller(QuerySpellerType speller) { * Get the answers property: This parameter is only valid if the query type is 'semantic'. If set, the query returns * answers extracted from key passages in the highest ranked documents. The number of answers returned can be * configured by appending the pipe character '|' followed by the 'count-<number of answers>' option after the - * answers parameter value, such as 'extractive|count-3'. Default count is 1. + * answers parameter value, such as 'extractive|count-3'. Default count is 1. The confidence threshold can be + * configured by appending the pipe character '|' followed by the 'threshold-<confidence threshold>' option + * after the answers parameter value, such as 'extractive|threshold-0.9'. Default threshold is 0.7. * * @return the answers value. */ @@ -638,7 +732,9 @@ public String getAnswers() { * Set the answers property: This parameter is only valid if the query type is 'semantic'. If set, the query returns * answers extracted from key passages in the highest ranked documents. The number of answers returned can be * configured by appending the pipe character '|' followed by the 'count-<number of answers>' option after the - * answers parameter value, such as 'extractive|count-3'. Default count is 1. + * answers parameter value, such as 'extractive|count-3'. Default count is 1. The confidence threshold can be + * configured by appending the pipe character '|' followed by the 'threshold-<confidence threshold>' option + * after the answers parameter value, such as 'extractive|threshold-0.9'. Default threshold is 0.7. * * @param answers the answers value to set. * @return the SearchRequest object itself. @@ -764,6 +860,26 @@ public SearchRequest setSemanticFields(String semanticFields) { return this; } + /** + * Get the vector property: The query parameters for vector and hybrid search queries. + * + * @return the vector value. + */ + public Vector getVector() { + return this.vector; + } + + /** + * Set the vector property: The query parameters for vector and hybrid search queries. + * + * @param vector the vector value to set. + * @return the SearchRequest object itself. + */ + public SearchRequest setVector(Vector vector) { + this.vector = vector; + return this; + } + @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); @@ -782,6 +898,9 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { "scoringParameters", this.scoringParameters, (writer, element) -> writer.writeString(element)); jsonWriter.writeStringField("scoringProfile", this.scoringProfile); jsonWriter.writeStringField("semanticConfiguration", this.semanticConfiguration); + jsonWriter.writeStringField("semanticErrorHandling", Objects.toString(this.semanticErrorHandling, null)); + jsonWriter.writeNumberField("semanticMaxWaitInMilliseconds", this.semanticMaxWaitInMilliseconds); + jsonWriter.writeStringField("debug", Objects.toString(this.debug, null)); jsonWriter.writeStringField("search", this.searchText); jsonWriter.writeStringField("searchFields", this.searchFields); jsonWriter.writeStringField("searchMode", Objects.toString(this.searchMode, null)); @@ -793,6 +912,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeNumberField("top", this.top); jsonWriter.writeStringField("captions", this.captions); jsonWriter.writeStringField("semanticFields", this.semanticFields); + jsonWriter.writeJsonField("vector", this.vector); return jsonWriter.writeEndObject(); } @@ -844,6 +964,14 @@ public static SearchRequest fromJson(JsonReader jsonReader) throws IOException { deserializedSearchRequest.scoringProfile = reader.getString(); } else if ("semanticConfiguration".equals(fieldName)) { deserializedSearchRequest.semanticConfiguration = reader.getString(); + } else if ("semanticErrorHandling".equals(fieldName)) { + deserializedSearchRequest.semanticErrorHandling = + SemanticErrorHandling.fromString(reader.getString()); + } else if ("semanticMaxWaitInMilliseconds".equals(fieldName)) { + deserializedSearchRequest.semanticMaxWaitInMilliseconds = + reader.getNullable(JsonReader::getInt); + } else if ("debug".equals(fieldName)) { + deserializedSearchRequest.debug = QueryDebugMode.fromString(reader.getString()); } else if ("search".equals(fieldName)) { deserializedSearchRequest.searchText = reader.getString(); } else if ("searchFields".equals(fieldName)) { @@ -866,6 +994,8 @@ public static SearchRequest fromJson(JsonReader jsonReader) throws IOException { deserializedSearchRequest.captions = reader.getString(); } else if ("semanticFields".equals(fieldName)) { deserializedSearchRequest.semanticFields = reader.getString(); + } else if ("vector".equals(fieldName)) { + deserializedSearchRequest.vector = Vector.fromJson(reader); } else { reader.skipChildren(); } diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/SearchResult.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/SearchResult.java index a4495c233b643..fdcb6a1286724 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/SearchResult.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/SearchResult.java @@ -12,6 +12,7 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import com.azure.search.documents.models.CaptionResult; +import com.azure.search.documents.models.DocumentDebugInfo; import java.io.IOException; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -44,6 +45,11 @@ public final class SearchResult implements JsonSerializable { */ private List captions; + /* + * Contains debugging information that can be used to further explore your search results. + */ + private List documentDebugInfo; + /* * Contains a document found by a search query, plus associated metadata. */ @@ -98,6 +104,16 @@ public List getCaptions() { return this.captions; } + /** + * Get the documentDebugInfo property: Contains debugging information that can be used to further explore your + * search results. + * + * @return the documentDebugInfo value. + */ + public List getDocumentDebugInfo() { + return this.documentDebugInfo; + } + /** * Get the additionalProperties property: Contains a document found by a search query, plus associated metadata. * @@ -128,6 +144,8 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { this.highlights, (writer, element) -> writer.writeArray(element, (writer1, element1) -> writer1.writeString(element1))); jsonWriter.writeArrayField("@search.captions", this.captions, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField( + "@search.documentDebugInfo", this.documentDebugInfo, (writer, element) -> writer.writeJson(element)); if (additionalProperties != null) { for (Map.Entry additionalProperty : additionalProperties.entrySet()) { jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); @@ -153,6 +171,7 @@ public static SearchResult fromJson(JsonReader jsonReader) throws IOException { Double rerankerScore = null; Map> highlights = null; List captions = null; + List documentDebugInfo = null; Map additionalProperties = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); @@ -167,6 +186,8 @@ public static SearchResult fromJson(JsonReader jsonReader) throws IOException { highlights = reader.readMap(reader1 -> reader1.readArray(reader2 -> reader2.getString())); } else if ("@search.captions".equals(fieldName)) { captions = reader.readArray(reader1 -> CaptionResult.fromJson(reader1)); + } else if ("@search.documentDebugInfo".equals(fieldName)) { + documentDebugInfo = reader.readArray(reader1 -> DocumentDebugInfo.fromJson(reader1)); } else { if (additionalProperties == null) { additionalProperties = new LinkedHashMap<>(); @@ -180,6 +201,7 @@ public static SearchResult fromJson(JsonReader jsonReader) throws IOException { deserializedSearchResult.rerankerScore = rerankerScore; deserializedSearchResult.highlights = highlights; deserializedSearchResult.captions = captions; + deserializedSearchResult.documentDebugInfo = documentDebugInfo; deserializedSearchResult.additionalProperties = additionalProperties; return deserializedSearchResult; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/Vector.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/Vector.java new file mode 100644 index 0000000000000..3b5541e2ad4bc --- /dev/null +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/models/Vector.java @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package com.azure.search.documents.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** The query parameters for vector and hybrid search queries. */ +@Fluent +public final class Vector implements JsonSerializable { + /* + * The vector representation of a search query. + */ + private List value; + + /* + * Number of nearest neighbors to return as top hits. + */ + private Integer k; + + /* + * Vector Fields of type Collection(Edm.Single) to be included in the vector searched. + */ + private String fields; + + /** Creates an instance of Vector class. */ + public Vector() {} + + /** + * Get the value property: The vector representation of a search query. + * + * @return the value value. + */ + public List getValue() { + return this.value; + } + + /** + * Set the value property: The vector representation of a search query. + * + * @param value the value value to set. + * @return the Vector object itself. + */ + public Vector setValue(List value) { + this.value = value; + return this; + } + + /** + * Get the k property: Number of nearest neighbors to return as top hits. + * + * @return the k value. + */ + public Integer getK() { + return this.k; + } + + /** + * Set the k property: Number of nearest neighbors to return as top hits. + * + * @param k the k value to set. + * @return the Vector object itself. + */ + public Vector setK(Integer k) { + this.k = k; + return this; + } + + /** + * Get the fields property: Vector Fields of type Collection(Edm.Single) to be included in the vector searched. + * + * @return the fields value. + */ + public String getFields() { + return this.fields; + } + + /** + * Set the fields property: Vector Fields of type Collection(Edm.Single) to be included in the vector searched. + * + * @param fields the fields value to set. + * @return the Vector object itself. + */ + public Vector setFields(String fields) { + this.fields = fields; + return this; + } + + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeFloat(element)); + jsonWriter.writeNumberField("k", this.k); + jsonWriter.writeStringField("fields", this.fields); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Vector from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Vector if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IOException If an error occurs while reading the Vector. + */ + public static Vector fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject( + reader -> { + Vector deserializedVector = new Vector(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> reader1.getFloat()); + deserializedVector.value = value; + } else if ("k".equals(fieldName)) { + deserializedVector.k = reader.getNullable(JsonReader::getInt); + } else if ("fields".equals(fieldName)) { + deserializedVector.fields = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedVector; + }); + } +} diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/util/SearchPagedResponseAccessHelper.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/util/SearchPagedResponseAccessHelper.java index 4529da529e1fd..f12ae45725be1 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/util/SearchPagedResponseAccessHelper.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/util/SearchPagedResponseAccessHelper.java @@ -3,6 +3,8 @@ package com.azure.search.documents.implementation.util; +import com.azure.search.documents.models.SemanticPartialResponseReason; +import com.azure.search.documents.models.SemanticPartialResponseType; import com.azure.search.documents.models.AnswerResult; import com.azure.search.documents.models.FacetResult; import com.azure.search.documents.util.SearchPagedResponse; @@ -61,6 +63,23 @@ public interface SearchPagedResponseAccessor { * @return The answer results if {@code answers} were supplied in the request, otherwise null. */ List getAnswers(SearchPagedResponse response); + + /** + * The reason that a partial response was returned for a semantic search request. + * + * @param response The {@link SearchPagedResponse} being accessed. + * @return The reason that a partial response was returned for a semantic search request. + */ + SemanticPartialResponseReason getSemanticPartialResponseReason(SearchPagedResponse response); + + /** + * Get the semanticPartialResponseType property: Type of partial response that was returned for a semantic search + * request. + * + * @param response The {@link SearchPagedResponse} being accessed. + * @return the semanticPartialResponseType value. + */ + SemanticPartialResponseType getSemanticPartialResponseType(SearchPagedResponse response); } /** @@ -113,6 +132,24 @@ public static List getAnswers(SearchPagedResponse response) { return accessor.getAnswers(response); } + /** + * The reason that a partial response was returned for a semantic search request. + * @param response The {@link SearchPagedResponse} being accessed. + * @return The reason that a partial response was returned for a semantic search request. + */ + public static SemanticPartialResponseReason getSemanticPartialResponseReason(SearchPagedResponse response) { + return accessor.getSemanticPartialResponseReason(response); + } + + /** + * The type of partial response that was returned for a semantic search request. + * @param response The {@link SearchPagedResponse} being accessed. + * @return The type of partial response that was returned for a semantic search request. + */ + public static SemanticPartialResponseType getSemanticPartialResponseType(SearchPagedResponse response) { + return accessor.getSemanticPartialResponseType(response); + } + public static void setAccessor(SearchPagedResponseAccessor searchPagedResponseAccessor) { accessor = searchPagedResponseAccessor; } diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/implementation/models/EntityRecognitionSkillV1.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/implementation/models/EntityRecognitionSkillV1.java index c89506f43eb47..ff166da3b8c2f 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/implementation/models/EntityRecognitionSkillV1.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/implementation/models/EntityRecognitionSkillV1.java @@ -20,7 +20,7 @@ import java.util.List; import java.util.Objects; -/** Text analytics entity recognition. */ +/** This skill is deprecated. Use the V3.EntityRecognitionSkill instead. */ @Fluent public final class EntityRecognitionSkillV1 extends SearchIndexerSkill { /* diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/implementation/models/SentimentSkillV1.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/implementation/models/SentimentSkillV1.java index 4b63816c2b37a..69bbff5e821fd 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/implementation/models/SentimentSkillV1.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/implementation/models/SentimentSkillV1.java @@ -19,7 +19,7 @@ import java.util.List; import java.util.Objects; -/** Text analytics positive-negative sentiment analysis, scored as a floating point value in a range of zero to 1. */ +/** This skill is deprecated. Use the V3.SentimentSkill instead. */ @Fluent public final class SentimentSkillV1 extends SearchIndexerSkill { /* diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/EntityRecognitionSkillLanguage.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/EntityRecognitionSkillLanguage.java index 51fa3dcfa395a..ffff3fbc82c79 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/EntityRecognitionSkillLanguage.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/EntityRecognitionSkillLanguage.java @@ -9,7 +9,7 @@ import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; -/** The language codes supported for input text by EntityRecognitionSkill. */ +/** Deprecated. The language codes supported for input text by EntityRecognitionSkill. */ public final class EntityRecognitionSkillLanguage extends ExpandableStringEnum { /** Arabic. */ public static final EntityRecognitionSkillLanguage AR = fromString("ar"); diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/HnswParameters.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/HnswParameters.java new file mode 100644 index 0000000000000..cca9cb904ad20 --- /dev/null +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/HnswParameters.java @@ -0,0 +1,184 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package com.azure.search.documents.indexes.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Objects; + +/** Contains the parameters specific to hnsw algorithm. */ +@Fluent +public final class HnswParameters implements JsonSerializable { + /* + * The number of bi-directional links created for every new element during construction. Increasing this parameter + * value may improve recall and reduce retrieval times for datasets with high intrinsic dimensionality at the + * expense of increased memory consumption and longer indexing time. + */ + private Integer m; + + /* + * The size of the dynamic list containing the nearest neighbors, which is used during index time. Increasing this + * parameter may improve index quality, at the expense of increased indexing time. At a certain point, increasing + * this parameter leads to diminishing returns. + */ + private Integer efConstruction; + + /* + * The size of the dynamic list containing the nearest neighbors, which is used during search time. Increasing this + * parameter may improve search results, at the expense of slower search. Increasing this parameter leads to + * diminishing returns.. + */ + private Integer efSearch; + + /* + * The similarity metric to use for vector comparisons. + */ + private VectorSearchAlgorithmMetric metric; + + /** Creates an instance of HnswParameters class. */ + public HnswParameters() {} + + /** + * Get the m property: The number of bi-directional links created for every new element during construction. + * Increasing this parameter value may improve recall and reduce retrieval times for datasets with high intrinsic + * dimensionality at the expense of increased memory consumption and longer indexing time. + * + * @return the m value. + */ + public Integer getM() { + return this.m; + } + + /** + * Set the m property: The number of bi-directional links created for every new element during construction. + * Increasing this parameter value may improve recall and reduce retrieval times for datasets with high intrinsic + * dimensionality at the expense of increased memory consumption and longer indexing time. + * + * @param m the m value to set. + * @return the HnswParameters object itself. + */ + public HnswParameters setM(Integer m) { + this.m = m; + return this; + } + + /** + * Get the efConstruction property: The size of the dynamic list containing the nearest neighbors, which is used + * during index time. Increasing this parameter may improve index quality, at the expense of increased indexing + * time. At a certain point, increasing this parameter leads to diminishing returns. + * + * @return the efConstruction value. + */ + public Integer getEfConstruction() { + return this.efConstruction; + } + + /** + * Set the efConstruction property: The size of the dynamic list containing the nearest neighbors, which is used + * during index time. Increasing this parameter may improve index quality, at the expense of increased indexing + * time. At a certain point, increasing this parameter leads to diminishing returns. + * + * @param efConstruction the efConstruction value to set. + * @return the HnswParameters object itself. + */ + public HnswParameters setEfConstruction(Integer efConstruction) { + this.efConstruction = efConstruction; + return this; + } + + /** + * Get the efSearch property: The size of the dynamic list containing the nearest neighbors, which is used during + * search time. Increasing this parameter may improve search results, at the expense of slower search. Increasing + * this parameter leads to diminishing returns.. + * + * @return the efSearch value. + */ + public Integer getEfSearch() { + return this.efSearch; + } + + /** + * Set the efSearch property: The size of the dynamic list containing the nearest neighbors, which is used during + * search time. Increasing this parameter may improve search results, at the expense of slower search. Increasing + * this parameter leads to diminishing returns.. + * + * @param efSearch the efSearch value to set. + * @return the HnswParameters object itself. + */ + public HnswParameters setEfSearch(Integer efSearch) { + this.efSearch = efSearch; + return this; + } + + /** + * Get the metric property: The similarity metric to use for vector comparisons. + * + * @return the metric value. + */ + public VectorSearchAlgorithmMetric getMetric() { + return this.metric; + } + + /** + * Set the metric property: The similarity metric to use for vector comparisons. + * + * @param metric the metric value to set. + * @return the HnswParameters object itself. + */ + public HnswParameters setMetric(VectorSearchAlgorithmMetric metric) { + this.metric = metric; + return this; + } + + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("m", this.m); + jsonWriter.writeNumberField("efConstruction", this.efConstruction); + jsonWriter.writeNumberField("efSearch", this.efSearch); + jsonWriter.writeStringField("metric", Objects.toString(this.metric, null)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of HnswParameters from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of HnswParameters if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the HnswParameters. + */ + public static HnswParameters fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject( + reader -> { + HnswParameters deserializedHnswParameters = new HnswParameters(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("m".equals(fieldName)) { + deserializedHnswParameters.m = reader.getNullable(JsonReader::getInt); + } else if ("efConstruction".equals(fieldName)) { + deserializedHnswParameters.efConstruction = reader.getNullable(JsonReader::getInt); + } else if ("efSearch".equals(fieldName)) { + deserializedHnswParameters.efSearch = reader.getNullable(JsonReader::getInt); + } else if ("metric".equals(fieldName)) { + deserializedHnswParameters.metric = + VectorSearchAlgorithmMetric.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedHnswParameters; + }); + } +} diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/HnswVectorSearchAlgorithmConfiguration.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/HnswVectorSearchAlgorithmConfiguration.java new file mode 100644 index 0000000000000..07a3f91037d97 --- /dev/null +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/HnswVectorSearchAlgorithmConfiguration.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package com.azure.search.documents.indexes.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * Contains configuration options specific to the hnsw approximate nearest neighbors algorithm used during indexing + * time. + */ +@Fluent +public final class HnswVectorSearchAlgorithmConfiguration extends VectorSearchAlgorithmConfiguration { + /* + * The name of the kind of algorithm being configured for use with vector search. Only `hnsw` is supported in the + * current preview. + */ + private static final String KIND = "hnsw"; + + /* + * Contains the parameters specific to hnsw algorithm. + */ + private HnswParameters parameters; + + /** + * Creates an instance of HnswVectorSearchAlgorithmConfiguration class. + * + * @param name the name value to set. + */ + public HnswVectorSearchAlgorithmConfiguration(String name) { + super(name); + } + + /** + * Get the parameters property: Contains the parameters specific to hnsw algorithm. + * + * @return the parameters value. + */ + public HnswParameters getParameters() { + return this.parameters; + } + + /** + * Set the parameters property: Contains the parameters specific to hnsw algorithm. + * + * @param parameters the parameters value to set. + * @return the HnswVectorSearchAlgorithmConfiguration object itself. + */ + public HnswVectorSearchAlgorithmConfiguration setParameters(HnswParameters parameters) { + this.parameters = parameters; + return this; + } + + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("kind", KIND); + jsonWriter.writeStringField("name", getName()); + jsonWriter.writeJsonField("hnswParameters", this.parameters); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of HnswVectorSearchAlgorithmConfiguration from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of HnswVectorSearchAlgorithmConfiguration if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties or the + * polymorphic discriminator. + * @throws IOException If an error occurs while reading the HnswVectorSearchAlgorithmConfiguration. + */ + public static HnswVectorSearchAlgorithmConfiguration fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject( + reader -> { + boolean nameFound = false; + String name = null; + HnswParameters parameters = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("kind".equals(fieldName)) { + String kind = reader.getString(); + if (!KIND.equals(kind)) { + throw new IllegalStateException( + "'kind' was expected to be non-null and equal to '" + + KIND + + "'. The found 'kind' was '" + + kind + + "'."); + } + } else if ("name".equals(fieldName)) { + name = reader.getString(); + nameFound = true; + } else if ("hnswParameters".equals(fieldName)) { + parameters = HnswParameters.fromJson(reader); + } else { + reader.skipChildren(); + } + } + if (nameFound) { + HnswVectorSearchAlgorithmConfiguration deserializedHnswVectorSearchAlgorithmConfiguration = + new HnswVectorSearchAlgorithmConfiguration(name); + deserializedHnswVectorSearchAlgorithmConfiguration.parameters = parameters; + + return deserializedHnswVectorSearchAlgorithmConfiguration; + } + List missingProperties = new ArrayList<>(); + if (!nameFound) { + missingProperties.add("name"); + } + + throw new IllegalStateException( + "Missing required property/properties: " + String.join(", ", missingProperties)); + }); + } +} diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchField.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchField.java index c47de7c7a1e2d..4ec44a4b07de3 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchField.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchField.java @@ -118,6 +118,17 @@ public final class SearchField implements JsonSerializable { */ private LexicalNormalizerName normalizerName; + /* + * The dimensionality of the vector field. + */ + private Integer dimensions; + + /* + * The name of the vector search algorithm configuration that specifies the algorithm and optional parameters for + * searching the vector field. + */ + private String vectorSearchConfiguration; + /* * A list of the names of synonym maps to associate with this field. This option can be used only with searchable * fields. Currently only one synonym map per field is supported. Assigning a synonym map to a field ensures that @@ -444,6 +455,48 @@ public SearchField setNormalizerName(LexicalNormalizerName normalizerName) { return this; } + /** + * Get the dimensions property: The dimensionality of the vector field. + * + * @return the dimensions value. + */ + public Integer getDimensions() { + return this.dimensions; + } + + /** + * Set the dimensions property: The dimensionality of the vector field. + * + * @param dimensions the dimensions value to set. + * @return the SearchField object itself. + */ + public SearchField setDimensions(Integer dimensions) { + this.dimensions = dimensions; + return this; + } + + /** + * Get the vectorSearchConfiguration property: The name of the vector search algorithm configuration that specifies + * the algorithm and optional parameters for searching the vector field. + * + * @return the vectorSearchConfiguration value. + */ + public String getVectorSearchConfiguration() { + return this.vectorSearchConfiguration; + } + + /** + * Set the vectorSearchConfiguration property: The name of the vector search algorithm configuration that specifies + * the algorithm and optional parameters for searching the vector field. + * + * @param vectorSearchConfiguration the vectorSearchConfiguration value to set. + * @return the SearchField object itself. + */ + public SearchField setVectorSearchConfiguration(String vectorSearchConfiguration) { + this.vectorSearchConfiguration = vectorSearchConfiguration; + return this; + } + /** * Get the synonymMapNames property: A list of the names of synonym maps to associate with this field. This option * can be used only with searchable fields. Currently only one synonym map per field is supported. Assigning a @@ -509,6 +562,8 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStringField("searchAnalyzer", Objects.toString(this.searchAnalyzerName, null)); jsonWriter.writeStringField("indexAnalyzer", Objects.toString(this.indexAnalyzerName, null)); jsonWriter.writeStringField("normalizer", Objects.toString(this.normalizerName, null)); + jsonWriter.writeNumberField("dimensions", this.dimensions); + jsonWriter.writeStringField("vectorSearchConfiguration", this.vectorSearchConfiguration); jsonWriter.writeArrayField( "synonymMaps", this.synonymMapNames, (writer, element) -> writer.writeString(element)); jsonWriter.writeArrayField("fields", this.fields, (writer, element) -> writer.writeJson(element)); @@ -541,6 +596,8 @@ public static SearchField fromJson(JsonReader jsonReader) throws IOException { LexicalAnalyzerName searchAnalyzerName = null; LexicalAnalyzerName indexAnalyzerName = null; LexicalNormalizerName normalizerName = null; + Integer dimensions = null; + String vectorSearchConfiguration = null; List synonymMapNames = null; List fields = null; while (reader.nextToken() != JsonToken.END_OBJECT) { @@ -573,6 +630,10 @@ public static SearchField fromJson(JsonReader jsonReader) throws IOException { indexAnalyzerName = LexicalAnalyzerName.fromString(reader.getString()); } else if ("normalizer".equals(fieldName)) { normalizerName = LexicalNormalizerName.fromString(reader.getString()); + } else if ("dimensions".equals(fieldName)) { + dimensions = reader.getNullable(JsonReader::getInt); + } else if ("vectorSearchConfiguration".equals(fieldName)) { + vectorSearchConfiguration = reader.getString(); } else if ("synonymMaps".equals(fieldName)) { synonymMapNames = reader.readArray(reader1 -> reader1.getString()); } else if ("fields".equals(fieldName)) { @@ -593,6 +654,8 @@ public static SearchField fromJson(JsonReader jsonReader) throws IOException { deserializedSearchField.searchAnalyzerName = searchAnalyzerName; deserializedSearchField.indexAnalyzerName = indexAnalyzerName; deserializedSearchField.normalizerName = normalizerName; + deserializedSearchField.dimensions = dimensions; + deserializedSearchField.vectorSearchConfiguration = vectorSearchConfiguration; deserializedSearchField.synonymMapNames = synonymMapNames; deserializedSearchField.fields = fields; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchFieldDataType.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchFieldDataType.java index 99cb0439651dd..e9c1b40b5e5cd 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchFieldDataType.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchFieldDataType.java @@ -35,6 +35,12 @@ public final class SearchFieldDataType extends ExpandableStringEnum { */ private SemanticSettings semanticSettings; + /* + * Contains configuration options related to vector search. + */ + private VectorSearch vectorSearch; + /* * The ETag of the index. */ @@ -411,6 +416,26 @@ public SearchIndex setSemanticSettings(SemanticSettings semanticSettings) { return this; } + /** + * Get the vectorSearch property: Contains configuration options related to vector search. + * + * @return the vectorSearch value. + */ + public VectorSearch getVectorSearch() { + return this.vectorSearch; + } + + /** + * Set the vectorSearch property: Contains configuration options related to vector search. + * + * @param vectorSearch the vectorSearch value to set. + * @return the SearchIndex object itself. + */ + public SearchIndex setVectorSearch(VectorSearch vectorSearch) { + this.vectorSearch = vectorSearch; + return this; + } + /** * Get the eTag property: The ETag of the index. * @@ -449,6 +474,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeJsonField("encryptionKey", this.encryptionKey); jsonWriter.writeJsonField("similarity", this.similarity); jsonWriter.writeJsonField("semantic", this.semanticSettings); + jsonWriter.writeJsonField("vectorSearch", this.vectorSearch); jsonWriter.writeStringField("@odata.etag", this.eTag); return jsonWriter.writeEndObject(); } @@ -480,6 +506,7 @@ public static SearchIndex fromJson(JsonReader jsonReader) throws IOException { SearchResourceEncryptionKey encryptionKey = null; SimilarityAlgorithm similarity = null; SemanticSettings semanticSettings = null; + VectorSearch vectorSearch = null; String eTag = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); @@ -514,6 +541,8 @@ public static SearchIndex fromJson(JsonReader jsonReader) throws IOException { similarity = SimilarityAlgorithm.fromJson(reader); } else if ("semantic".equals(fieldName)) { semanticSettings = SemanticSettings.fromJson(reader); + } else if ("vectorSearch".equals(fieldName)) { + vectorSearch = VectorSearch.fromJson(reader); } else if ("@odata.etag".equals(fieldName)) { eTag = reader.getString(); } else { @@ -535,6 +564,7 @@ public static SearchIndex fromJson(JsonReader jsonReader) throws IOException { deserializedSearchIndex.encryptionKey = encryptionKey; deserializedSearchIndex.similarity = similarity; deserializedSearchIndex.semanticSettings = semanticSettings; + deserializedSearchIndex.vectorSearch = vectorSearch; deserializedSearchIndex.eTag = eTag; return deserializedSearchIndex; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchIndexStatistics.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchIndexStatistics.java index abf0bb6f7ac89..d17a61511a15d 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchIndexStatistics.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchIndexStatistics.java @@ -30,6 +30,11 @@ public final class SearchIndexStatistics implements JsonSerializable { /* * The connection string to the storage account projections will be stored in. @@ -28,6 +28,14 @@ public final class SearchIndexerKnowledgeStore implements JsonSerializable projections; + /* + * The user-assigned managed identity used for connections to Azure Storage when writing knowledge store + * projections. If the connection string indicates an identity (ResourceId) and it's not specified, the + * system-assigned managed identity is used. On updates to the indexer, if the identity is unspecified, the value + * remains unchanged. If set to "none", the value of this property is cleared. + */ + private SearchIndexerDataIdentity identity; + /** * Creates an instance of SearchIndexerKnowledgeStore class. * @@ -59,11 +67,38 @@ public List getProjections() { return this.projections; } + /** + * Get the identity property: The user-assigned managed identity used for connections to Azure Storage when writing + * knowledge store projections. If the connection string indicates an identity (ResourceId) and it's not specified, + * the system-assigned managed identity is used. On updates to the indexer, if the identity is unspecified, the + * value remains unchanged. If set to "none", the value of this property is cleared. + * + * @return the identity value. + */ + public SearchIndexerDataIdentity getIdentity() { + return this.identity; + } + + /** + * Set the identity property: The user-assigned managed identity used for connections to Azure Storage when writing + * knowledge store projections. If the connection string indicates an identity (ResourceId) and it's not specified, + * the system-assigned managed identity is used. On updates to the indexer, if the identity is unspecified, the + * value remains unchanged. If set to "none", the value of this property is cleared. + * + * @param identity the identity value to set. + * @return the SearchIndexerKnowledgeStore object itself. + */ + public SearchIndexerKnowledgeStore setIdentity(SearchIndexerDataIdentity identity) { + this.identity = identity; + return this; + } + @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); jsonWriter.writeStringField("storageConnectionString", this.storageConnectionString); jsonWriter.writeArrayField("projections", this.projections, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("identity", this.identity); return jsonWriter.writeEndObject(); } @@ -83,6 +118,7 @@ public static SearchIndexerKnowledgeStore fromJson(JsonReader jsonReader) throws String storageConnectionString = null; boolean projectionsFound = false; List projections = null; + SearchIndexerDataIdentity identity = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); @@ -95,6 +131,8 @@ public static SearchIndexerKnowledgeStore fromJson(JsonReader jsonReader) throws reader.readArray( reader1 -> SearchIndexerKnowledgeStoreProjection.fromJson(reader1)); projectionsFound = true; + } else if ("identity".equals(fieldName)) { + identity = SearchIndexerDataIdentity.fromJson(reader); } else { reader.skipChildren(); } @@ -102,6 +140,7 @@ public static SearchIndexerKnowledgeStore fromJson(JsonReader jsonReader) throws if (storageConnectionStringFound && projectionsFound) { SearchIndexerKnowledgeStore deserializedSearchIndexerKnowledgeStore = new SearchIndexerKnowledgeStore(storageConnectionString, projections); + deserializedSearchIndexerKnowledgeStore.identity = identity; return deserializedSearchIndexerKnowledgeStore; } diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchServiceCounters.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchServiceCounters.java index 04fe279a3d574..e4c3d3a928262 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchServiceCounters.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchServiceCounters.java @@ -58,6 +58,11 @@ public final class SearchServiceCounters implements JsonSerializable { + /* + * Allows you to set the name of a default semantic configuration in your index, making it optional to pass it on + * as a query parameter every time. + */ + private String defaultConfiguration; + /* * The semantic configurations for the index. */ @@ -25,6 +31,28 @@ public final class SemanticSettings implements JsonSerializable configurat @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); + jsonWriter.writeStringField("defaultConfiguration", this.defaultConfiguration); jsonWriter.writeArrayField( "configurations", this.configurations, (writer, element) -> writer.writeJson(element)); return jsonWriter.writeEndObject(); @@ -69,7 +98,9 @@ public static SemanticSettings fromJson(JsonReader jsonReader) throws IOExceptio String fieldName = reader.getFieldName(); reader.nextToken(); - if ("configurations".equals(fieldName)) { + if ("defaultConfiguration".equals(fieldName)) { + deserializedSemanticSettings.defaultConfiguration = reader.getString(); + } else if ("configurations".equals(fieldName)) { List configurations = reader.readArray(reader1 -> SemanticConfiguration.fromJson(reader1)); deserializedSemanticSettings.configurations = configurations; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SentimentSkillLanguage.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SentimentSkillLanguage.java index d19d90717a843..b7da9b4e57bfa 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SentimentSkillLanguage.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SentimentSkillLanguage.java @@ -9,7 +9,7 @@ import com.azure.core.util.ExpandableStringEnum; import java.util.Collection; -/** The language codes supported for input text by SentimentSkill. */ +/** Deprecated. The language codes supported for input text by SentimentSkill. */ public final class SentimentSkillLanguage extends ExpandableStringEnum { /** Danish. */ public static final SentimentSkillLanguage DA = fromString("da"); diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/VectorSearch.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/VectorSearch.java new file mode 100644 index 0000000000000..7a26ea0657aee --- /dev/null +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/VectorSearch.java @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package com.azure.search.documents.indexes.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** Contains configuration options related to vector search. */ +@Fluent +public final class VectorSearch implements JsonSerializable { + /* + * Contains configuration options specific to the algorithm used during indexing time. + */ + private List algorithmConfigurations; + + /** Creates an instance of VectorSearch class. */ + public VectorSearch() {} + + /** + * Get the algorithmConfigurations property: Contains configuration options specific to the algorithm used during + * indexing time. + * + * @return the algorithmConfigurations value. + */ + public List getAlgorithmConfigurations() { + return this.algorithmConfigurations; + } + + /** + * Set the algorithmConfigurations property: Contains configuration options specific to the algorithm used during + * indexing time. + * + * @param algorithmConfigurations the algorithmConfigurations value to set. + * @return the VectorSearch object itself. + */ + public VectorSearch setAlgorithmConfigurations(List algorithmConfigurations) { + this.algorithmConfigurations = algorithmConfigurations; + return this; + } + + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField( + "algorithmConfigurations", + this.algorithmConfigurations, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VectorSearch from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VectorSearch if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the VectorSearch. + */ + public static VectorSearch fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject( + reader -> { + VectorSearch deserializedVectorSearch = new VectorSearch(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("algorithmConfigurations".equals(fieldName)) { + List algorithmConfigurations = + reader.readArray(reader1 -> VectorSearchAlgorithmConfiguration.fromJson(reader1)); + deserializedVectorSearch.algorithmConfigurations = algorithmConfigurations; + } else { + reader.skipChildren(); + } + } + + return deserializedVectorSearch; + }); + } +} diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/VectorSearchAlgorithmConfiguration.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/VectorSearchAlgorithmConfiguration.java new file mode 100644 index 0000000000000..4ee50c66b1a4d --- /dev/null +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/VectorSearchAlgorithmConfiguration.java @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package com.azure.search.documents.indexes.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** Contains configuration options specific to the algorithm used during indexing time. */ +@Immutable +public class VectorSearchAlgorithmConfiguration implements JsonSerializable { + /* + * The name to associate with this particular configuration. + */ + private final String name; + + /** + * Creates an instance of VectorSearchAlgorithmConfiguration class. + * + * @param name the name value to set. + */ + public VectorSearchAlgorithmConfiguration(String name) { + this.name = name; + } + + /** + * Get the name property: The name to associate with this particular configuration. + * + * @return the name value. + */ + public String getName() { + return this.name; + } + + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VectorSearchAlgorithmConfiguration from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VectorSearchAlgorithmConfiguration if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties or the + * polymorphic discriminator. + * @throws IOException If an error occurs while reading the VectorSearchAlgorithmConfiguration. + */ + public static VectorSearchAlgorithmConfiguration fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject( + reader -> { + String discriminatorValue = null; + JsonReader readerToUse = reader.bufferObject(); + + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + + if (discriminatorValue != null) { + readerToUse = readerToUse.reset(); + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("hnsw".equals(discriminatorValue)) { + return HnswVectorSearchAlgorithmConfiguration.fromJson(readerToUse); + } else { + throw new IllegalStateException( + "Discriminator field 'kind' didn't match one of the expected values 'hnsw'"); + } + }); + } +} diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/VectorSearchAlgorithmMetric.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/VectorSearchAlgorithmMetric.java new file mode 100644 index 0000000000000..c30c6fb6ea07c --- /dev/null +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/VectorSearchAlgorithmMetric.java @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package com.azure.search.documents.indexes.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** The similarity metric to use for vector comparisons. */ +public final class VectorSearchAlgorithmMetric extends ExpandableStringEnum { + /** Static value cosine for VectorSearchAlgorithmMetric. */ + public static final VectorSearchAlgorithmMetric COSINE = fromString("cosine"); + + /** Static value euclidean for VectorSearchAlgorithmMetric. */ + public static final VectorSearchAlgorithmMetric EUCLIDEAN = fromString("euclidean"); + + /** Static value dotProduct for VectorSearchAlgorithmMetric. */ + public static final VectorSearchAlgorithmMetric DOT_PRODUCT = fromString("dotProduct"); + + /** + * Creates a new instance of VectorSearchAlgorithmMetric value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public VectorSearchAlgorithmMetric() {} + + /** + * Creates or finds a VectorSearchAlgorithmMetric from its string representation. + * + * @param name a name to look for. + * @return the corresponding VectorSearchAlgorithmMetric. + */ + public static VectorSearchAlgorithmMetric fromString(String name) { + return fromString(name, VectorSearchAlgorithmMetric.class); + } + + /** + * Gets known VectorSearchAlgorithmMetric values. + * + * @return known VectorSearchAlgorithmMetric values. + */ + public static Collection values() { + return values(VectorSearchAlgorithmMetric.class); + } +} diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/WebApiSkill.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/WebApiSkill.java index 0e700c1a6b3c5..e3cc18a34ea11 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/WebApiSkill.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/WebApiSkill.java @@ -55,6 +55,22 @@ public final class WebApiSkill extends SearchIndexerSkill { */ private Integer degreeOfParallelism; + /* + * Applies to custom skills that connect to external code in an Azure function or some other application that + * provides the transformations. This value should be the application ID created for the function or app when it + * was registered with Azure Active Directory. When specified, the custom skill connects to the function or app + * using a managed ID (either system or user-assigned) of the search service and the access token of the function + * or app, using this value as the resource id for creating the scope of the access token. + */ + private String authResourceId; + + /* + * The user-assigned managed identity used for outbound connections. If an authResourceId is provided and it's not + * specified, the system-assigned managed identity is used. On updates to the indexer, if the identity is + * unspecified, the value remains unchanged. If set to "none", the value of this property is cleared. + */ + private SearchIndexerDataIdentity authIdentity; + /** * Creates an instance of WebApiSkill class. * @@ -176,6 +192,60 @@ public WebApiSkill setDegreeOfParallelism(Integer degreeOfParallelism) { return this; } + /** + * Get the authResourceId property: Applies to custom skills that connect to external code in an Azure function or + * some other application that provides the transformations. This value should be the application ID created for the + * function or app when it was registered with Azure Active Directory. When specified, the custom skill connects to + * the function or app using a managed ID (either system or user-assigned) of the search service and the access + * token of the function or app, using this value as the resource id for creating the scope of the access token. + * + * @return the authResourceId value. + */ + public String getAuthResourceId() { + return this.authResourceId; + } + + /** + * Set the authResourceId property: Applies to custom skills that connect to external code in an Azure function or + * some other application that provides the transformations. This value should be the application ID created for the + * function or app when it was registered with Azure Active Directory. When specified, the custom skill connects to + * the function or app using a managed ID (either system or user-assigned) of the search service and the access + * token of the function or app, using this value as the resource id for creating the scope of the access token. + * + * @param authResourceId the authResourceId value to set. + * @return the WebApiSkill object itself. + */ + public WebApiSkill setAuthResourceId(String authResourceId) { + this.authResourceId = authResourceId; + return this; + } + + /** + * Get the authIdentity property: The user-assigned managed identity used for outbound connections. If an + * authResourceId is provided and it's not specified, the system-assigned managed identity is used. On updates to + * the indexer, if the identity is unspecified, the value remains unchanged. If set to "none", the value of this + * property is cleared. + * + * @return the authIdentity value. + */ + public SearchIndexerDataIdentity getAuthIdentity() { + return this.authIdentity; + } + + /** + * Set the authIdentity property: The user-assigned managed identity used for outbound connections. If an + * authResourceId is provided and it's not specified, the system-assigned managed identity is used. On updates to + * the indexer, if the identity is unspecified, the value remains unchanged. If set to "none", the value of this + * property is cleared. + * + * @param authIdentity the authIdentity value to set. + * @return the WebApiSkill object itself. + */ + public WebApiSkill setAuthIdentity(SearchIndexerDataIdentity authIdentity) { + this.authIdentity = authIdentity; + return this; + } + /** {@inheritDoc} */ @Override public WebApiSkill setName(String name) { @@ -212,6 +282,8 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStringField("timeout", Objects.toString(this.timeout, null)); jsonWriter.writeNumberField("batchSize", this.batchSize); jsonWriter.writeNumberField("degreeOfParallelism", this.degreeOfParallelism); + jsonWriter.writeStringField("authResourceId", this.authResourceId); + jsonWriter.writeJsonField("authIdentity", this.authIdentity); return jsonWriter.writeEndObject(); } @@ -242,6 +314,8 @@ public static WebApiSkill fromJson(JsonReader jsonReader) throws IOException { Duration timeout = null; Integer batchSize = null; Integer degreeOfParallelism = null; + String authResourceId = null; + SearchIndexerDataIdentity authIdentity = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); @@ -281,6 +355,10 @@ public static WebApiSkill fromJson(JsonReader jsonReader) throws IOException { batchSize = reader.getNullable(JsonReader::getInt); } else if ("degreeOfParallelism".equals(fieldName)) { degreeOfParallelism = reader.getNullable(JsonReader::getInt); + } else if ("authResourceId".equals(fieldName)) { + authResourceId = reader.getString(); + } else if ("authIdentity".equals(fieldName)) { + authIdentity = SearchIndexerDataIdentity.fromJson(reader); } else { reader.skipChildren(); } @@ -295,6 +373,8 @@ public static WebApiSkill fromJson(JsonReader jsonReader) throws IOException { deserializedWebApiSkill.timeout = timeout; deserializedWebApiSkill.batchSize = batchSize; deserializedWebApiSkill.degreeOfParallelism = degreeOfParallelism; + deserializedWebApiSkill.authResourceId = authResourceId; + deserializedWebApiSkill.authIdentity = authIdentity; return deserializedWebApiSkill; } diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/DocumentDebugInfo.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/DocumentDebugInfo.java new file mode 100644 index 0000000000000..54285b2a2e71a --- /dev/null +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/DocumentDebugInfo.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package com.azure.search.documents.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** Contains debugging information that can be used to further explore your search results. */ +@Immutable +public final class DocumentDebugInfo implements JsonSerializable { + /* + * Contains debugging information specific to semantic search queries. + */ + private SemanticDebugInfo semantic; + + /** Creates an instance of DocumentDebugInfo class. */ + public DocumentDebugInfo() {} + + /** + * Get the semantic property: Contains debugging information specific to semantic search queries. + * + * @return the semantic value. + */ + public SemanticDebugInfo getSemantic() { + return this.semantic; + } + + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("semantic", this.semantic); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DocumentDebugInfo from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DocumentDebugInfo if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the DocumentDebugInfo. + */ + public static DocumentDebugInfo fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject( + reader -> { + DocumentDebugInfo deserializedDocumentDebugInfo = new DocumentDebugInfo(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("semantic".equals(fieldName)) { + deserializedDocumentDebugInfo.semantic = SemanticDebugInfo.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedDocumentDebugInfo; + }); + } +} diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/QueryAnswerType.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/QueryAnswerType.java index 14870883e59f0..d113ee5027b4c 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/QueryAnswerType.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/QueryAnswerType.java @@ -13,7 +13,9 @@ * This parameter is only valid if the query type is 'semantic'. If set, the query returns answers extracted from key * passages in the highest ranked documents. The number of answers returned can be configured by appending the pipe * character '|' followed by the 'count-<number of answers>' option after the answers parameter value, such as - * 'extractive|count-3'. Default count is 1. + * 'extractive|count-3'. Default count is 1. The confidence threshold can be configured by appending the pipe character + * '|' followed by the 'threshold-<confidence threshold>' option after the answers parameter value, such as + * 'extractive|threshold-0.9'. Default threshold is 0.7. */ public final class QueryAnswerType extends ExpandableStringEnum { /** Do not return answers for the query. */ diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/QueryDebugMode.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/QueryDebugMode.java new file mode 100644 index 0000000000000..ec3a9aa41fa21 --- /dev/null +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/QueryDebugMode.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package com.azure.search.documents.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** Enables a debugging tool that can be used to further explore your search results. */ +public final class QueryDebugMode extends ExpandableStringEnum { + /** No query debugging information will be returned. */ + public static final QueryDebugMode DISABLED = fromString("disabled"); + + /** Allows the user to further explore their Semantic search results. */ + public static final QueryDebugMode SEMANTIC = fromString("semantic"); + + /** + * Creates a new instance of QueryDebugMode value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public QueryDebugMode() {} + + /** + * Creates or finds a QueryDebugMode from its string representation. + * + * @param name a name to look for. + * @return the corresponding QueryDebugMode. + */ + public static QueryDebugMode fromString(String name) { + return fromString(name, QueryDebugMode.class); + } + + /** + * Gets known QueryDebugMode values. + * + * @return known QueryDebugMode values. + */ + public static Collection values() { + return values(QueryDebugMode.class); + } +} diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/QueryResultDocumentRerankerInput.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/QueryResultDocumentRerankerInput.java new file mode 100644 index 0000000000000..37b9dff0e0f8e --- /dev/null +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/QueryResultDocumentRerankerInput.java @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package com.azure.search.documents.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** The raw concatenated strings that were sent to the semantic enrichment process. */ +@Immutable +public final class QueryResultDocumentRerankerInput implements JsonSerializable { + /* + * The raw string for the title field that was used for semantic enrichment. + */ + private String title; + + /* + * The raw concatenated strings for the content fields that were used for semantic enrichment. + */ + private String content; + + /* + * The raw concatenated strings for the keyword fields that were used for semantic enrichment. + */ + private String keywords; + + /** Creates an instance of QueryResultDocumentRerankerInput class. */ + public QueryResultDocumentRerankerInput() {} + + /** + * Get the title property: The raw string for the title field that was used for semantic enrichment. + * + * @return the title value. + */ + public String getTitle() { + return this.title; + } + + /** + * Get the content property: The raw concatenated strings for the content fields that were used for semantic + * enrichment. + * + * @return the content value. + */ + public String getContent() { + return this.content; + } + + /** + * Get the keywords property: The raw concatenated strings for the keyword fields that were used for semantic + * enrichment. + * + * @return the keywords value. + */ + public String getKeywords() { + return this.keywords; + } + + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("title", this.title); + jsonWriter.writeStringField("content", this.content); + jsonWriter.writeStringField("keywords", this.keywords); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of QueryResultDocumentRerankerInput from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of QueryResultDocumentRerankerInput if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the QueryResultDocumentRerankerInput. + */ + public static QueryResultDocumentRerankerInput fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject( + reader -> { + QueryResultDocumentRerankerInput deserializedQueryResultDocumentRerankerInput = + new QueryResultDocumentRerankerInput(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("title".equals(fieldName)) { + deserializedQueryResultDocumentRerankerInput.title = reader.getString(); + } else if ("content".equals(fieldName)) { + deserializedQueryResultDocumentRerankerInput.content = reader.getString(); + } else if ("keywords".equals(fieldName)) { + deserializedQueryResultDocumentRerankerInput.keywords = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedQueryResultDocumentRerankerInput; + }); + } +} diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/QueryResultDocumentSemanticField.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/QueryResultDocumentSemanticField.java new file mode 100644 index 0000000000000..7206c4336028b --- /dev/null +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/QueryResultDocumentSemanticField.java @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package com.azure.search.documents.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.search.documents.implementation.models.QueryResultDocumentSemanticFieldState; +import java.io.IOException; +import java.util.Objects; + +/** Description of fields that were sent to the semantic enrichment process, as well as how they were used. */ +@Immutable +public final class QueryResultDocumentSemanticField implements JsonSerializable { + /* + * The name of the field that was sent to the semantic enrichment process + */ + private String name; + + /* + * The way the field was used for the semantic enrichment process (fully used, partially used, or unused) + */ + private QueryResultDocumentSemanticFieldState state; + + /** Creates an instance of QueryResultDocumentSemanticField class. */ + public QueryResultDocumentSemanticField() {} + + /** + * Get the name property: The name of the field that was sent to the semantic enrichment process. + * + * @return the name value. + */ + public String getName() { + return this.name; + } + + /** + * Get the state property: The way the field was used for the semantic enrichment process (fully used, partially + * used, or unused). + * + * @return the state value. + */ + public QueryResultDocumentSemanticFieldState getState() { + return this.state; + } + + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("state", Objects.toString(this.state, null)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of QueryResultDocumentSemanticField from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of QueryResultDocumentSemanticField if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the QueryResultDocumentSemanticField. + */ + public static QueryResultDocumentSemanticField fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject( + reader -> { + QueryResultDocumentSemanticField deserializedQueryResultDocumentSemanticField = + new QueryResultDocumentSemanticField(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedQueryResultDocumentSemanticField.name = reader.getString(); + } else if ("state".equals(fieldName)) { + deserializedQueryResultDocumentSemanticField.state = + QueryResultDocumentSemanticFieldState.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedQueryResultDocumentSemanticField; + }); + } +} diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SearchOptions.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SearchOptions.java index 617c6782bc706..de50f76245f12 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SearchOptions.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SearchOptions.java @@ -98,6 +98,22 @@ public final class SearchOptions { */ private String semanticConfigurationName; + /* + * Allows the user to choose whether a semantic call should fail completely, or to return partial results. + */ + private SemanticErrorHandling semanticErrorHandling; + + /* + * Allows the user to set an upper bound on the amount of time it takes for semantic enrichment to finish + * processing before the request fails. + */ + private Integer semanticMaxWaitInMilliseconds; + + /* + * Enables a debugging tool that can be used to further explore your search results. + */ + private QueryDebugMode debug; + /* * The list of field names to which to scope the full-text search. When * using fielded search (fieldName:searchExpression) in a full Lucene @@ -122,7 +138,10 @@ public final class SearchOptions { * ranked documents. The number of answers returned can be configured by * appending the pipe character '|' followed by the 'count-' option after the answers parameter value, such as - * 'extractive|count-3'. Default count is 1. + * 'extractive|count-3'. Default count is 1. The confidence threshold can + * be configured by appending the pipe character '|' followed by the + * 'threshold-' option after the answers parameter + * value, such as 'extractive|threshold-0.9'. Default threshold is 0.7. */ private QueryAnswerType answers; @@ -136,6 +155,15 @@ public final class SearchOptions { */ private Integer answersCount; + /* + * This parameter is only valid if the query type is 'semantic'. + * The confidence threshold can be configured by appending the pipe + * character '|' followed by the 'threshold-' + * option after the answers parameter value, such as + * 'extractive|threshold-0.9'. Default threshold is 0.7. + */ + private Double answerThreshold; + /* * A value that specifies whether any or all of the search terms must be * matched in order to count the document as a match. @@ -490,6 +518,70 @@ public SearchOptions setSemanticConfigurationName(String semanticConfigurationNa return this; } + /** + * Get the semanticErrorHandling property: Allows the user to choose whether a semantic call should fail completely, + * or to return partial results. + * + * @return the semanticErrorHandling value. + */ + public SemanticErrorHandling getSemanticErrorHandling() { + return this.semanticErrorHandling; + } + + /** + * Set the semanticErrorHandling property: Allows the user to choose whether a semantic call should fail completely, + * or to return partial results. + * + * @param semanticErrorHandling the semanticErrorHandling value to set. + * @return the SearchOptions object itself. + */ + public SearchOptions setSemanticErrorHandling(SemanticErrorHandling semanticErrorHandling) { + this.semanticErrorHandling = semanticErrorHandling; + return this; + } + + /** + * Get the semanticMaxWaitInMilliseconds property: Allows the user to set an upper bound on the amount of time it + * takes for semantic enrichment to finish processing before the request fails. + * + * @return the semanticMaxWaitInMilliseconds value. + */ + public Integer getSemanticMaxWaitInMilliseconds() { + return this.semanticMaxWaitInMilliseconds; + } + + /** + * Set the semanticMaxWaitInMilliseconds property: Allows the user to set an upper bound on the amount of time it + * takes for semantic enrichment to finish processing before the request fails. + * + * @param semanticMaxWaitInMilliseconds the semanticMaxWaitInMilliseconds value to set. + * @return the SearchOptions object itself. + */ + public SearchOptions setSemanticMaxWaitInMilliseconds(Integer semanticMaxWaitInMilliseconds) { + this.semanticMaxWaitInMilliseconds = semanticMaxWaitInMilliseconds; + return this; + } + + /** + * Get the debug property: Enables a debugging tool that can be used to further explore your search results. + * + * @return the debug value. + */ + public QueryDebugMode getDebug() { + return this.debug; + } + + /** + * Set the debug property: Enables a debugging tool that can be used to further explore your search results. + * + * @param debug the debug value to set. + * @return the SearchOptions object itself. + */ + public SearchOptions setDebug(QueryDebugMode debug) { + this.debug = debug; + return this; + } + /** * Get the searchFields property: The list of field names to which to scope the full-text search. When using fielded * search (fieldName:searchExpression) in a full Lucene query, the field names of each fielded search expression @@ -558,7 +650,9 @@ public SearchOptions setSpeller(QuerySpellerType speller) { * Get the answers property: This parameter is only valid if the query type is 'semantic'. If set, the query returns * answers extracted from key passages in the highest ranked documents. The number of answers returned can be * configured by appending the pipe character '|' followed by the 'count-<number of answers>' option after the - * answers parameter value, such as 'extractive|count-3'. Default count is 1. + * answers parameter value, such as 'extractive|count-3'. Default count is 1. The confidence threshold can be + * configured by appending the pipe character '|' followed by the 'threshold-<confidence threshold>' option + * after the answers parameter value, such as 'extractive|threshold-0.9'. Default threshold is 0.7. * * @return the answers value. */ @@ -570,7 +664,9 @@ public QueryAnswerType getAnswers() { * Set the answers property: This parameter is only valid if the query type is 'semantic'. If set, the query returns * answers extracted from key passages in the highest ranked documents. The number of answers returned can be * configured by appending the pipe character '|' followed by the 'count-<number of answers>' option after the - * answers parameter value, such as 'extractive|count-3'. Default count is 1. + * answers parameter value, such as 'extractive|count-3'. Default count is 1. The confidence threshold can be + * configured by appending the pipe character '|' followed by the 'threshold-<confidence threshold>' option + * after the answers parameter value, such as 'extractive|threshold-0.9'. Default threshold is 0.7. * * @param answers the answers value to set. * @return the SearchOptions object itself. @@ -606,6 +702,33 @@ public SearchOptions setAnswersCount(Integer answersCount) { return this; } + /** + * Get the answer threshold property: This parameter is only valid if the query type is 'semantic'. + * The confidence threshold can be configured by appending the pipe + * character '|' followed by the 'threshold-<confidence threshold>' + * option after the answers parameter value, such as + * 'extractive|threshold-0.9'. Default threshold is 0.7. + * + * @return the answer threshold value. + */ + public Double getAnswerThreshold() { + return this.answerThreshold; + } + + /** + * Set the answer threshold property: This parameter is only valid if the query type is 'semantic'. + * The confidence threshold can be configured by appending the pipe + * character '|' followed by the 'threshold-<confidence threshold>' + * option after the answers parameter value, such as + * 'extractive|threshold-0.9'. Default threshold is 0.7. + * @param answerThreshold the answer threshold value to set. + * @return the SearchOptions object itself. + */ + public SearchOptions setAnswerThreshold(Double answerThreshold) { + this.answerThreshold = answerThreshold; + return this; + } + /** * Get the searchMode property: A value that specifies whether any or all of the search terms must be matched in * order to count the document as a match. diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SearchResult.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SearchResult.java index ea41b5f7795e3..ceed5f4ff42f3 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SearchResult.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SearchResult.java @@ -47,6 +47,11 @@ public final class SearchResult { */ private List captions; + /* + * Contains debugging information that can be used to further explore your search results. + */ + private List documentDebugInfo; + /* * Contains a document found by a search query, plus associated metadata. */ @@ -80,6 +85,11 @@ public void setRerankerScore(SearchResult searchResult, Double rerankerScore) { public void setCaptions(SearchResult searchResult, List captions) { searchResult.setCaptions(captions); } + + @Override + public void setDocumentDebugInfo(SearchResult searchResult, List documentDebugInfo) { + searchResult.setDocumentDebugInfo(documentDebugInfo); + } }); } @@ -133,6 +143,16 @@ public List getCaptions() { return this.captions; } + /** + * Get the documentDebugInfo property: Contains debugging information that can be used to further explore your + * search results. + * + * @return the documentDebugInfo value. + */ + public List getDocumentDebugInfo() { + return this.documentDebugInfo; + } + /** * Get the additionalProperties property: Unmatched properties from the message are deserialized this collection. * @@ -190,4 +210,13 @@ private void setRerankerScore(Double rerankerScore) { private void setCaptions(List captions) { this.captions = captions; } + + /** + * The private setter to set the documentDebugInfo property via {@code SearchResultHelper.setDocumentDebugInfo}. + * + * @param documentDebugInfo The document debug info. + */ + private void setDocumentDebugInfo(List documentDebugInfo) { + this.documentDebugInfo = documentDebugInfo; + } } diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SemanticDebugInfo.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SemanticDebugInfo.java new file mode 100644 index 0000000000000..77414d72b144b --- /dev/null +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SemanticDebugInfo.java @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package com.azure.search.documents.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** The SemanticDebugInfo model. */ +@Immutable +public final class SemanticDebugInfo implements JsonSerializable { + /* + * The title field that was sent to the semantic enrichment process, as well as how it was used + */ + private QueryResultDocumentSemanticField titleField; + + /* + * The content fields that were sent to the semantic enrichment process, as well as how they were used + */ + private List contentFields; + + /* + * The keyword fields that were sent to the semantic enrichment process, as well as how they were used + */ + private List keywordFields; + + /* + * The raw concatenated strings that were sent to the semantic enrichment process. + */ + private QueryResultDocumentRerankerInput rerankerInput; + + /** Creates an instance of SemanticDebugInfo class. */ + public SemanticDebugInfo() {} + + /** + * Get the titleField property: The title field that was sent to the semantic enrichment process, as well as how it + * was used. + * + * @return the titleField value. + */ + public QueryResultDocumentSemanticField getTitleField() { + return this.titleField; + } + + /** + * Get the contentFields property: The content fields that were sent to the semantic enrichment process, as well as + * how they were used. + * + * @return the contentFields value. + */ + public List getContentFields() { + return this.contentFields; + } + + /** + * Get the keywordFields property: The keyword fields that were sent to the semantic enrichment process, as well as + * how they were used. + * + * @return the keywordFields value. + */ + public List getKeywordFields() { + return this.keywordFields; + } + + /** + * Get the rerankerInput property: The raw concatenated strings that were sent to the semantic enrichment process. + * + * @return the rerankerInput value. + */ + public QueryResultDocumentRerankerInput getRerankerInput() { + return this.rerankerInput; + } + + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("titleField", this.titleField); + jsonWriter.writeArrayField("contentFields", this.contentFields, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("keywordFields", this.keywordFields, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("rerankerInput", this.rerankerInput); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SemanticDebugInfo from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SemanticDebugInfo if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the SemanticDebugInfo. + */ + public static SemanticDebugInfo fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject( + reader -> { + SemanticDebugInfo deserializedSemanticDebugInfo = new SemanticDebugInfo(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("titleField".equals(fieldName)) { + deserializedSemanticDebugInfo.titleField = + QueryResultDocumentSemanticField.fromJson(reader); + } else if ("contentFields".equals(fieldName)) { + List contentFields = + reader.readArray(reader1 -> QueryResultDocumentSemanticField.fromJson(reader1)); + deserializedSemanticDebugInfo.contentFields = contentFields; + } else if ("keywordFields".equals(fieldName)) { + List keywordFields = + reader.readArray(reader1 -> QueryResultDocumentSemanticField.fromJson(reader1)); + deserializedSemanticDebugInfo.keywordFields = keywordFields; + } else if ("rerankerInput".equals(fieldName)) { + deserializedSemanticDebugInfo.rerankerInput = + QueryResultDocumentRerankerInput.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedSemanticDebugInfo; + }); + } +} diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SemanticErrorHandling.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SemanticErrorHandling.java new file mode 100644 index 0000000000000..c632d88089751 --- /dev/null +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SemanticErrorHandling.java @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package com.azure.search.documents.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** Allows the user to choose whether a semantic call should fail completely, or to return partial results. */ +public final class SemanticErrorHandling extends ExpandableStringEnum { + /** + * If the semantic processing fails, partial results still return. The definition of partial results depends on what + * semantic step failed and what was the reason for failure. + */ + public static final SemanticErrorHandling PARTIAL = fromString("partial"); + + /** + * If there is an exception during the semantic processing step, the query will fail and return the appropriate HTTP + * code depending on the error. + */ + public static final SemanticErrorHandling FAIL = fromString("fail"); + + /** + * Creates a new instance of SemanticErrorHandling value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public SemanticErrorHandling() {} + + /** + * Creates or finds a SemanticErrorHandling from its string representation. + * + * @param name a name to look for. + * @return the corresponding SemanticErrorHandling. + */ + public static SemanticErrorHandling fromString(String name) { + return fromString(name, SemanticErrorHandling.class); + } + + /** + * Gets known SemanticErrorHandling values. + * + * @return known SemanticErrorHandling values. + */ + public static Collection values() { + return values(SemanticErrorHandling.class); + } +} diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SemanticPartialResponseReason.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SemanticPartialResponseReason.java new file mode 100644 index 0000000000000..90343c761e803 --- /dev/null +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SemanticPartialResponseReason.java @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package com.azure.search.documents.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** Reason that a partial response was returned for a semantic search request. */ +public final class SemanticPartialResponseReason extends ExpandableStringEnum { + /** + * If 'semanticMaxWaitInMilliseconds' was set and the semantic processing duration exceeded that value. Only the + * base results were returned. + */ + public static final SemanticPartialResponseReason MAX_WAIT_EXCEEDED = fromString("maxWaitExceeded"); + + /** The request was throttled. Only the base results were returned. */ + public static final SemanticPartialResponseReason CAPACITY_OVERLOADED = fromString("capacityOverloaded"); + + /** At least one step of the semantic process failed. */ + public static final SemanticPartialResponseReason TRANSIENT = fromString("transient"); + + /** + * Creates a new instance of SemanticPartialResponseReason value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public SemanticPartialResponseReason() {} + + /** + * Creates or finds a SemanticPartialResponseReason from its string representation. + * + * @param name a name to look for. + * @return the corresponding SemanticPartialResponseReason. + */ + public static SemanticPartialResponseReason fromString(String name) { + return fromString(name, SemanticPartialResponseReason.class); + } + + /** + * Gets known SemanticPartialResponseReason values. + * + * @return known SemanticPartialResponseReason values. + */ + public static Collection values() { + return values(SemanticPartialResponseReason.class); + } +} diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SemanticPartialResponseType.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SemanticPartialResponseType.java new file mode 100644 index 0000000000000..abe11ca072563 --- /dev/null +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SemanticPartialResponseType.java @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package com.azure.search.documents.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** Type of partial response that was returned for a semantic search request. */ +public final class SemanticPartialResponseType extends ExpandableStringEnum { + /** Results without any semantic enrichment or reranking. */ + public static final SemanticPartialResponseType BASE_RESULTS = fromString("baseResults"); + + /** + * Results have been reranked with the reranker model and will include semantic captions. They will not include any + * answers, answers highlights or caption highlights. + */ + public static final SemanticPartialResponseType RERANKED_RESULTS = fromString("rerankedResults"); + + /** + * Creates a new instance of SemanticPartialResponseType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public SemanticPartialResponseType() {} + + /** + * Creates or finds a SemanticPartialResponseType from its string representation. + * + * @param name a name to look for. + * @return the corresponding SemanticPartialResponseType. + */ + public static SemanticPartialResponseType fromString(String name) { + return fromString(name, SemanticPartialResponseType.class); + } + + /** + * Gets known SemanticPartialResponseType values. + * + * @return known SemanticPartialResponseType values. + */ + public static Collection values() { + return values(SemanticPartialResponseType.class); + } +} diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/util/SearchPagedFlux.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/util/SearchPagedFlux.java index 15fbe528ef006..7194349e518fa 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/util/SearchPagedFlux.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/util/SearchPagedFlux.java @@ -7,6 +7,8 @@ import com.azure.core.util.paging.ContinuablePagedFlux; import com.azure.search.documents.implementation.models.SearchFirstPageResponseWrapper; import com.azure.search.documents.implementation.models.SearchRequest; +import com.azure.search.documents.models.SemanticPartialResponseReason; +import com.azure.search.documents.models.SemanticPartialResponseType; import com.azure.search.documents.models.AnswerResult; import com.azure.search.documents.models.FacetResult; import com.azure.search.documents.models.SearchResult; @@ -118,4 +120,32 @@ public Mono> getAnswers() { return Mono.just(metaData.getFirstPageResponse().getAnswers()); }); } + + /** + * The reason for a partial result returned by Azure Cognitive Search. + * @return The reason for a partial result returned by Azure Cognitive Search. + */ + public Mono getSemanticPartialResponseReason() { + return metadataSupplier.get() + .flatMap(metaData -> { + if (metaData.getFirstPageResponse().getSemanticPartialResponseReason() == null) { + return Mono.empty(); + } + return Mono.just(metaData.getFirstPageResponse().getSemanticPartialResponseReason()); + }); + } + + /** + * The type of the partial result returned by Azure Cognitive Search. + * @return The type of the partial result returned by Azure Cognitive Search. + */ + public Mono getSemanticPartialResponseType() { + return metadataSupplier.get() + .flatMap(metaData -> { + if (metaData.getFirstPageResponse().getSemanticPartialResponseType() == null) { + return Mono.empty(); + } + return Mono.just(metaData.getFirstPageResponse().getSemanticPartialResponseType()); + }); + } } diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/util/SearchPagedIterable.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/util/SearchPagedIterable.java index d40401d4dfd06..238ad0f7bd4f2 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/util/SearchPagedIterable.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/util/SearchPagedIterable.java @@ -8,6 +8,8 @@ import com.azure.core.util.paging.PageRetrieverSync; import com.azure.search.documents.implementation.models.SearchFirstPageResponseWrapper; import com.azure.search.documents.implementation.models.SearchRequest; +import com.azure.search.documents.models.SemanticPartialResponseReason; +import com.azure.search.documents.models.SemanticPartialResponseType; import com.azure.search.documents.models.AnswerResult; import com.azure.search.documents.models.FacetResult; import com.azure.search.documents.models.SearchResult; @@ -127,4 +129,22 @@ public List getAnswers() { return metadataSupplier != null ? metadataSupplier.get().getFirstPageResponse().getAnswers() : pagedFlux.getAnswers().block(); } + + /** + * The reason for a partial result returned by Azure Cognitive Search. + * @return The reason for a partial result returned by Azure Cognitive Search. + */ + public SemanticPartialResponseReason getSemanticPartialResponseReason() { + return metadataSupplier != null ? metadataSupplier.get().getFirstPageResponse().getSemanticPartialResponseReason() + : pagedFlux.getSemanticPartialResponseReason().block(); + } + + /** + * The type of the partial result returned by Azure Cognitive Search. + * @return The type of the partial result returned by Azure Cognitive Search. + */ + public SemanticPartialResponseType getSemanticPartialResponseType() { + return metadataSupplier != null ? metadataSupplier.get().getFirstPageResponse().getSemanticPartialResponseType() + : pagedFlux.getSemanticPartialResponseType().block(); + } } diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/util/SearchPagedResponse.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/util/SearchPagedResponse.java index 29d4cad460287..efa96490bd7ca 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/util/SearchPagedResponse.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/util/SearchPagedResponse.java @@ -7,6 +7,8 @@ import com.azure.core.http.rest.Page; import com.azure.core.http.rest.PagedResponseBase; import com.azure.core.http.rest.Response; +import com.azure.search.documents.models.SemanticPartialResponseReason; +import com.azure.search.documents.models.SemanticPartialResponseType; import com.azure.search.documents.implementation.util.SearchPagedResponseAccessHelper; import com.azure.search.documents.models.AnswerResult; import com.azure.search.documents.models.FacetResult; @@ -29,6 +31,8 @@ public final class SearchPagedResponse extends PagedResponseBase> facets; private final List answers; + private final SemanticPartialResponseReason semanticPartialResponseReason; + private final SemanticPartialResponseType semanticPartialResponseType; static { SearchPagedResponseAccessHelper.setAccessor(new SearchPagedResponseAccessHelper.SearchPagedResponseAccessor() { @@ -51,6 +55,18 @@ public Long getCount(SearchPagedResponse response) { public List getAnswers(SearchPagedResponse response) { return response.getAnswers(); } + + @Override + public SemanticPartialResponseReason getSemanticPartialResponseReason(SearchPagedResponse response) { + return response.getSemanticPartialResponseReason(); + } + + @Override + public SemanticPartialResponseType getSemanticPartialResponseType(SearchPagedResponse response) { + return response.getSemanticPartialResponseType(); + } + + }); } @@ -65,9 +81,11 @@ public List getAnswers(SearchPagedResponse response) { */ public SearchPagedResponse(Response> response, String continuationToken, Map> facets, Long count, Double coverage) { - this(response, continuationToken, facets, count, coverage, null); + this(response, continuationToken, facets, count, coverage, null, null, null); } + + /** * Constructor * @@ -77,9 +95,12 @@ public SearchPagedResponse(Response> response, String continu * @param count Total number of documents available as a result for the search. * @param coverage Percent of the index used in the search operation. * @param answers Answers contained in the search. + * @param semanticPartialResponseReason Reason that a partial response was returned for a semantic search request. + * @param semanticPartialResponseType Type of the partial response returned for a semantic search request. */ public SearchPagedResponse(Response> response, String continuationToken, - Map> facets, Long count, Double coverage, List answers) { + Map> facets, Long count, Double coverage, List answers, + SemanticPartialResponseReason semanticPartialResponseReason, SemanticPartialResponseType semanticPartialResponseType) { super(response.getRequest(), response.getStatusCode(), response.getHeaders(), response.getValue(), continuationToken, null); @@ -88,6 +109,8 @@ public SearchPagedResponse(Response> response, String continu this.count = count; this.coverage = coverage; this.answers = answers; + this.semanticPartialResponseReason = semanticPartialResponseReason; + this.semanticPartialResponseType = semanticPartialResponseType; } /** @@ -136,6 +159,24 @@ List getAnswers() { return answers; } + /** + * The reason that a partial response was returned for a semantic search request. + * + * @return Reason that a partial response was returned for a semantic search request if response was partial. + */ + SemanticPartialResponseReason getSemanticPartialResponseReason() { + return semanticPartialResponseReason; + } + + /** + * The type of the partial response returned for a semantic search request. + * + * @return Type of the partial response returned for a semantic search request if response was partial. + */ + SemanticPartialResponseType getSemanticPartialResponseType() { + return semanticPartialResponseType; + } + @Override public List getValue() { return value; diff --git a/sdk/search/azure-search-documents/swagger/README.md b/sdk/search/azure-search-documents/swagger/README.md index 2b343a8ff0905..7b517abf154aa 100644 --- a/sdk/search/azure-search-documents/swagger/README.md +++ b/sdk/search/azure-search-documents/swagger/README.md @@ -87,10 +87,10 @@ These settings apply only when `--tag=searchindex` is specified on the command l ``` yaml $(tag) == 'searchindex' namespace: com.azure.search.documents input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/932e261a870475e1a29115f62def7bb84e4d7b38/specification/search/data-plane/Azure.Search/preview/2021-04-30-Preview/searchindex.json +- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/0cfd102a6ecb172f04ec915732bd8ca6f6b2a7af/specification/search/data-plane/Azure.Search/preview/2023-07-01-Preview/searchindex.json models-subpackage: implementation.models custom-types-subpackage: models -custom-types: AnswerResult,AutocompleteItem,AutocompleteMode,AutocompleteOptions,AutocompleteResult,CaptionResult,FacetResult,IndexActionType,IndexDocumentsResult,IndexingResult,QueryAnswerType,QueryCaptionType,QueryLanguage,QuerySpellerType,QueryType,ScoringStatistics,SearchMode,SuggestOptions +custom-types: AnswerResult,AutocompleteItem,AutocompleteMode,AutocompleteOptions,AutocompleteResult,CaptionResult,FacetResult,IndexActionType,IndexDocumentsResult,IndexingResult,QueryAnswerType,QueryCaptionType,QueryLanguage,QuerySpellerType,QueryType,ScoringStatistics,SearchMode,SuggestOptions,DocumentDebugInfo,SemanticDebugInfo,QueryResultDocumentSemanticField,QueryResultDocumentRerankerInput,SemanticPartialResponseReason,SemanticPartialResponseType,SemanticErrorHandling,QueryDebugMode customization-class: src/main/java/SearchIndexCustomizations.java ``` @@ -101,7 +101,7 @@ These settings apply only when `--tag=searchservice` is specified on the command ``` yaml $(tag) == 'searchservice' namespace: com.azure.search.documents.indexes input-file: -- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/904899a23a417768ce1ec1d5f89f33817f8ef8ad/specification/search/data-plane/Azure.Search/preview/2021-04-30-Preview/searchservice.json +- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/0cfd102a6ecb172f04ec915732bd8ca6f6b2a7af/specification/search/data-plane/Azure.Search/preview/2023-07-01-Preview/searchservice.json models-subpackage: models custom-types-subpackage: implementation.models custom-types: AnalyzeRequest,AnalyzeResult,AzureActiveDirectoryApplicationCredentials,DataSourceCredentials,DocumentKeysOrIds,EdgeNGramTokenFilterV1,EdgeNGramTokenFilterV2,EntityRecognitionSkillV1,EntityRecognitionSkillV3,KeywordTokenizerV1,KeywordTokenizerV2,ListAliasesResult,ListDataSourcesResult,ListIndexersResult,ListIndexesResult,ListSkillsetsResult,ListSynonymMapsResult,LuceneStandardTokenizerV1,LuceneStandardTokenizerV2,NGramTokenFilterV1,NGramTokenFilterV2,RequestOptions,SearchError,SearchErrorException,SentimentSkillV1,SentimentSkillV3,SkillNames @@ -224,9 +224,10 @@ directive: $.SearchIndexerDataSourceConnection.required = $.SearchIndexerDataSourceConnection.required.filter(required => required === 'name'); $.SearchIndexerSkillset.required = $.SearchIndexerSkillset.required.filter(required => required === 'name'); delete $.SynonymMap.required; + $.ServiceCounters.required = $.ServiceCounters.required.filter(required => required !== 'aliasesCount' && required !== 'skillsetCount' && required !== 'vectorIndexSize'); ``` -### Renames +### Renames ``` yaml $(java) directive: - from: swagger-document