private static BulkRequest CreateDeleteBulkRequest <T>(IEnumerable <T> objects, IndexName index) where T : class { // ReSharper disable once PossibleMultipleEnumeration objects.ThrowIfEmpty(nameof(objects)); var bulkRequest = new BulkRequest(index); // ReSharper disable once PossibleMultipleEnumeration var deletes = objects .Select(o => new BulkDeleteOperation <T>(o)) .Cast <IBulkOperation>() .ToList(); bulkRequest.Operations = new BulkOperationsCollection <IBulkOperation>(deletes); return(bulkRequest); }
private static BulkRequest CreateIndexBulkRequest <T>(IEnumerable <T> objects, IndexName index) where T : class { @objects.ThrowIfEmpty(nameof(objects)); var bulkRequest = new BulkRequest(index); var indexOps = @objects .Select(o => new BulkIndexOperation <T>(o)) .Cast <IBulkOperation>() .ToList(); bulkRequest.Operations = new BulkOperationsCollection <IBulkOperation>(indexOps); return(bulkRequest); }
/// <inheritdoc /> public CreateIndexResponse CreateIndex(IndexName index, Func <CreateIndexDescriptor, ICreateIndexRequest> selector = null) => CreateIndex(selector.InvokeOrDefault(new CreateIndexDescriptor(index)));
/// <summary> /// Manually set the index, default to the default index or the fixed index set on the bulk operation /// </summary> public TDescriptor Index(IndexName index) => Assign(a => a.Index = index);
/// <summary> /// Shortcut into the Bulk call that indexes the specified objects /// <para> </para> /// https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html /// </summary> /// <param name="client"></param> /// <typeparam name="T">The type used to infer the default index and typename</typeparam> /// <param name="objects">List of objects to index, Id will be inferred (Id property or IdProperty attribute on type)</param> /// <param name="index">Override the inferred indexname for T</param> /// <param name="type">Override the inferred typename for T</param> public static BulkResponse IndexMany <T>(this IElasticClient client, IEnumerable <T> @objects, IndexName index = null) where T : class { var bulkRequest = CreateIndexBulkRequest(objects, index); return(client.Bulk(bulkRequest)); }
public ShrinkIndexResponse ShrinkIndex( IndexName source, IndexName target, Func <ShrinkIndexDescriptor, IShrinkIndexRequest> selector = null ) => ShrinkIndex(selector.InvokeOrDefault(new ShrinkIndexDescriptor(source, target)));
///<summary>/{index}/_migration/deprecations</summary> ///<param name = "index">Optional, accepts null</param> public DeprecationInfoDescriptor(IndexName index) : base(r => r.Optional("index", index)) { }
private static IReadOnlyDictionary <string, AliasDefinition> AliasesPointingToIndex(IndexName index, GetAliasResponse response) { if (!response.IsValid || !response.Indices.HasAny()) { return(EmptyReadOnly <string, AliasDefinition> .Dictionary); } return(response.Indices[index].Aliases); }
public DocumentPath <T> Index(IndexName index) { Self.Index = index; return(this); }
/// <summary> /// Returns a dictionary of aliases that point to the specified index, simplified version of /// <see cref="IElasticClient.GetAlias(IGetAliasRequest)" />.. /// </summary> /// <param name="index">The index name we want to know aliases of</param> public static IReadOnlyDictionary <string, AliasDefinition> GetAliasesPointingToIndex(this IElasticClient client, IndexName index) { var response = client.GetAlias(a => a.Index(index).RequestConfiguration(r => r.ThrowExceptions())); return(AliasesPointingToIndex(index, response)); }
/// <summary> /// Returns a dictionary of aliases that point to the specified index, simplified version of /// <see cref="IElasticClient.GetAlias(IGetAliasRequest)" />. /// </summary> /// <param name="index">The index name we want to know aliases of</param> public static async Task <IReadOnlyDictionary <string, AliasDefinition> > GetAliasesPointingToIndexAsync(this IElasticClient client, IndexName index ) { var response = await client.GetAliasAsync(a => a.Index(index).RequestConfiguration(r => r.ThrowExceptions())).ConfigureAwait(false); return(AliasesPointingToIndex(index, response)); }
/// <inheritdoc /> public ValidateJobDescriptor <TDocument> ResultsIndexName(IndexName indexName) => Assign(indexName, (a, v) => a.ResultsIndexName = v);
/// <inheritdoc cref="IPainlessContextSetup.Index" /> public PainlessContextSetupDescriptor Index(IndexName index) => Assign(a => a.Index = index);
/// <inheritdoc cref="IRestoreRequest.Indices"/> public RestoreDescriptor Index(IndexName index) => this.Indices(index);
/// <inheritdoc cref="UnfollowIndex(IndexName, System.Func{Nest.UnfollowIndexDescriptor,Nest.IUnfollowIndexRequest})" /> public UnfollowIndexResponse UnfollowIndex(IndexName index, Func <UnfollowIndexDescriptor, IUnfollowIndexRequest> selector = null) => UnfollowIndex(selector.InvokeOrDefault(new UnfollowIndexDescriptor(index)));
internal static bool IsNullOrEmpty(this IndexName value) => value == null || value.GetHashCode() == 0;
/// <inheritdoc cref="UnfollowIndex(IndexName, System.Func{Nest.UnfollowIndexDescriptor,Nest.IUnfollowIndexRequest})" /> public Task <UnfollowIndexResponse> UnfollowIndexAsync( IndexName index, Func <UnfollowIndexDescriptor, IUnfollowIndexRequest> selector = null, CancellationToken ct = default ) => UnfollowIndexAsync(selector.InvokeOrDefault(new UnfollowIndexDescriptor(index)), ct);
public static Task <GetRollupIndexCapabilitiesResponse> GetRollupIndexCapabilitiesAsync(this IElasticClient client, IndexName index, Func <GetRollupIndexCapabilitiesDescriptor, IGetRollupIndexCapabilitiesRequest> selector = null, CancellationToken ct = default ) => client.Rollup.GetIndexCapabilitiesAsync(index, selector, ct);
public Task <ShrinkIndexResponse> ShrinkIndexAsync( IndexName source, IndexName target, Func <ShrinkIndexDescriptor, IShrinkIndexRequest> selector = null, CancellationToken cancellationToken = default ) => ShrinkIndexAsync(selector.InvokeOrDefault(new ShrinkIndexDescriptor(source, target)));
public static GetRollupIndexCapabilitiesResponse GetRollupIndexCapabilities(this IElasticClient client, IndexName index, Func <GetRollupIndexCapabilitiesDescriptor, IGetRollupIndexCapabilitiesRequest> selector = null ) => client.Rollup.GetIndexCapabilities(index, selector);
///<summary>Index pattern</summary> public DeprecationInfoDescriptor Index(IndexName index) => Assign(index, (a, v) => a.RouteValues.Optional("index", v));
/// <inheritdoc /> public ValidateJobDescriptor <T> ResultsIndexName(IndexName indexName) => Assign(a => a.ResultsIndexName = indexName);
public FieldLookupDescriptor <T> Index(IndexName index) => Assign(a => a.Index = index);
public string IndexName(IndexName index) => IndexNameResolver.Resolve(index);
/// <summary> /// Shortcut into the Bulk call that indexes the specified objects /// <para> </para> /// https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html /// </summary> /// <param name="client"></param> /// <typeparam name="T">The type used to infer the default index and typename</typeparam> /// <param name="objects">List of objects to index, Id will be inferred (Id property or IdProperty attribute on type)</param> /// <param name="index">Override the inferred indexname for T</param> /// <param name="type">Override the inferred typename for T</param> public static Task <BulkResponse> IndexManyAsync <T>(this IElasticClient client, IEnumerable <T> objects, IndexName index = null, CancellationToken cancellationToken = default ) where T : class { var bulkRequest = CreateIndexBulkRequest(objects, index); return(client.BulkAsync(bulkRequest, cancellationToken)); }
public IndexActionDescriptor Index(IndexName index) => Assign(index, (a, v) => a.Index = v);
///<summary>/{index}/_ccr/follow</summary> ///<param name = "index">this parameter is required</param> public CreateFollowIndexRequest(IndexName index) : base(r => r.Required("index", index)) { }
public AliasRemoveIndexDescriptor Index(IndexName index) { Self.RemoveIndex.Index = index; return(this); }
/// <inheritdoc /> public Task <CreateIndexResponse> CreateIndexAsync( IndexName index, Func <CreateIndexDescriptor, ICreateIndexRequest> selector = null, CancellationToken cancellationToken = default ) => CreateIndexAsync(selector.InvokeOrDefault(new CreateIndexDescriptor(index)));
/// <inheritdoc/> public Task <IIndicesOperationResponse> CreateIndexAsync(IndexName index, Func <CreateIndexDescriptor, ICreateIndexRequest> selector = null) => this.CreateIndexAsync(selector.InvokeOrDefault(new CreateIndexDescriptor(index)));