Skip to content

Commit

Permalink
Fix index inference for requests with index/indices parameter (#8170
Browse files Browse the repository at this point in the history
) (#8172)

Co-authored-by: Florian Bernd <git@flobernd.de>
  • Loading branch information
github-actions[bot] and flobernd committed Apr 26, 2024
1 parent 018c8b7 commit 01b0bfe
Show file tree
Hide file tree
Showing 36 changed files with 1,310 additions and 45 deletions.
Expand Up @@ -164,7 +164,7 @@ public BulkRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.IndexName?
{
}

public BulkRequestDescriptor()
public BulkRequestDescriptor() : this(typeof(TDocument))
{
}

Expand Down
Expand Up @@ -121,7 +121,7 @@ public AnalyzeIndexRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.In
{
}

public AnalyzeIndexRequestDescriptor()
public AnalyzeIndexRequestDescriptor() : this(typeof(TDocument))
{
}

Expand Down
Expand Up @@ -112,6 +112,10 @@ public CreateIndexRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Ind
{
}

public CreateIndexRequestDescriptor() : this(typeof(TDocument))
{
}

internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementCreate;

protected override HttpMethod StaticHttpMethod => HttpMethod.PUT;
Expand Down
Expand Up @@ -133,7 +133,7 @@ public RolloverRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.IndexA
{
}

public RolloverRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.IndexAlias alias) : base(r => r.Required("alias", alias))
public RolloverRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.IndexAlias alias) : this(alias, typeof(TDocument))
{
}

Expand Down
Expand Up @@ -165,7 +165,7 @@ public MultiGetRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.IndexN
{
}

public MultiGetRequestDescriptor()
public MultiGetRequestDescriptor() : this(typeof(TDocument))
{
}

Expand Down
Expand Up @@ -198,7 +198,7 @@ public MultiTermVectorsRequestDescriptor(Elastic.Clients.Elasticsearch.Serverles
{
}

public MultiTermVectorsRequestDescriptor()
public MultiTermVectorsRequestDescriptor() : this(typeof(TDocument))
{
}

Expand Down
Expand Up @@ -100,6 +100,10 @@ public TermsEnumRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Index
{
}

public TermsEnumRequestDescriptor() : this(typeof(TDocument))
{
}

internal override ApiUrls ApiUrls => ApiUrlLookup.NoNamespaceTermsEnum;

protected override HttpMethod StaticHttpMethod => HttpMethod.POST;
Expand Down
Expand Up @@ -423,6 +423,29 @@ public virtual Task<CreateIndexResponse> CreateAsync<TDocument>(Elastic.Clients.
return DoRequestAsync<CreateIndexRequestDescriptor<TDocument>, CreateIndexResponse, CreateIndexRequestParameters>(descriptor, cancellationToken);
}

/// <summary>
/// <para>Creates an index with optional settings and mappings.</para>
/// <para><see href="https://www.elastic.co/guide/en/elasticsearch/reference/8.13/indices-create-index.html">Learn more about this API in the Elasticsearch documentation.</see></para>
/// </summary>
public virtual Task<CreateIndexResponse> CreateAsync<TDocument>(CancellationToken cancellationToken = default)
{
var descriptor = new CreateIndexRequestDescriptor<TDocument>();
descriptor.BeforeRequest();
return DoRequestAsync<CreateIndexRequestDescriptor<TDocument>, CreateIndexResponse, CreateIndexRequestParameters>(descriptor, cancellationToken);
}

/// <summary>
/// <para>Creates an index with optional settings and mappings.</para>
/// <para><see href="https://www.elastic.co/guide/en/elasticsearch/reference/8.13/indices-create-index.html">Learn more about this API in the Elasticsearch documentation.</see></para>
/// </summary>
public virtual Task<CreateIndexResponse> CreateAsync<TDocument>(Action<CreateIndexRequestDescriptor<TDocument>> configureRequest, CancellationToken cancellationToken = default)
{
var descriptor = new CreateIndexRequestDescriptor<TDocument>();
configureRequest?.Invoke(descriptor);
descriptor.BeforeRequest();
return DoRequestAsync<CreateIndexRequestDescriptor<TDocument>, CreateIndexResponse, CreateIndexRequestParameters>(descriptor, cancellationToken);
}

/// <summary>
/// <para>Creates an index with optional settings and mappings.</para>
/// <para><see href="https://www.elastic.co/guide/en/elasticsearch/reference/8.13/indices-create-index.html">Learn more about this API in the Elasticsearch documentation.</see></para>
Expand Down
Expand Up @@ -3311,6 +3311,29 @@ public virtual Task<TermsEnumResponse> TermsEnumAsync<TDocument>(Elastic.Clients
return DoRequestAsync<TermsEnumRequestDescriptor<TDocument>, TermsEnumResponse, TermsEnumRequestParameters>(descriptor, cancellationToken);
}

/// <summary>
/// <para>The terms enum API can be used to discover terms in the index that begin with the provided string. It is designed for low-latency look-ups used in auto-complete scenarios.</para>
/// <para><see href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-terms-enum.html">Learn more about this API in the Elasticsearch documentation.</see></para>
/// </summary>
public virtual Task<TermsEnumResponse> TermsEnumAsync<TDocument>(CancellationToken cancellationToken = default)
{
var descriptor = new TermsEnumRequestDescriptor<TDocument>();
descriptor.BeforeRequest();
return DoRequestAsync<TermsEnumRequestDescriptor<TDocument>, TermsEnumResponse, TermsEnumRequestParameters>(descriptor, cancellationToken);
}

/// <summary>
/// <para>The terms enum API can be used to discover terms in the index that begin with the provided string. It is designed for low-latency look-ups used in auto-complete scenarios.</para>
/// <para><see href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-terms-enum.html">Learn more about this API in the Elasticsearch documentation.</see></para>
/// </summary>
public virtual Task<TermsEnumResponse> TermsEnumAsync<TDocument>(Action<TermsEnumRequestDescriptor<TDocument>> configureRequest, CancellationToken cancellationToken = default)
{
var descriptor = new TermsEnumRequestDescriptor<TDocument>();
configureRequest?.Invoke(descriptor);
descriptor.BeforeRequest();
return DoRequestAsync<TermsEnumRequestDescriptor<TDocument>, TermsEnumResponse, TermsEnumRequestParameters>(descriptor, cancellationToken);
}

/// <summary>
/// <para>The terms enum API can be used to discover terms in the index that begin with the provided string. It is designed for low-latency look-ups used in auto-complete scenarios.</para>
/// <para><see href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-terms-enum.html">Learn more about this API in the Elasticsearch documentation.</see></para>
Expand Down

0 comments on commit 01b0bfe

Please sign in to comment.