Skip to content

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ public static async Task<T> GetAsync<T>(
/// </returns>
public static DocumentIndexResult Index(
this IDocumentsOperations operations,
IndexBatch batch,
IndexBatch<Document> batch,
SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return operations.IndexAsync(batch, searchRequestOptions).GetAwaiter().GetResult();
Expand Down Expand Up @@ -543,7 +543,7 @@ public static DocumentIndexResult Index(
/// </returns>
public static async Task<DocumentIndexResult> IndexAsync(
this IDocumentsOperations operations,
IndexBatch batch,
IndexBatch<Document> batch,
SearchRequestOptions searchRequestOptions = default(SearchRequestOptions),
CancellationToken cancellationToken = default(CancellationToken))
{
Expand Down Expand Up @@ -862,7 +862,7 @@ public static async Task<DocumentSearchResult<T>> SearchAsync<T>(
/// <see cref="IDocumentsOperations.GetWithHttpMessagesAsync(string, System.Collections.Generic.IEnumerable&lt;string&gt;, SearchRequestOptions, System.Collections.Generic.Dictionary&lt;string, System.Collections.Generic.List&lt;string&gt;&gt;, CancellationToken)"/>
/// for more information.
/// </remarks>
public static DocumentSuggestResult Suggest(
public static DocumentSuggestResult<Document> Suggest(
this IDocumentsOperations operations,
string searchText,
string suggesterName,
Expand Down Expand Up @@ -903,15 +903,15 @@ public static DocumentSuggestResult Suggest(
/// <see cref="IDocumentsOperations.GetWithHttpMessagesAsync(string, System.Collections.Generic.IEnumerable&lt;string&gt;, SearchRequestOptions, System.Collections.Generic.Dictionary&lt;string, System.Collections.Generic.List&lt;string&gt;&gt;, CancellationToken)"/>
/// for more information.
/// </remarks>
public static async Task<DocumentSuggestResult> SuggestAsync(
public static async Task<DocumentSuggestResult<Document>> SuggestAsync(
this IDocumentsOperations operations,
string searchText,
string suggesterName,
SuggestParameters suggestParameters = null,
SearchRequestOptions searchRequestOptions = default(SearchRequestOptions),
CancellationToken cancellationToken = default(CancellationToken))
{
AzureOperationResponse<DocumentSuggestResult> result = await operations.SuggestWithHttpMessagesAsync(searchText, suggesterName, suggestParameters ?? new SuggestParameters(), searchRequestOptions, null, cancellationToken).ConfigureAwait(false);
AzureOperationResponse<DocumentSuggestResult<Document>> result = await operations.SuggestWithHttpMessagesAsync(searchText, suggesterName, suggestParameters ?? new SuggestParameters(), searchRequestOptions, null, cancellationToken).ConfigureAwait(false);
return result.Body;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ Task<AzureOperationResponse<T>> GetWithHttpMessagesAsync<T>(
/// Response containing the status of operations for all actions in the batch.
/// </returns>
Task<AzureOperationResponse<DocumentIndexResult>> IndexWithHttpMessagesAsync(
IndexBatch batch,
IndexBatch<Document> batch,
SearchRequestOptions searchRequestOptions = default(SearchRequestOptions),
Dictionary<string, List<string>> customHeaders = null,
CancellationToken cancellationToken = default(CancellationToken));
Expand Down Expand Up @@ -517,7 +517,7 @@ Task<AzureOperationResponse<DocumentSearchResult<T>>> SearchWithHttpMessagesAsyn
/// <see cref="IDocumentsOperations.GetWithHttpMessagesAsync(string, System.Collections.Generic.IEnumerable&lt;string&gt;, SearchRequestOptions, System.Collections.Generic.Dictionary&lt;string, System.Collections.Generic.List&lt;string&gt;&gt;, CancellationToken)"/>
/// for more information.
/// </remarks>
Task<AzureOperationResponse<DocumentSuggestResult>> SuggestWithHttpMessagesAsync(
Task<AzureOperationResponse<DocumentSuggestResult<Document>>> SuggestWithHttpMessagesAsync(
string searchText,
string suggesterName,
SuggestParameters suggestParameters,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,22 @@ namespace Microsoft.Azure.Search.Models
using Common;

/// <summary>
/// Represents an index action that operates on a document.
/// Provides factory methods for creating an index action that operates on a document.
/// </summary>
public class IndexAction : IndexActionBase<Document>
public static class IndexAction
{
private IndexAction(IndexActionType actionType, Document document)
: base(actionType, document)
{
// Do nothing.
}

/// <summary>
/// Creates a new IndexAction for deleting a document.
/// </summary>
/// <param name="keyName">The name of the key field of the index.</param>
/// <param name="keyValue">The key of the document to delete.</param>
/// <returns>A new IndexAction.</returns>
public static IndexAction Delete(string keyName, string keyValue)
public static IndexAction<Document> Delete(string keyName, string keyValue)
{
Throw.IfArgumentNull(keyName, "keyName");
Throw.IfArgumentNull(keyValue, "keyValue");

return new IndexAction(IndexActionType.Delete, new Document() { { keyName, keyValue } });
}

/// <summary>
/// Creates a new IndexAction for deleting a document.
/// </summary>
/// <param name="document">The document to delete; Fields other than the key are ignored.</param>
/// <returns>A new IndexAction.</returns>
public static IndexAction Delete(Document document)
{
return new IndexAction(IndexActionType.Delete, document);
return new IndexAction<Document>(new Document() { [keyName] = keyValue }, IndexActionType.Delete);
}

/// <summary>
Expand All @@ -51,17 +35,7 @@ public static IndexAction Delete(Document document)
/// <returns>A new IndexAction.</returns>
public static IndexAction<T> Delete<T>(T document) where T : class
{
return new IndexAction<T>(IndexActionType.Delete, document);
}

/// <summary>
/// Creates a new IndexAction for merging a document into an existing document in the index.
/// </summary>
/// <param name="document">The document to merge; Set only the fields that you want to change.</param>
/// <returns>A new IndexAction.</returns>
public static IndexAction Merge(Document document)
{
return new IndexAction(IndexActionType.Merge, document);
return new IndexAction<T>(document, IndexActionType.Delete);
}

/// <summary>
Expand All @@ -73,26 +47,16 @@ public static IndexAction Merge(Document document)
/// <param name="document">The document to merge; Set only the properties that you want to change.</param>
/// <returns>A new IndexAction.</returns>
/// <remarks>
/// If type T contains non-nullable value-typed properties, these properties may not merge correctly. If you
/// <para>If type T contains non-nullable value-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 bool), 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 value-typed
/// properties to be nullable in type T.
/// properties to be nullable in type T.</para>
/// <para>The above does not apply if you are using <c cref="Document">Document</c> as type T.</para>
/// </remarks>
public static IndexAction<T> Merge<T>(T document) where T : class
{
return new IndexAction<T>(IndexActionType.Merge, document);
}

/// <summary>
/// Creates a new IndexAction for uploading a document to the index, or merging it into an existing document
/// if it already exists in the index.
/// </summary>
/// <param name="document">The document to merge or upload.</param>
/// <returns>A new IndexAction.</returns>
public static IndexAction MergeOrUpload(Document document)
{
return new IndexAction(IndexActionType.MergeOrUpload, document);
return new IndexAction<T>(document, IndexActionType.Merge);
}

/// <summary>
Expand All @@ -105,25 +69,16 @@ public static IndexAction MergeOrUpload(Document document)
/// <param name="document">The document to merge or upload.</param>
/// <returns>A new IndexAction.</returns>
/// <remarks>
/// If type T contains non-nullable value-typed properties, these properties may not merge correctly. If you
/// <para>If type T contains non-nullable value-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 bool), 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 value-typed
/// properties to be nullable in type T.
/// properties to be nullable in type T.</para>
/// <para>The above does not apply if you are using <c cref="Document">Document</c> as type T.</para>
/// </remarks>
public static IndexAction<T> MergeOrUpload<T>(T document) where T : class
{
return new IndexAction<T>(IndexActionType.MergeOrUpload, document);
}

/// <summary>
/// Creates a new IndexAction for uploading a document to the index.
/// </summary>
/// <param name="document">The document to upload.</param>
/// <returns>A new IndexAction.</returns>
public static IndexAction Upload(Document document)
{
return new IndexAction(IndexActionType.Upload, document);
return new IndexAction<T>(document, IndexActionType.MergeOrUpload);
}

/// <summary>
Expand All @@ -136,7 +91,7 @@ public static IndexAction Upload(Document document)
/// <returns>A new IndexAction.</returns>
public static IndexAction<T> Upload<T>(T document) where T : class
{
return new IndexAction<T>(IndexActionType.Upload, document);
return new IndexAction<T>(document, IndexActionType.Upload);
}
}
}

This file was deleted.

This file was deleted.

Loading