azure-docs-sdk-java/docs-ref-autogen/com.azure.search.documents....

398 строки
59 KiB
YAML

### YamlMime:JavaType
uid: "com.azure.search.documents.SearchClient"
fullName: "com.azure.search.documents.SearchClient"
name: "SearchClient"
nameWithType: "SearchClient"
summary: "This class provides a client that contains the operations for querying an index and uploading, merging, or deleting documents in an Azure AI Search service."
inheritances:
- "<xref href=\"java.lang.Object?displayProperty=fullName\" data-throw-if-not-resolved=\"False\" />"
inheritedClassMethods:
- classRef: "java.lang.<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html\">Object</a>"
methodsRef:
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--\">clone</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-\">equals</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--\">finalize</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--\">getClass</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--\">hashCode</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--\">notify</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--\">notifyAll</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--\">toString</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--\">wait</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-\">wait</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-\">wait</a>"
syntax: "public final class **SearchClient**"
methods:
- uid: "com.azure.search.documents.SearchClient.<T>getDocument(java.lang.String,java.lang.Class<T>)"
fullName: "com.azure.search.documents.SearchClient.getDocument(String key, Class<T> modelClass)"
name: "getDocument(String key, Class<T> modelClass)"
nameWithType: "SearchClient.getDocument(String key, Class<T> modelClass)"
summary: "Retrieves a document from the Azure AI Search index."
parameters:
- description: "The key of the document to retrieve."
name: "key"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "The model class converts to."
name: "modelClass"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html\">Class</a>&lt;<xref href=\"T?alt=T&text=T\" data-throw-if-not-resolved=\"False\" />&gt;"
syntax: "public T <T>getDocument(String key, Class<T> modelClass)"
desc: "Retrieves a document from the Azure AI Search index.\n\nView [naming rules][] for guidelines on constructing valid document keys.\n\n**Code Sample**\n\nGet dynamic SearchDocument.\n\n```java\nSearchDocument result = SEARCH_CLIENT.getDocument(\"hotelId\", SearchDocument.class);\n for (Map.Entry<String, Object> keyValuePair : result.entrySet()) {\n System.out.printf(\"Document key %s, Document value %s\", keyValuePair.getKey(), keyValuePair.getValue());\n }\n```\n\n\n[naming rules]: https://docs.microsoft.com/rest/api/searchservice/Naming-rules"
returns:
description: "document object"
type: "<xref href=\"T?alt=T&text=T\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.search.documents.SearchClient.<T>getDocumentWithResponse(java.lang.String,java.lang.Class<T>,java.util.List<java.lang.String>,com.azure.core.util.Context)"
fullName: "com.azure.search.documents.SearchClient.getDocumentWithResponse(String key, Class<T> modelClass, List<String> selectedFields, Context context)"
name: "getDocumentWithResponse(String key, Class<T> modelClass, List<String> selectedFields, Context context)"
nameWithType: "SearchClient.getDocumentWithResponse(String key, Class<T> modelClass, List<String> selectedFields, Context context)"
summary: "Retrieves a document from the Azure AI Search index."
parameters:
- description: "The key of the document to retrieve."
name: "key"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "The model class converts to."
name: "modelClass"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html\">Class</a>&lt;<xref href=\"T?alt=T&text=T\" data-throw-if-not-resolved=\"False\" />&gt;"
- description: "List of field names to retrieve for the document; Any field not retrieved will have null or\n default as its corresponding property value in the returned object."
name: "selectedFields"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/util/List.html\">List</a>&lt;<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>&gt;"
- description: "additional context that is passed through the Http pipeline during the service call"
name: "context"
type: "<xref href=\"com.azure.core.util.Context?alt=com.azure.core.util.Context&text=Context\" data-throw-if-not-resolved=\"False\" />"
syntax: "public Response<T> <T>getDocumentWithResponse(String key, Class<T> modelClass, List<String> selectedFields, Context context)"
desc: "Retrieves a document from the Azure AI Search index.\n\nView [naming rules][] for guidelines on constructing valid document keys.\n\n**Code Sample**\n\nGet dynamic SearchDocument.\n\n```java\nResponse<SearchDocument> resultResponse = SEARCH_CLIENT.getDocumentWithResponse(\"hotelId\",\n SearchDocument.class, null, new Context(KEY_1, VALUE_1));\n System.out.println(\"The status code of the response is \" + resultResponse.getStatusCode());\n for (Map.Entry<String, Object> keyValuePair : resultResponse.getValue().entrySet()) {\n System.out.printf(\"Document key %s, Document value %s\", keyValuePair.getKey(), keyValuePair.getValue());\n }\n```\n\n\n[naming rules]: https://docs.microsoft.com/rest/api/searchservice/Naming-rules"
returns:
description: "response containing a document object"
type: "<xref href=\"com.azure.core.http.rest.Response?alt=com.azure.core.http.rest.Response&text=Response\" data-throw-if-not-resolved=\"False\" />&lt;<xref href=\"T?alt=T&text=T\" data-throw-if-not-resolved=\"False\" />&gt;"
- uid: "com.azure.search.documents.SearchClient.autocomplete(java.lang.String,java.lang.String)"
fullName: "com.azure.search.documents.SearchClient.autocomplete(String searchText, String suggesterName)"
name: "autocomplete(String searchText, String suggesterName)"
nameWithType: "SearchClient.autocomplete(String searchText, String suggesterName)"
summary: "Autocompletes incomplete query terms based on input text and matching terms in the index."
parameters:
- description: "search text"
name: "searchText"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "suggester name"
name: "suggesterName"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
syntax: "public AutocompletePagedIterable autocomplete(String searchText, String suggesterName)"
desc: "Autocompletes incomplete query terms based on input text and matching terms in the index.\n\n**Code Sample**\n\nAutocomplete text from documents in service.\n\n```java\nAutocompletePagedIterable autocompletePagedIterable = SEARCH_CLIENT.autocomplete(\"searchText\", \"sg\");\n for (AutocompleteItem result: autocompletePagedIterable) {\n System.out.printf(\"The complete term is %s\", result.getText());\n }\n```"
returns:
description: "auto complete result."
type: "<xref href=\"com.azure.search.documents.util.AutocompletePagedIterable?alt=com.azure.search.documents.util.AutocompletePagedIterable&text=AutocompletePagedIterable\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.search.documents.SearchClient.autocomplete(java.lang.String,java.lang.String,com.azure.search.documents.models.AutocompleteOptions,com.azure.core.util.Context)"
fullName: "com.azure.search.documents.SearchClient.autocomplete(String searchText, String suggesterName, AutocompleteOptions autocompleteOptions, Context context)"
name: "autocomplete(String searchText, String suggesterName, AutocompleteOptions autocompleteOptions, Context context)"
nameWithType: "SearchClient.autocomplete(String searchText, String suggesterName, AutocompleteOptions autocompleteOptions, Context context)"
summary: "Autocompletes incomplete query terms based on input text and matching terms in the index."
parameters:
- description: "search text"
name: "searchText"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "suggester name"
name: "suggesterName"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "autocomplete options"
name: "autocompleteOptions"
type: "<xref href=\"com.azure.search.documents.models.AutocompleteOptions?alt=com.azure.search.documents.models.AutocompleteOptions&text=AutocompleteOptions\" data-throw-if-not-resolved=\"False\" />"
- description: "additional context that is passed through the HTTP pipeline during the service call"
name: "context"
type: "<xref href=\"com.azure.core.util.Context?alt=com.azure.core.util.Context&text=Context\" data-throw-if-not-resolved=\"False\" />"
syntax: "public AutocompletePagedIterable autocomplete(String searchText, String suggesterName, AutocompleteOptions autocompleteOptions, Context context)"
desc: "Autocompletes incomplete query terms based on input text and matching terms in the index.\n\n**Code Sample**\n\nAutocomplete text from documents in service with option.\n\n```java\nAutocompletePagedIterable autocompletePagedIterable = SEARCH_CLIENT.autocomplete(\"searchText\", \"sg\",\n new AutocompleteOptions().setAutocompleteMode(AutocompleteMode.ONE_TERM_WITH_CONTEXT),\n new Context(KEY_1, VALUE_1));\n for (AutocompleteItem result: autocompletePagedIterable) {\n System.out.printf(\"The complete term is %s\", result.getText());\n }\n```"
returns:
description: "auto complete result."
type: "<xref href=\"com.azure.search.documents.util.AutocompletePagedIterable?alt=com.azure.search.documents.util.AutocompletePagedIterable&text=AutocompletePagedIterable\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.search.documents.SearchClient.deleteDocuments(java.lang.Iterable<?>)"
fullName: "com.azure.search.documents.SearchClient.deleteDocuments(Iterable<?> documents)"
name: "deleteDocuments(Iterable<?> documents)"
nameWithType: "SearchClient.deleteDocuments(Iterable<?> documents)"
summary: "Deletes a collection of documents from the target index."
parameters:
- description: "collection of documents to delete from the target Index. Fields other than the key are ignored."
name: "documents"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html\">Iterable</a>&lt;?&gt;"
syntax: "public IndexDocumentsResult deleteDocuments(Iterable<?> documents)"
desc: "Deletes a collection of documents from the target index.\n\n**Code Sample**\n\nDelete dynamic SearchDocument.\n\n```java\nSearchDocument searchDocument = new SearchDocument();\n searchDocument.put(\"hotelId\", \"1\");\n searchDocument.put(\"hotelName\", \"test\");\n IndexDocumentsResult result = SEARCH_CLIENT.deleteDocuments(Collections.singletonList(searchDocument));\n for (IndexingResult indexingResult : result.getResults()) {\n System.out.printf(\"Does document with key %s delete successfully? %b%n\", indexingResult.getKey(),\n indexingResult.isSucceeded());\n }\n```"
returns:
description: "document index result."
type: "<xref href=\"com.azure.search.documents.models.IndexDocumentsResult?alt=com.azure.search.documents.models.IndexDocumentsResult&text=IndexDocumentsResult\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.search.documents.SearchClient.deleteDocumentsWithResponse(java.lang.Iterable<?>,com.azure.search.documents.models.IndexDocumentsOptions,com.azure.core.util.Context)"
fullName: "com.azure.search.documents.SearchClient.deleteDocumentsWithResponse(Iterable<?> documents, IndexDocumentsOptions options, Context context)"
name: "deleteDocumentsWithResponse(Iterable<?> documents, IndexDocumentsOptions options, Context context)"
nameWithType: "SearchClient.deleteDocumentsWithResponse(Iterable<?> documents, IndexDocumentsOptions options, Context context)"
summary: "Deletes a collection of documents from the target index."
parameters:
- description: "collection of documents to delete from the target Index. Fields other than the key are ignored."
name: "documents"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html\">Iterable</a>&lt;?&gt;"
- description: "Options that allow specifying document indexing behavior."
name: "options"
type: "<xref href=\"com.azure.search.documents.models.IndexDocumentsOptions?alt=com.azure.search.documents.models.IndexDocumentsOptions&text=IndexDocumentsOptions\" data-throw-if-not-resolved=\"False\" />"
- description: "additional context that is passed through the Http pipeline during the service call"
name: "context"
type: "<xref href=\"com.azure.core.util.Context?alt=com.azure.core.util.Context&text=Context\" data-throw-if-not-resolved=\"False\" />"
syntax: "public Response<IndexDocumentsResult> deleteDocumentsWithResponse(Iterable<?> documents, IndexDocumentsOptions options, Context context)"
desc: "Deletes a collection of documents from the target index.\n\n**Code Sample**\n\nDelete dynamic SearchDocument.\n\n```java\nSearchDocument searchDocument = new SearchDocument();\n searchDocument.put(\"hotelId\", \"1\");\n searchDocument.put(\"hotelName\", \"test\");\n Response<IndexDocumentsResult> resultResponse = SEARCH_CLIENT.deleteDocumentsWithResponse(\n Collections.singletonList(searchDocument), null, new Context(KEY_1, VALUE_1));\n System.out.println(\"The status code of the response is \" + resultResponse.getStatusCode());\n for (IndexingResult indexingResult : resultResponse.getValue().getResults()) {\n System.out.printf(\"Does document with key %s delete successfully? %b%n\", indexingResult.getKey(),\n indexingResult.isSucceeded());\n }\n```"
returns:
description: "response containing a document index result."
type: "<xref href=\"com.azure.core.http.rest.Response?alt=com.azure.core.http.rest.Response&text=Response\" data-throw-if-not-resolved=\"False\" />&lt;<xref href=\"com.azure.search.documents.models.IndexDocumentsResult?alt=com.azure.search.documents.models.IndexDocumentsResult&text=IndexDocumentsResult\" data-throw-if-not-resolved=\"False\" />&gt;"
- uid: "com.azure.search.documents.SearchClient.getDocumentCount()"
fullName: "com.azure.search.documents.SearchClient.getDocumentCount()"
name: "getDocumentCount()"
nameWithType: "SearchClient.getDocumentCount()"
summary: "Queries the number of documents in the search index."
syntax: "public long getDocumentCount()"
desc: "Queries the number of documents in the search index.\n\n**Code Sample**\n\nGet document count.\n\n```java\nlong count = SEARCH_CLIENT.getDocumentCount();\n System.out.printf(\"There are %d documents in service.\", count);\n```"
returns:
description: "the number of documents."
type: "<xref href=\"long?alt=long&text=long\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.search.documents.SearchClient.getDocumentCountWithResponse(com.azure.core.util.Context)"
fullName: "com.azure.search.documents.SearchClient.getDocumentCountWithResponse(Context context)"
name: "getDocumentCountWithResponse(Context context)"
nameWithType: "SearchClient.getDocumentCountWithResponse(Context context)"
summary: "Queries the number of documents in the search index."
parameters:
- description: "additional context that is passed through the Http pipeline during the service call"
name: "context"
type: "<xref href=\"com.azure.core.util.Context?alt=com.azure.core.util.Context&text=Context\" data-throw-if-not-resolved=\"False\" />"
syntax: "public Response<Long> getDocumentCountWithResponse(Context context)"
desc: "Queries the number of documents in the search index.\n\n**Code Sample**\n\nGet document count.\n\n```java\nResponse<Long> countResponse = SEARCH_CLIENT.getDocumentCountWithResponse(new Context(KEY_1, VALUE_1));\n System.out.println(\"The status code of the response is \" + countResponse.getStatusCode());\n System.out.printf(\"There are %d documents in service.\", countResponse.getValue());\n```"
returns:
description: "response containing the number of documents."
type: "<xref href=\"com.azure.core.http.rest.Response?alt=com.azure.core.http.rest.Response&text=Response\" data-throw-if-not-resolved=\"False\" />&lt;<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Long.html\">Long</a>&gt;"
- uid: "com.azure.search.documents.SearchClient.getEndpoint()"
fullName: "com.azure.search.documents.SearchClient.getEndpoint()"
name: "getEndpoint()"
nameWithType: "SearchClient.getEndpoint()"
summary: "Gets the endpoint for the Azure AI Search service."
syntax: "public String getEndpoint()"
desc: "Gets the endpoint for the Azure AI Search service."
returns:
description: "the endpoint value."
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- uid: "com.azure.search.documents.SearchClient.getIndexName()"
fullName: "com.azure.search.documents.SearchClient.getIndexName()"
name: "getIndexName()"
nameWithType: "SearchClient.getIndexName()"
summary: "Gets the name of the Azure AI Search index."
syntax: "public String getIndexName()"
desc: "Gets the name of the Azure AI Search index."
returns:
description: "the indexName value."
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- uid: "com.azure.search.documents.SearchClient.indexDocuments(com.azure.search.documents.indexes.models.IndexDocumentsBatch<?>)"
fullName: "com.azure.search.documents.SearchClient.indexDocuments(IndexDocumentsBatch<?> batch)"
name: "indexDocuments(IndexDocumentsBatch<?> batch)"
nameWithType: "SearchClient.indexDocuments(IndexDocumentsBatch<?> batch)"
summary: "Sends a batch of upload, merge, and/or delete actions to the search index."
parameters:
- description: "The batch of index actions"
name: "batch"
type: "<xref href=\"com.azure.search.documents.indexes.models.IndexDocumentsBatch?alt=com.azure.search.documents.indexes.models.IndexDocumentsBatch&text=IndexDocumentsBatch\" data-throw-if-not-resolved=\"False\" />&lt;?&gt;"
syntax: "public IndexDocumentsResult indexDocuments(IndexDocumentsBatch<?> batch)"
desc: "Sends a batch of upload, merge, and/or delete actions to the search index.\n\n**Code Sample**\n\nIndex batch operation on dynamic SearchDocument.\n\n```java\nSearchDocument searchDocument1 = new SearchDocument();\n searchDocument1.put(\"hotelId\", \"1\");\n searchDocument1.put(\"hotelName\", \"test1\");\n SearchDocument searchDocument2 = new SearchDocument();\n searchDocument2.put(\"hotelId\", \"2\");\n searchDocument2.put(\"hotelName\", \"test2\");\n IndexDocumentsBatch<SearchDocument> indexDocumentsBatch = new IndexDocumentsBatch<>();\n indexDocumentsBatch.addUploadActions(Collections.singletonList(searchDocument1));\n indexDocumentsBatch.addDeleteActions(Collections.singletonList(searchDocument2));\n IndexDocumentsResult result = SEARCH_CLIENT.indexDocuments(indexDocumentsBatch);\n for (IndexingResult indexingResult : result.getResults()) {\n System.out.printf(\"Does document with key %s finish successfully? %b%n\", indexingResult.getKey(),\n indexingResult.isSucceeded());\n }\n```"
returns:
description: "Response containing the status of operations for all actions in the batch"
type: "<xref href=\"com.azure.search.documents.models.IndexDocumentsResult?alt=com.azure.search.documents.models.IndexDocumentsResult&text=IndexDocumentsResult\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.search.documents.SearchClient.indexDocumentsWithResponse(com.azure.search.documents.indexes.models.IndexDocumentsBatch<?>,com.azure.search.documents.models.IndexDocumentsOptions,com.azure.core.util.Context)"
fullName: "com.azure.search.documents.SearchClient.indexDocumentsWithResponse(IndexDocumentsBatch<?> batch, IndexDocumentsOptions options, Context context)"
name: "indexDocumentsWithResponse(IndexDocumentsBatch<?> batch, IndexDocumentsOptions options, Context context)"
nameWithType: "SearchClient.indexDocumentsWithResponse(IndexDocumentsBatch<?> batch, IndexDocumentsOptions options, Context context)"
summary: "Sends a batch of upload, merge, and/or delete actions to the search index."
parameters:
- description: "The batch of index actions"
name: "batch"
type: "<xref href=\"com.azure.search.documents.indexes.models.IndexDocumentsBatch?alt=com.azure.search.documents.indexes.models.IndexDocumentsBatch&text=IndexDocumentsBatch\" data-throw-if-not-resolved=\"False\" />&lt;?&gt;"
- description: "Options that allow specifying document indexing behavior."
name: "options"
type: "<xref href=\"com.azure.search.documents.models.IndexDocumentsOptions?alt=com.azure.search.documents.models.IndexDocumentsOptions&text=IndexDocumentsOptions\" data-throw-if-not-resolved=\"False\" />"
- description: "additional context that is passed through the Http pipeline during the service call"
name: "context"
type: "<xref href=\"com.azure.core.util.Context?alt=com.azure.core.util.Context&text=Context\" data-throw-if-not-resolved=\"False\" />"
syntax: "public Response<IndexDocumentsResult> indexDocumentsWithResponse(IndexDocumentsBatch<?> batch, IndexDocumentsOptions options, Context context)"
desc: "Sends a batch of upload, merge, and/or delete actions to the search index.\n\n**Code Sample**\n\nIndex batch operation on dynamic SearchDocument.\n\n```java\nSearchDocument searchDocument1 = new SearchDocument();\n searchDocument1.put(\"hotelId\", \"1\");\n searchDocument1.put(\"hotelName\", \"test1\");\n SearchDocument searchDocument2 = new SearchDocument();\n searchDocument2.put(\"hotelId\", \"2\");\n searchDocument2.put(\"hotelName\", \"test2\");\n IndexDocumentsBatch<SearchDocument> indexDocumentsBatch = new IndexDocumentsBatch<>();\n indexDocumentsBatch.addUploadActions(Collections.singletonList(searchDocument1));\n indexDocumentsBatch.addDeleteActions(Collections.singletonList(searchDocument2));\n Response<IndexDocumentsResult> resultResponse = SEARCH_CLIENT.indexDocumentsWithResponse(indexDocumentsBatch,\n null, new Context(KEY_1, VALUE_1));\n System.out.println(\"The status code of the response is \" + resultResponse.getStatusCode());\n for (IndexingResult indexingResult : resultResponse.getValue().getResults()) {\n System.out.printf(\"Does document with key %s finish successfully? %b%n\", indexingResult.getKey(),\n indexingResult.isSucceeded());\n }\n```"
returns:
description: "Response containing the status of operations for all actions in the batch"
type: "<xref href=\"com.azure.core.http.rest.Response?alt=com.azure.core.http.rest.Response&text=Response\" data-throw-if-not-resolved=\"False\" />&lt;<xref href=\"com.azure.search.documents.models.IndexDocumentsResult?alt=com.azure.search.documents.models.IndexDocumentsResult&text=IndexDocumentsResult\" data-throw-if-not-resolved=\"False\" />&gt;"
- uid: "com.azure.search.documents.SearchClient.mergeDocuments(java.lang.Iterable<?>)"
fullName: "com.azure.search.documents.SearchClient.mergeDocuments(Iterable<?> documents)"
name: "mergeDocuments(Iterable<?> documents)"
nameWithType: "SearchClient.mergeDocuments(Iterable<?> documents)"
summary: "Merges a collection of documents with existing documents in the target index."
parameters:
- description: "collection of documents to be merged"
name: "documents"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html\">Iterable</a>&lt;?&gt;"
syntax: "public IndexDocumentsResult mergeDocuments(Iterable<?> documents)"
desc: "Merges a collection of documents with existing documents in the target index.\n\nIf the type of the document contains non-nullable primitive-typed properties, these properties may not merge correctly. If you do not set such a property, it will automatically take its default value (for example, `0` for `int` or false for `boolean`), which will override the value of the property currently stored in the index, even if this was not your intent. For this reason, it is strongly recommended that you always declare primitive-typed properties with their class equivalents (for example, an integer property should be of type `Integer` instead of `int`).\n\n**Code Sample**\n\nMerge dynamic SearchDocument.\n\n```java\nSearchDocument searchDocument = new SearchDocument();\n searchDocument.put(\"hotelName\", \"merge\");\n IndexDocumentsResult result = SEARCH_CLIENT.mergeDocuments(Collections.singletonList(searchDocument));\n for (IndexingResult indexingResult : result.getResults()) {\n System.out.printf(\"Does document with key %s merge successfully? %b%n\", indexingResult.getKey(),\n indexingResult.isSucceeded());\n }\n```"
returns:
description: "document index result"
type: "<xref href=\"com.azure.search.documents.models.IndexDocumentsResult?alt=com.azure.search.documents.models.IndexDocumentsResult&text=IndexDocumentsResult\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.search.documents.SearchClient.mergeDocumentsWithResponse(java.lang.Iterable<?>,com.azure.search.documents.models.IndexDocumentsOptions,com.azure.core.util.Context)"
fullName: "com.azure.search.documents.SearchClient.mergeDocumentsWithResponse(Iterable<?> documents, IndexDocumentsOptions options, Context context)"
name: "mergeDocumentsWithResponse(Iterable<?> documents, IndexDocumentsOptions options, Context context)"
nameWithType: "SearchClient.mergeDocumentsWithResponse(Iterable<?> documents, IndexDocumentsOptions options, Context context)"
summary: "Merges a collection of documents with existing documents in the target index."
parameters:
- description: "collection of documents to be merged."
name: "documents"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html\">Iterable</a>&lt;?&gt;"
- description: "Options that allow specifying document indexing behavior."
name: "options"
type: "<xref href=\"com.azure.search.documents.models.IndexDocumentsOptions?alt=com.azure.search.documents.models.IndexDocumentsOptions&text=IndexDocumentsOptions\" data-throw-if-not-resolved=\"False\" />"
- description: "additional context that is passed through the Http pipeline during the service call"
name: "context"
type: "<xref href=\"com.azure.core.util.Context?alt=com.azure.core.util.Context&text=Context\" data-throw-if-not-resolved=\"False\" />"
syntax: "public Response<IndexDocumentsResult> mergeDocumentsWithResponse(Iterable<?> documents, IndexDocumentsOptions options, Context context)"
desc: "Merges a collection of documents with existing documents in the target index.\n\nIf the type of the document contains non-nullable primitive-typed properties, these properties may not merge correctly. If you do not set such a property, it will automatically take its default value (for example, `0` for `int` or false for `boolean`), which will override the value of the property currently stored in the index, even if this was not your intent. For this reason, it is strongly recommended that you always declare primitive-typed properties with their class equivalents (for example, an integer property should be of type `Integer` instead of `int`).\n\n**Code Sample**\n\nMerge dynamic SearchDocument.\n\n```java\nSearchDocument searchDocument = new SearchDocument();\n searchDocument.put(\"hotelName\", \"test\");\n Response<IndexDocumentsResult> resultResponse = SEARCH_CLIENT.mergeDocumentsWithResponse(\n Collections.singletonList(searchDocument), null, new Context(KEY_1, VALUE_1));\n System.out.println(\"The status code of the response is \" + resultResponse.getStatusCode());\n for (IndexingResult indexingResult : resultResponse.getValue().getResults()) {\n System.out.printf(\"Does document with key %s merge successfully? %b%n\", indexingResult.getKey(),\n indexingResult.isSucceeded());\n }\n```"
returns:
description: "response containing the document index result."
type: "<xref href=\"com.azure.core.http.rest.Response?alt=com.azure.core.http.rest.Response&text=Response\" data-throw-if-not-resolved=\"False\" />&lt;<xref href=\"com.azure.search.documents.models.IndexDocumentsResult?alt=com.azure.search.documents.models.IndexDocumentsResult&text=IndexDocumentsResult\" data-throw-if-not-resolved=\"False\" />&gt;"
- uid: "com.azure.search.documents.SearchClient.mergeOrUploadDocuments(java.lang.Iterable<?>)"
fullName: "com.azure.search.documents.SearchClient.mergeOrUploadDocuments(Iterable<?> documents)"
name: "mergeOrUploadDocuments(Iterable<?> documents)"
nameWithType: "SearchClient.mergeOrUploadDocuments(Iterable<?> documents)"
summary: "This action behaves like merge if a document with the given key already exists in the index."
parameters:
- description: "collection of documents to be merged, if exists, otherwise uploaded"
name: "documents"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html\">Iterable</a>&lt;?&gt;"
syntax: "public IndexDocumentsResult mergeOrUploadDocuments(Iterable<?> documents)"
desc: "This action behaves like merge if a document with the given key already exists in the index. If the document does not exist, it behaves like upload with a new document.\n\nIf the type of the document contains non-nullable primitive-typed properties, these properties may not merge correctly. If you do not set such a property, it will automatically take its default value (for example, `0` for `int` or false for `boolean`), which will override the value of the property currently stored in the index, even if this was not your intent. For this reason, it is strongly recommended that you always declare primitive-typed properties with their class equivalents (for example, an integer property should be of type `Integer` instead of `int`).\n\n**Code Sample**\n\nMerge or upload dynamic SearchDocument.\n\n```java\nSearchDocument searchDocument = new SearchDocument();\n searchDocument.put(\"hotelId\", \"1\");\n searchDocument.put(\"hotelName\", \"test\");\n IndexDocumentsResult result = SEARCH_CLIENT.mergeOrUploadDocuments(Collections.singletonList(searchDocument));\n for (IndexingResult indexingResult : result.getResults()) {\n System.out.printf(\"Does document with key %s mergeOrUpload successfully? %b%n\", indexingResult.getKey(),\n indexingResult.isSucceeded());\n }\n```"
returns:
description: "document index result"
type: "<xref href=\"com.azure.search.documents.models.IndexDocumentsResult?alt=com.azure.search.documents.models.IndexDocumentsResult&text=IndexDocumentsResult\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.search.documents.SearchClient.mergeOrUploadDocumentsWithResponse(java.lang.Iterable<?>,com.azure.search.documents.models.IndexDocumentsOptions,com.azure.core.util.Context)"
fullName: "com.azure.search.documents.SearchClient.mergeOrUploadDocumentsWithResponse(Iterable<?> documents, IndexDocumentsOptions options, Context context)"
name: "mergeOrUploadDocumentsWithResponse(Iterable<?> documents, IndexDocumentsOptions options, Context context)"
nameWithType: "SearchClient.mergeOrUploadDocumentsWithResponse(Iterable<?> documents, IndexDocumentsOptions options, Context context)"
summary: "This action behaves like merge if a document with the given key already exists in the index."
parameters:
- description: "collection of documents to be merged, if exists, otherwise uploaded"
name: "documents"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html\">Iterable</a>&lt;?&gt;"
- description: "Options that allow specifying document indexing behavior."
name: "options"
type: "<xref href=\"com.azure.search.documents.models.IndexDocumentsOptions?alt=com.azure.search.documents.models.IndexDocumentsOptions&text=IndexDocumentsOptions\" data-throw-if-not-resolved=\"False\" />"
- description: "additional context that is passed through the Http pipeline during the service call"
name: "context"
type: "<xref href=\"com.azure.core.util.Context?alt=com.azure.core.util.Context&text=Context\" data-throw-if-not-resolved=\"False\" />"
syntax: "public Response<IndexDocumentsResult> mergeOrUploadDocumentsWithResponse(Iterable<?> documents, IndexDocumentsOptions options, Context context)"
desc: "This action behaves like merge if a document with the given key already exists in the index. If the document does not exist, it behaves like upload with a new document.\n\nIf the type of the document contains non-nullable primitive-typed properties, these properties may not merge correctly. If you do not set such a property, it will automatically take its default value (for example, `0` for `int` or false for `boolean`), which will override the value of the property currently stored in the index, even if this was not your intent. For this reason, it is strongly recommended that you always declare primitive-typed properties with their class equivalents (for example, an integer property should be of type `Integer` instead of `int`).\n\n**Code Sample**\n\nMerge or upload dynamic SearchDocument.\n\n```java\nSearchDocument searchDocument = new SearchDocument();\n searchDocument.put(\"hotelId\", \"1\");\n searchDocument.put(\"hotelName\", \"test\");\n Response<IndexDocumentsResult> resultResponse = SEARCH_CLIENT.mergeOrUploadDocumentsWithResponse(\n Collections.singletonList(searchDocument), null, new Context(KEY_1, VALUE_1));\n System.out.println(\"The status code of the response is \" + resultResponse.getStatusCode());\n for (IndexingResult indexingResult : resultResponse.getValue().getResults()) {\n System.out.printf(\"Does document with key %s mergeOrUpload successfully? %b%n\", indexingResult.getKey(),\n indexingResult.isSucceeded());\n }\n```"
returns:
description: "response containing a document index result"
type: "<xref href=\"com.azure.core.http.rest.Response?alt=com.azure.core.http.rest.Response&text=Response\" data-throw-if-not-resolved=\"False\" />&lt;<xref href=\"com.azure.search.documents.models.IndexDocumentsResult?alt=com.azure.search.documents.models.IndexDocumentsResult&text=IndexDocumentsResult\" data-throw-if-not-resolved=\"False\" />&gt;"
- uid: "com.azure.search.documents.SearchClient.search(java.lang.String)"
fullName: "com.azure.search.documents.SearchClient.search(String searchText)"
name: "search(String searchText)"
nameWithType: "SearchClient.search(String searchText)"
summary: "Searches for documents in the Azure AI Search index."
parameters:
- description: "A full-text search query expression."
name: "searchText"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
syntax: "public SearchPagedIterable search(String searchText)"
desc: "Searches for documents in the Azure AI Search index.\n\nIf `searchText` is set to null or `\"*\"` all documents will be matched, see [simple query syntax in Azure AI Search][] for more information about search query syntax.\n\nThe <xref uid=\"com.azure.search.documents.util.SearchPagedIterable\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SearchPagedIterable\"></xref> will iterate through search result pages until all search results are returned. Each page is determined by the `$skip` and `$top` values and the Search service has a limit on the number of documents that can be skipped, more information about the `$skip` limit can be found at [Search Documents REST API][] and reading the `$skip` description. If the total number of results exceeds the `$skip` limit the <xref uid=\"com.azure.search.documents.util.SearchPagedIterable\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SearchPagedIterable\"></xref> won't prevent you from exceeding the `$skip` limit. To prevent exceeding the limit you can track the number of documents returned and stop requesting new pages when the limit is reached.\n\n**Code Sample**\n\nSearch text from documents in service.\n\n```java\nSearchPagedIterable searchPagedIterable = SEARCH_CLIENT.search(\"searchText\");\n System.out.printf(\"There are around %d results.\", searchPagedIterable.getTotalCount());\n\n long numberOfDocumentsReturned = 0;\n for (SearchPagedResponse resultResponse: searchPagedIterable.iterableByPage()) {\n System.out.println(\"The status code of the response is \" + resultResponse.getStatusCode());\n numberOfDocumentsReturned += resultResponse.getValue().size();\n resultResponse.getValue().forEach(searchResult -> {\n for (Map.Entry<String, Object> keyValuePair: searchResult\n .getDocument(SearchDocument.class).entrySet()) {\n System.out.printf(\"Document key %s, document value %s\", keyValuePair.getKey(),\n keyValuePair.getValue());\n }\n });\n\n if (numberOfDocumentsReturned >= SEARCH_SKIP_LIMIT) {\n // Reached the $skip limit, stop requesting more documents.\n break;\n }\n }\n```\n\n\n[simple query syntax in Azure AI Search]: https://docs.microsoft.com/rest/api/searchservice/Simple-query-syntax-in-Azure-Search\n[Search Documents REST API]: https://learn.microsoft.com/rest/api/searchservice/search-documents"
returns:
description: "A <xref uid=\"com.azure.search.documents.util.SearchPagedIterable\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SearchPagedIterable\"></xref> that iterates over <xref uid=\"com.azure.search.documents.models.SearchResult\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SearchResult\"></xref> objects and provides access to the\n <xref uid=\"com.azure.search.documents.util.SearchPagedResponse\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SearchPagedResponse\"></xref> object for each page containing HTTP response and count, facet, and coverage\n information."
type: "<xref href=\"com.azure.search.documents.util.SearchPagedIterable?alt=com.azure.search.documents.util.SearchPagedIterable&text=SearchPagedIterable\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.search.documents.SearchClient.search(java.lang.String,com.azure.search.documents.models.SearchOptions,com.azure.core.util.Context)"
fullName: "com.azure.search.documents.SearchClient.search(String searchText, SearchOptions searchOptions, Context context)"
name: "search(String searchText, SearchOptions searchOptions, Context context)"
nameWithType: "SearchClient.search(String searchText, SearchOptions searchOptions, Context context)"
summary: "Searches for documents in the Azure AI Search index."
parameters:
- description: "A full-text search query expression."
name: "searchText"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "Parameters to further refine the search query"
name: "searchOptions"
type: "<xref href=\"com.azure.search.documents.models.SearchOptions?alt=com.azure.search.documents.models.SearchOptions&text=SearchOptions\" data-throw-if-not-resolved=\"False\" />"
- description: "additional context that is passed through the Http pipeline during the service call"
name: "context"
type: "<xref href=\"com.azure.core.util.Context?alt=com.azure.core.util.Context&text=Context\" data-throw-if-not-resolved=\"False\" />"
syntax: "public SearchPagedIterable search(String searchText, SearchOptions searchOptions, Context context)"
desc: "Searches for documents in the Azure AI Search index.\n\nIf `searchText` is set to null or `\"*\"` all documents will be matched, see [simple query syntax in Azure AI Search][] for more information about search query syntax.\n\nThe <xref uid=\"com.azure.search.documents.util.SearchPagedIterable\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SearchPagedIterable\"></xref> will iterate through search result pages until all search results are returned. Each page is determined by the `$skip` and `$top` values and the Search service has a limit on the number of documents that can be skipped, more information about the `$skip` limit can be found at [Search Documents REST API][] and reading the `$skip` description. If the total number of results exceeds the `$skip` limit the <xref uid=\"com.azure.search.documents.util.SearchPagedIterable\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SearchPagedIterable\"></xref> won't prevent you from exceeding the `$skip` limit. To prevent exceeding the limit you can track the number of documents returned and stop requesting new pages when the limit is reached.\n\n**Code Sample**\n\nSearch text from documents in service with option.\n\n```java\nSearchPagedIterable searchPagedIterable = SEARCH_CLIENT.search(\"searchText\",\n new SearchOptions().setOrderBy(\"hotelId desc\"), new Context(KEY_1, VALUE_1));\n System.out.printf(\"There are around %d results.\", searchPagedIterable.getTotalCount());\n\n long numberOfDocumentsReturned = 0;\n for (SearchPagedResponse resultResponse: searchPagedIterable.iterableByPage()) {\n System.out.println(\"The status code of the response is \" + resultResponse.getStatusCode());\n numberOfDocumentsReturned += resultResponse.getValue().size();\n resultResponse.getValue().forEach(searchResult -> {\n for (Map.Entry<String, Object> keyValuePair: searchResult\n .getDocument(SearchDocument.class).entrySet()) {\n System.out.printf(\"Document key %s, document value %s\", keyValuePair.getKey(),\n keyValuePair.getValue());\n }\n });\n\n if (numberOfDocumentsReturned >= SEARCH_SKIP_LIMIT) {\n // Reached the $skip limit, stop requesting more documents.\n break;\n }\n }\n```\n\n\n[simple query syntax in Azure AI Search]: https://docs.microsoft.com/rest/api/searchservice/Simple-query-syntax-in-Azure-Search\n[Search Documents REST API]: https://learn.microsoft.com/rest/api/searchservice/search-documents"
returns:
description: "A <xref uid=\"com.azure.search.documents.util.SearchPagedIterable\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SearchPagedIterable\"></xref> that iterates over <xref uid=\"com.azure.search.documents.models.SearchResult\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SearchResult\"></xref> objects and provides access to the\n <xref uid=\"com.azure.search.documents.util.SearchPagedResponse\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SearchPagedResponse\"></xref> object for each page containing HTTP response and count, facet, and coverage\n information."
type: "<xref href=\"com.azure.search.documents.util.SearchPagedIterable?alt=com.azure.search.documents.util.SearchPagedIterable&text=SearchPagedIterable\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.search.documents.SearchClient.suggest(java.lang.String,java.lang.String)"
fullName: "com.azure.search.documents.SearchClient.suggest(String searchText, String suggesterName)"
name: "suggest(String searchText, String suggesterName)"
nameWithType: "SearchClient.suggest(String searchText, String suggesterName)"
summary: "Suggests documents in the index that match the given partial query."
parameters:
- description: "The search text on which to base suggestions"
name: "searchText"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "The name of the suggester as specified in the suggesters collection that's part of the index\n definition"
name: "suggesterName"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
syntax: "public SuggestPagedIterable suggest(String searchText, String suggesterName)"
desc: "Suggests documents in the index that match the given partial query.\n\n**Code Sample**\n\nSuggest text from documents in service.\n\n```java\nSuggestPagedIterable suggestPagedIterable = SEARCH_CLIENT.suggest(\"searchText\", \"sg\");\n for (SuggestResult result: suggestPagedIterable) {\n SearchDocument searchDocument = result.getDocument(SearchDocument.class);\n for (Map.Entry<String, Object> keyValuePair: searchDocument.entrySet()) {\n System.out.printf(\"Document key %s, document value %s\", keyValuePair.getKey(), keyValuePair.getValue());\n }\n }\n```"
returns:
description: "A <xref uid=\"com.azure.search.documents.util.SuggestPagedIterable\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SuggestPagedIterable\"></xref> that iterates over <xref uid=\"com.azure.search.documents.models.SuggestResult\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SuggestResult\"></xref> objects and provides access to\n the <xref uid=\"com.azure.search.documents.util.SuggestPagedResponse\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SuggestPagedResponse\"></xref> object for each page containing HTTP response and coverage information."
type: "<xref href=\"com.azure.search.documents.util.SuggestPagedIterable?alt=com.azure.search.documents.util.SuggestPagedIterable&text=SuggestPagedIterable\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.search.documents.SearchClient.suggest(java.lang.String,java.lang.String,com.azure.search.documents.models.SuggestOptions,com.azure.core.util.Context)"
fullName: "com.azure.search.documents.SearchClient.suggest(String searchText, String suggesterName, SuggestOptions suggestOptions, Context context)"
name: "suggest(String searchText, String suggesterName, SuggestOptions suggestOptions, Context context)"
nameWithType: "SearchClient.suggest(String searchText, String suggesterName, SuggestOptions suggestOptions, Context context)"
summary: "Suggests documents in the index that match the given partial query."
parameters:
- description: "The search text on which to base suggestions"
name: "searchText"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "The name of the suggester as specified in the suggesters collection that's part of the index\n definition"
name: "suggesterName"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "Parameters to further refine the suggestion query."
name: "suggestOptions"
type: "<xref href=\"com.azure.search.documents.models.SuggestOptions?alt=com.azure.search.documents.models.SuggestOptions&text=SuggestOptions\" data-throw-if-not-resolved=\"False\" />"
- description: "additional context that is passed through the Http pipeline during the service call"
name: "context"
type: "<xref href=\"com.azure.core.util.Context?alt=com.azure.core.util.Context&text=Context\" data-throw-if-not-resolved=\"False\" />"
syntax: "public SuggestPagedIterable suggest(String searchText, String suggesterName, SuggestOptions suggestOptions, Context context)"
desc: "Suggests documents in the index that match the given partial query.\n\n**Code Sample**\n\nSuggest text from documents in service with option.\n\n```java\nSuggestPagedIterable suggestPagedIterable = SEARCH_CLIENT.suggest(\"searchText\", \"sg\",\n new SuggestOptions().setOrderBy(\"hotelId desc\"), new Context(KEY_1, VALUE_1));\n for (SuggestResult result: suggestPagedIterable) {\n SearchDocument searchDocument = result.getDocument(SearchDocument.class);\n for (Map.Entry<String, Object> keyValuePair: searchDocument.entrySet()) {\n System.out.printf(\"Document key %s, document value %s\", keyValuePair.getKey(), keyValuePair.getValue());\n }\n }\n```"
returns:
description: "A <xref uid=\"com.azure.search.documents.util.SuggestPagedIterable\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SuggestPagedIterable\"></xref> that iterates over <xref uid=\"com.azure.search.documents.models.SuggestResult\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SuggestResult\"></xref> objects and provides access to\n the <xref uid=\"com.azure.search.documents.util.SuggestPagedResponse\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SuggestPagedResponse\"></xref> object for each page containing HTTP response and coverage information."
type: "<xref href=\"com.azure.search.documents.util.SuggestPagedIterable?alt=com.azure.search.documents.util.SuggestPagedIterable&text=SuggestPagedIterable\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.search.documents.SearchClient.uploadDocuments(java.lang.Iterable<?>)"
fullName: "com.azure.search.documents.SearchClient.uploadDocuments(Iterable<?> documents)"
name: "uploadDocuments(Iterable<?> documents)"
nameWithType: "SearchClient.uploadDocuments(Iterable<?> documents)"
summary: "Uploads a collection of documents to the target index."
parameters:
- description: "collection of documents to upload to the target Index."
name: "documents"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html\">Iterable</a>&lt;?&gt;"
syntax: "public IndexDocumentsResult uploadDocuments(Iterable<?> documents)"
desc: "Uploads a collection of documents to the target index.\n\n**Code Sample**\n\nUpload dynamic SearchDocument.\n\n```java\nSearchDocument searchDocument = new SearchDocument();\n searchDocument.put(\"hotelId\", \"1\");\n searchDocument.put(\"hotelName\", \"test\");\n IndexDocumentsResult result = SEARCH_CLIENT.uploadDocuments(Collections.singletonList(searchDocument));\n for (IndexingResult indexingResult : result.getResults()) {\n System.out.printf(\"Does document with key %s upload successfully? %b%n\", indexingResult.getKey(),\n indexingResult.isSucceeded());\n }\n```"
returns:
description: "document index result."
type: "<xref href=\"com.azure.search.documents.models.IndexDocumentsResult?alt=com.azure.search.documents.models.IndexDocumentsResult&text=IndexDocumentsResult\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.search.documents.SearchClient.uploadDocumentsWithResponse(java.lang.Iterable<?>,com.azure.search.documents.models.IndexDocumentsOptions,com.azure.core.util.Context)"
fullName: "com.azure.search.documents.SearchClient.uploadDocumentsWithResponse(Iterable<?> documents, IndexDocumentsOptions options, Context context)"
name: "uploadDocumentsWithResponse(Iterable<?> documents, IndexDocumentsOptions options, Context context)"
nameWithType: "SearchClient.uploadDocumentsWithResponse(Iterable<?> documents, IndexDocumentsOptions options, Context context)"
summary: "Uploads a collection of documents to the target index."
parameters:
- description: "collection of documents to upload to the target Index."
name: "documents"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html\">Iterable</a>&lt;?&gt;"
- description: "Options that allow specifying document indexing behavior."
name: "options"
type: "<xref href=\"com.azure.search.documents.models.IndexDocumentsOptions?alt=com.azure.search.documents.models.IndexDocumentsOptions&text=IndexDocumentsOptions\" data-throw-if-not-resolved=\"False\" />"
- description: "additional context that is passed through the Http pipeline during the service call"
name: "context"
type: "<xref href=\"com.azure.core.util.Context?alt=com.azure.core.util.Context&text=Context\" data-throw-if-not-resolved=\"False\" />"
syntax: "public Response<IndexDocumentsResult> uploadDocumentsWithResponse(Iterable<?> documents, IndexDocumentsOptions options, Context context)"
desc: "Uploads a collection of documents to the target index.\n\n**Code Sample**\n\nUpload dynamic SearchDocument.\n\n```java\nSearchDocument searchDocument = new SearchDocument();\n searchDocument.put(\"hotelId\", \"1\");\n searchDocument.put(\"hotelName\", \"test\");\n Response<IndexDocumentsResult> resultResponse = SEARCH_CLIENT.uploadDocumentsWithResponse(\n Collections.singletonList(searchDocument), null, new Context(KEY_1, VALUE_1));\n System.out.println(\"The status code of the response is \" + resultResponse.getStatusCode());\n for (IndexingResult indexingResult : resultResponse.getValue().getResults()) {\n System.out.printf(\"Does document with key %s upload successfully? %b%n\", indexingResult.getKey(),\n indexingResult.isSucceeded());\n }\n```"
returns:
description: "response containing the document index result."
type: "<xref href=\"com.azure.core.http.rest.Response?alt=com.azure.core.http.rest.Response&text=Response\" data-throw-if-not-resolved=\"False\" />&lt;<xref href=\"com.azure.search.documents.models.IndexDocumentsResult?alt=com.azure.search.documents.models.IndexDocumentsResult&text=IndexDocumentsResult\" data-throw-if-not-resolved=\"False\" />&gt;"
type: "class"
desc: "This class provides a client that contains the operations for querying an index and uploading, merging, or deleting documents in an Azure AI Search service.\n\n## Overview ##\n\nConceptually, a document is an entity in your index. Mapping this concept to more familiar database equivalents: a search index equates to a table, and documents are roughly equivalent to rows in a table. Documents exist only in an index, and are retrieved only through queries that target the documents collection (/docs) of an index. All operations performed on the collection such as uploading, merging, deleting, or querying documents take place in the context of a single index, so the URL format document operations will always include /indexes/\\[index name\\]/docs for a given index name.\n\nThis client provides a synchronous API for accessing and performing operations on indexed documents. This client assists with searching your indexed documents, autocompleting partially typed search terms based on documents within the index, suggesting the most likely matching text in documents as a user types. The client provides operations for adding, updating, and deleting documents from an index.\n\n## Getting Started ##\n\nAuthenticating and building instances of this client are handled by <xref uid=\"com.azure.search.documents.SearchClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SearchClientBuilder\"></xref>. This sample shows you how to authenticate and create an instance of the client:\n\n```java\nSearchClient searchClient = new SearchClientBuilder()\n .credential(new AzureKeyCredential(\"{key}\"))\n .endpoint(\"{endpoint}\")\n .indexName(\"{indexName}\")\n .buildClient();\n```\n\nFor more information on authentication and building, see the <xref uid=\"com.azure.search.documents.SearchClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SearchClientBuilder\"></xref> documentation.\n\n--------------------\n\n## Examples ##\n\nThe following examples all use [a simple Hotel data set][] that you can [ import into your own index from the Azure portal.][import into your own index from the Azure portal.] These are just a few of the basics - please check out [our Samples ][our Samples]for much more.\n\n### Upload a Document ###\n\nThe following sample uploads a new document to an index.\n\n```java\nList<Hotel> hotels = new ArrayList<>();\n hotels.add(new Hotel().setHotelId(\"100\"));\n hotels.add(new Hotel().setHotelId(\"200\"));\n hotels.add(new Hotel().setHotelId(\"300\"));\n searchClient.uploadDocuments(hotels);\n```\n\n *For an asynchronous sample see <xref uid=\"com.azure.search.documents.SearchAsyncClient.uploadDocuments(java.lang.Iterable<?>)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SearchAsyncClient#uploadDocuments(Iterable)\"></xref>.* \n\n### Merge a Document ###\n\nThe following sample merges documents in an index.\n\n```java\nList<Hotel> hotels = new ArrayList<>();\n hotels.add(new Hotel().setHotelId(\"100\"));\n hotels.add(new Hotel().setHotelId(\"200\"));\n searchClient.mergeDocuments(hotels);\n```\n\n *For an asynchronous sample see <xref uid=\"com.azure.search.documents.SearchAsyncClient.mergeDocuments(java.lang.Iterable<?>)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SearchAsyncClient#mergeDocuments(Iterable)\"></xref>.* \n\n### Delete a Document ###\n\nThe following sample deletes a document from an index.\n\n```java\nSearchDocument documentId = new SearchDocument();\n documentId.put(\"hotelId\", \"100\");\n searchClient.deleteDocuments(Collections.singletonList(documentId));\n```\n\n *For an asynchronous sample see <xref uid=\"com.azure.search.documents.SearchAsyncClient.deleteDocuments(java.lang.Iterable<?>)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SearchAsyncClient#deleteDocuments(Iterable)\"></xref>.* \n\n### Get a Document ###\n\nThe following sample gets a document from an index.\n\n```java\nHotel hotel = searchClient.getDocument(\"100\", Hotel.class);\n System.out.printf(\"Retrieved Hotel %s%n\", hotel.getHotelId());\n```\n\n *For an asynchronous sample see <xref uid=\"com.azure.search.documents.SearchAsyncClient.<T>getDocument(java.lang.String,java.lang.Class<T>)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SearchAsyncClient#getDocument(String, Class)\"></xref>.* \n\n### Search Documents ###\n\nThe following sample searches for documents within an index.\n\n```java\nSearchDocument searchDocument = new SearchDocument();\n searchDocument.put(\"hotelId\", \"8\");\n searchDocument.put(\"description\", \"budget\");\n searchDocument.put(\"descriptionFr\", \"motel\");\n\n SearchDocument searchDocument1 = new SearchDocument();\n searchDocument1.put(\"hotelId\", \"9\");\n searchDocument1.put(\"description\", \"budget\");\n searchDocument1.put(\"descriptionFr\", \"motel\");\n\n List<SearchDocument> searchDocuments = new ArrayList<>();\n searchDocuments.add(searchDocument);\n searchDocuments.add(searchDocument1);\n searchClient.uploadDocuments(searchDocuments);\n\n SearchPagedIterable results = searchClient.search(\"SearchText\");\n System.out.printf(\"There are %s results.%n\", results.getTotalCount());\n```\n\n *For an asynchronous sample see <xref uid=\"com.azure.search.documents.SearchAsyncClient.search(java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SearchAsyncClient#search(String)\"></xref>.* \n\n### Make a Suggestion ###\n\nThe following sample suggests the most likely matching text in documents.\n\n```java\nSuggestPagedIterable suggestPagedIterable = searchClient.suggest(\"searchText\", \"sg\");\n for (SuggestResult result: suggestPagedIterable) {\n System.out.printf(\"The suggested text is %s\", result.getText());\n }\n```\n\n *For an asynchronous sample see <xref uid=\"com.azure.search.documents.SearchAsyncClient.suggest(java.lang.String,java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SearchAsyncClient#suggest(String, String)\"></xref>.* \n\n### Provide an Autocompletion ###\n\nThe following sample provides autocompletion for a partially typed query.\n\n```java\nAutocompletePagedIterable autocompletePagedIterable = searchClient.autocomplete(\"searchText\", \"sg\");\n for (AutocompleteItem result: autocompletePagedIterable) {\n System.out.printf(\"The complete term is %s\", result.getText());\n }\n```\n\n *For an asynchronous sample see <xref uid=\"com.azure.search.documents.SearchAsyncClient.autocomplete(java.lang.String,java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"SearchAsyncClient#autocomplete(String, String)\"></xref>.* \n\n\n[a simple Hotel data set]: https://github.com/Azure-Samples/azure-search-sample-data\n[import into your own index from the Azure portal.]: https://learn.microsoft.com/azure/search/search-get-started-portal#step-1---start-the-import-data-wizard-and-create-a-data-source\n[our Samples]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/search/azure-search-documents/src/samples/README.md"
metadata: {}
package: "com.azure.search.documents"
artifact: com.azure:azure-search-documents:11.7.1