Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.azure.search.documents.implementation.SearchUtils;
import com.azure.search.documents.implementation.models.AutocompletePostRequest;
import com.azure.search.documents.implementation.models.SuggestPostRequest;
import com.azure.search.documents.models.AcceptHeaderNoneConstant;
import com.azure.search.documents.models.AutocompleteOptions;
import com.azure.search.documents.models.AutocompleteResult;
import com.azure.search.documents.models.IndexBatchException;
Expand Down Expand Up @@ -99,6 +100,14 @@ public SearchServiceVersion getServiceVersion() {

/**
* Sends a batch of document write actions to the index.
* <p><strong>Header Parameters</strong></p>
* <table border="1">
* <caption>Header Parameters</caption>
* <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
* <tr><td>Accept</td><td>String</td><td>No</td><td>The Accept header. Allowed values:
* "application/json;odata.metadata=none".</td></tr>
* </table>
* You can add these to a request with {@link RequestOptions#addHeader}
* <p><strong>Request Body Schema</strong></p>
*
* <pre>
Expand Down Expand Up @@ -163,7 +172,7 @@ Response<BinaryData> indexWithResponse(BinaryData batch, RequestOptions requestO
public long getDocumentCount() {
// Generated convenience method for hiddenGeneratedGetDocumentCountWithResponse
RequestOptions requestOptions = new RequestOptions();
return hiddenGeneratedGetDocumentCountWithResponse(requestOptions).getValue().toObject(Long.class);
return Long.parseLong(hiddenGeneratedGetDocumentCountWithResponse(requestOptions).getValue().toString());
}

/**
Expand Down Expand Up @@ -241,48 +250,6 @@ public SearchPagedIterable search(SearchOptions options, RequestOptions requestO
});
}

/**
* Retrieves a document from the index.
*
* @param key The key of the document to retrieve.
* @param querySourceAuthorization Token identifying the user for which the query is being executed. This token is
* used to enforce security restrictions on documents.
* @param enableElevatedRead A value that enables elevated read that bypass document level permission checks for the
* query operation.
* @param selectedFields List of field names to retrieve for the document; Any field not retrieved will be missing
* from the returned document.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a document retrieved via a document lookup operation.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public LookupDocument getDocument(String key, String querySourceAuthorization, Boolean enableElevatedRead,
List<String> selectedFields) {
// Generated convenience method for hiddenGeneratedGetDocumentWithResponse
RequestOptions requestOptions = new RequestOptions();
if (querySourceAuthorization != null) {
requestOptions.setHeader(HttpHeaderName.fromString("x-ms-query-source-authorization"),
querySourceAuthorization);
}
if (enableElevatedRead != null) {
requestOptions.setHeader(HttpHeaderName.fromString("x-ms-enable-elevated-read"),
String.valueOf(enableElevatedRead));
}
if (selectedFields != null) {
requestOptions.addQueryParam("$select",
selectedFields.stream()
.map(paramItemValue -> Objects.toString(paramItemValue, ""))
.collect(Collectors.joining(",")),
false);
}
return hiddenGeneratedGetDocumentWithResponse(key, requestOptions).getValue().toObject(LookupDocument.class);
}

/**
* Retrieves a document from the index.
*
Expand Down Expand Up @@ -384,6 +351,8 @@ public Response<IndexDocumentsResult> indexDocumentsWithResponse(IndexDocumentsB
* <table border="1">
* <caption>Header Parameters</caption>
* <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
* <tr><td>Accept</td><td>String</td><td>No</td><td>The Accept header. Allowed values:
* "application/json;odata.metadata=none".</td></tr>
* <tr><td>x-ms-query-source-authorization</td><td>String</td><td>No</td><td>Token identifying the user for which
* the query is being executed. This token is used to enforce security restrictions on documents.</td></tr>
* <tr><td>x-ms-enable-elevated-read</td><td>Boolean</td><td>No</td><td>A value that enables elevated read that
Expand Down Expand Up @@ -675,6 +644,14 @@ Response<BinaryData> searchWithResponse(BinaryData searchPostRequest, RequestOpt

/**
* Suggests documents in the index that match the given partial query text.
* <p><strong>Header Parameters</strong></p>
* <table border="1">
* <caption>Header Parameters</caption>
* <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
* <tr><td>Accept</td><td>String</td><td>No</td><td>The Accept header. Allowed values:
* "application/json;odata.metadata=none".</td></tr>
* </table>
* You can add these to a request with {@link RequestOptions#addHeader}
* <p><strong>Request Body Schema</strong></p>
*
* <pre>
Expand Down Expand Up @@ -735,6 +712,14 @@ Response<BinaryData> suggestWithResponse(BinaryData suggestPostRequest, RequestO

/**
* Autocompletes incomplete query terms based on input text and matching terms in the index.
* <p><strong>Header Parameters</strong></p>
* <table border="1">
* <caption>Header Parameters</caption>
* <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
* <tr><td>Accept</td><td>String</td><td>No</td><td>The Accept header. Allowed values:
* "application/json;odata.metadata=none".</td></tr>
* </table>
* You can add these to a request with {@link RequestOptions#addHeader}
* <p><strong>Request Body Schema</strong></p>
*
* <pre>
Expand Down Expand Up @@ -803,6 +788,7 @@ Response<BinaryData> autocompleteWithResponse(BinaryData autocompletePostRequest
public SuggestDocumentsResult suggest(SuggestOptions options) {
// Generated convenience method for suggestWithResponse
RequestOptions requestOptions = new RequestOptions();
AcceptHeaderNoneConstant accept = options.getAccept();
SuggestPostRequest suggestPostRequestObj
= new SuggestPostRequest(options.getSearchText(), options.getSuggesterName()).setFilter(options.getFilter())
.setUseFuzzyMatching(options.isUseFuzzyMatching())
Expand All @@ -814,6 +800,9 @@ public SuggestDocumentsResult suggest(SuggestOptions options) {
.setSelect(options.getSelect())
.setTop(options.getTop());
BinaryData suggestPostRequest = BinaryData.fromObject(suggestPostRequestObj);
if (accept != null) {
requestOptions.setHeader(HttpHeaderName.ACCEPT, accept.toString());
}
return suggestWithResponse(suggestPostRequest, requestOptions).getValue()
.toObject(SuggestDocumentsResult.class);
}
Expand Down Expand Up @@ -864,6 +853,7 @@ public Response<SuggestDocumentsResult> suggestWithResponse(SuggestOptions optio
public AutocompleteResult autocomplete(AutocompleteOptions options) {
// Generated convenience method for autocompleteWithResponse
RequestOptions requestOptions = new RequestOptions();
AcceptHeaderNoneConstant accept = options.getAccept();
AutocompletePostRequest autocompletePostRequestObj
= new AutocompletePostRequest(options.getSearchText(), options.getSuggesterName())
.setAutocompleteMode(options.getAutocompleteMode())
Expand All @@ -875,6 +865,9 @@ public AutocompleteResult autocomplete(AutocompleteOptions options) {
.setSearchFields(options.getSearchFields())
.setTop(options.getTop());
BinaryData autocompletePostRequest = BinaryData.fromObject(autocompletePostRequestObj);
if (accept != null) {
requestOptions.setHeader(HttpHeaderName.ACCEPT, accept.toString());
}
return autocompleteWithResponse(autocompletePostRequest, requestOptions).getValue()
.toObject(AutocompleteResult.class);
}
Expand Down Expand Up @@ -963,6 +956,14 @@ public Response<LookupDocument> getDocumentWithResponse(String key, RequestOptio

/**
* Queries the number of documents in the index.
* <p><strong>Header Parameters</strong></p>
* <table border="1">
* <caption>Header Parameters</caption>
* <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
* <tr><td>Accept</td><td>String</td><td>No</td><td>The Accept header. Allowed values:
* "application/json;odata.metadata=none".</td></tr>
* </table>
* You can add these to a request with {@link RequestOptions#addHeader}
* <p><strong>Response Body Schema</strong></p>
*
* <pre>
Expand Down Expand Up @@ -999,6 +1000,8 @@ Response<BinaryData> hiddenGeneratedGetDocumentCountWithResponse(RequestOptions
* <table border="1">
* <caption>Header Parameters</caption>
* <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
* <tr><td>Accept</td><td>String</td><td>No</td><td>The Accept header. Allowed values:
* "application/json;odata.metadata=none".</td></tr>
* <tr><td>x-ms-query-source-authorization</td><td>String</td><td>No</td><td>Token identifying the user for which
* the query is being executed. This token is used to enforce security restrictions on documents.</td></tr>
* <tr><td>x-ms-enable-elevated-read</td><td>Boolean</td><td>No</td><td>A value that enables elevated read that
Expand Down Expand Up @@ -1030,4 +1033,98 @@ Response<BinaryData> hiddenGeneratedGetDocumentCountWithResponse(RequestOptions
Response<BinaryData> hiddenGeneratedGetDocumentWithResponse(String key, RequestOptions requestOptions) {
return this.serviceClient.getDocumentWithResponse(key, requestOptions);
}

/**
* Queries the number of documents in the index.
*
* @param accept The Accept header.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a 64-bit integer.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public long getDocumentCount(AcceptHeaderNoneConstant accept) {
// Generated convenience method for hiddenGeneratedGetDocumentCountWithResponse
RequestOptions requestOptions = new RequestOptions();
if (accept != null) {
requestOptions.setHeader(HttpHeaderName.ACCEPT, accept.toString());
}
return Long.parseLong(hiddenGeneratedGetDocumentCountWithResponse(requestOptions).getValue().toString());
}

/**
* Retrieves a document from the index.
*
* @param key The key of the document to retrieve.
* @param accept The Accept header.
* @param querySourceAuthorization Token identifying the user for which the query is being executed. This token is
* used to enforce security restrictions on documents.
* @param enableElevatedRead A value that enables elevated read that bypass document level permission checks for the
* query operation.
* @param selectedFields List of field names to retrieve for the document; Any field not retrieved will be missing
* from the returned document.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a document retrieved via a document lookup operation.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public LookupDocument getDocument(String key, AcceptHeaderNoneConstant accept, String querySourceAuthorization,
Boolean enableElevatedRead, List<String> selectedFields) {
// Generated convenience method for hiddenGeneratedGetDocumentWithResponse
RequestOptions requestOptions = new RequestOptions();
if (accept != null) {
requestOptions.setHeader(HttpHeaderName.ACCEPT, accept.toString());
}
if (querySourceAuthorization != null) {
requestOptions.setHeader(HttpHeaderName.fromString("x-ms-query-source-authorization"),
querySourceAuthorization);
}
if (enableElevatedRead != null) {
requestOptions.setHeader(HttpHeaderName.fromString("x-ms-enable-elevated-read"),
String.valueOf(enableElevatedRead));
}
if (selectedFields != null) {
requestOptions.addQueryParam("$select",
selectedFields.stream()
.map(paramItemValue -> Objects.toString(paramItemValue, ""))
.collect(Collectors.joining(",")),
false);
}
return hiddenGeneratedGetDocumentWithResponse(key, requestOptions).getValue().toObject(LookupDocument.class);
}

/**
* Sends a batch of document write actions to the index.
*
* @param batch The batch of index actions.
* @param accept The Accept header.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return response containing the status of operations for all documents in the indexing request.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
IndexDocumentsResult index(IndexDocumentsBatch batch, AcceptHeaderNoneConstant accept) {
// Generated convenience method for indexWithResponse
RequestOptions requestOptions = new RequestOptions();
if (accept != null) {
requestOptions.setHeader(HttpHeaderName.ACCEPT, accept.toString());
}
return indexWithResponse(BinaryData.fromObject(batch), requestOptions).getValue()
.toObject(IndexDocumentsResult.class);
}
}
Loading
Loading