Skip to content
Merged
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
7 changes: 7 additions & 0 deletions src/Nest/XPack/Sql/ISqlRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information

using System.Collections.Generic;
using System.Runtime.Serialization;

namespace Nest
Expand All @@ -19,6 +20,12 @@ public interface ISqlRequest
[DataMember(Name ="filter")]
QueryContainer Filter { get; set; }

/// <summary>
/// Optional values for parameters in the query.
/// </summary>
[DataMember(Name = "params")]
IList<object> Params { get; set; }

/// <summary> The SQL query you want Elasticsearch to execute </summary>
[DataMember(Name ="query")]
string Query { get; set; }
Expand Down
20 changes: 14 additions & 6 deletions src/Nest/XPack/Sql/QuerySql/QuerySqlRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information

using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace Nest
Expand Down Expand Up @@ -51,6 +52,9 @@ public partial class QuerySqlRequest
/// <inheritdoc cref="ISqlRequest.Filter" />
public QueryContainer Filter { get; set; }

/// <inheritdoc cref="ISqlRequest.Params" />
public IList<object> Params { get; set; }

/// <inheritdoc cref="ISqlRequest.Query" />
public string Query { get; set; }

Expand All @@ -70,34 +74,38 @@ public partial class QuerySqlDescriptor
string IQuerySqlRequest.Cursor { get; set; }
int? ISqlRequest.FetchSize { get; set; }
QueryContainer ISqlRequest.Filter { get; set; }
IList<object> ISqlRequest.Params { get; set; }
string ISqlRequest.Query { get; set; }
IRuntimeFields ISqlRequest.RuntimeFields { get; set; }
string ISqlRequest.TimeZone { get; set; }
Time IQuerySqlRequest.WaitForCompletionTimeout { get; set; }

/// <inheritdoc cref="ISqlRequest.Params" />
public QuerySqlDescriptor Params(IEnumerable<object> parameters) => Assign(parameters, (a, v) => a.Params = v?.ToListOrNullIfEmpty());

/// <inheritdoc cref="ISqlRequest.Params" />
public QuerySqlDescriptor Params(IList<object> parameters) => Assign(parameters, (a, v) => a.Params = v);

/// <inheritdoc cref="ISqlRequest.Params" />
public QuerySqlDescriptor Params(params object[] parameters) => Assign(parameters, (a, v) => a.Params = v);

/// <inheritdoc cref="ISqlRequest.Query" />
/// >
public QuerySqlDescriptor Query(string query) => Assign(query, (a, v) => a.Query = v);

/// <inheritdoc cref="ISqlRequest.TimeZone" />
/// >
public QuerySqlDescriptor TimeZone(string timeZone) => Assign(timeZone, (a, v) => a.TimeZone = v);

/// <inheritdoc cref="ISqlRequest.FetchSize" />
/// >
public QuerySqlDescriptor FetchSize(int? fetchSize) => Assign(fetchSize, (a, v) => a.FetchSize = v);

/// <inheritdoc cref="ISqlRequest.Filter" />
/// >
public QuerySqlDescriptor Filter<T>(Func<QueryContainerDescriptor<T>, QueryContainer> querySelector)
where T : class => Assign(querySelector, (a, v) => a.Filter = v?.Invoke(new QueryContainerDescriptor<T>()));

/// <inheritdoc cref="IQuerySqlRequest.Cursor" />
/// >
public QuerySqlDescriptor Cursor(string cursor) => Assign(cursor, (a, v) => a.Cursor = v);

/// <inheritdoc cref="IQuerySqlRequest.Columnar" />
/// >
public QuerySqlDescriptor Columnar(bool? columnar = true) => Assign(columnar, (a, v) => a.Columnar = v);

/// <inheritdoc cref="ISqlRequest.RuntimeFields" />
Expand Down
18 changes: 14 additions & 4 deletions src/Nest/XPack/Sql/TranslateSql/TranslateSqlRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information

using System;
using System.Collections.Generic;
using Elasticsearch.Net.Specification.SqlApi;

namespace Nest
Expand All @@ -22,6 +23,9 @@ protected sealed override void RequestDefaults(TranslateSqlRequestParameters par
/// <inheritdoc cref="ISqlRequest.Filter" />
public QueryContainer Filter { get; set; }

/// <inheritdoc cref="ISqlRequest.Params" />
public IList<object> Params { get; set; }

/// <inheritdoc cref="ISqlRequest.Query" />
public string Query { get; set; }

Expand All @@ -39,24 +43,30 @@ protected sealed override void RequestDefaults(TranslateSqlRequestParameters par

int? ISqlRequest.FetchSize { get; set; }
QueryContainer ISqlRequest.Filter { get; set; }
IList<object> ISqlRequest.Params { get; set; }
string ISqlRequest.Query { get; set; }
string ISqlRequest.TimeZone { get; set; }
IRuntimeFields ISqlRequest.RuntimeFields { get; set; }

/// <inheritdoc cref="ISqlRequest.Params" />
public TranslateSqlDescriptor Params(IEnumerable<object> parameters) => Assign(parameters, (a, v) => a.Params = v?.ToListOrNullIfEmpty());

/// <inheritdoc cref="ISqlRequest.Params" />
public TranslateSqlDescriptor Params(IList<object> parameters) => Assign(parameters, (a, v) => a.Params = v);

/// <inheritdoc cref="ISqlRequest.Params" />
public TranslateSqlDescriptor Params(params object[] parameters) => Assign(parameters, (a, v) => a.Params = v);

/// <inheritdoc cref="ISqlRequest.Query" />
/// >
public TranslateSqlDescriptor Query(string query) => Assign(query, (a, v) => a.Query = v);

/// <inheritdoc cref="ISqlRequest.TimeZone" />
/// >
public TranslateSqlDescriptor TimeZone(string timeZone) => Assign(timeZone, (a, v) => a.TimeZone = v);

/// <inheritdoc cref="ISqlRequest.FetchSize" />
/// >
public TranslateSqlDescriptor FetchSize(int? fetchSize) => Assign(fetchSize, (a, v) => a.FetchSize = v);

/// <inheritdoc cref="ISqlRequest.Filter" />
/// >
public TranslateSqlDescriptor Filter<T>(Func<QueryContainerDescriptor<T>, QueryContainer> querySelector)
where T : class => Assign(querySelector, (a, v) => a.Filter = v?.Invoke(new QueryContainerDescriptor<T>()));

Expand Down