diff --git a/src/CodeGeneration/CodeGeneration.LowLevelClient/CodeGeneration.LowLevelClient.csproj b/src/CodeGeneration/CodeGeneration.LowLevelClient/CodeGeneration.LowLevelClient.csproj
index f91ec6ccb04..335dfc0c982 100644
--- a/src/CodeGeneration/CodeGeneration.LowLevelClient/CodeGeneration.LowLevelClient.csproj
+++ b/src/CodeGeneration/CodeGeneration.LowLevelClient/CodeGeneration.LowLevelClient.csproj
@@ -77,6 +77,7 @@
+
diff --git a/src/CodeGeneration/CodeGeneration.LowLevelClient/Overrides/Descriptors/DeleteWarmerDescriptorOverrides.cs b/src/CodeGeneration/CodeGeneration.LowLevelClient/Overrides/Descriptors/DeleteWarmerDescriptorOverrides.cs
new file mode 100644
index 00000000000..9242f327cd6
--- /dev/null
+++ b/src/CodeGeneration/CodeGeneration.LowLevelClient/Overrides/Descriptors/DeleteWarmerDescriptorOverrides.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace CodeGeneration.LowLevelClient.Overrides.Descriptors
+{
+ public class DeleteWarmerDescriptorOverrides : IDescriptorOverrides
+ {
+ public IEnumerable SkipQueryStringParams
+ {
+ get
+ {
+ return new string[]
+ {
+ "name"
+ };
+ }
+ }
+ }
+}
diff --git a/src/CodeGeneration/CodeGeneration.LowLevelClient/Overrides/Descriptors/SearchDescriptorOverrides.cs b/src/CodeGeneration/CodeGeneration.LowLevelClient/Overrides/Descriptors/SearchDescriptorOverrides.cs
index 19d11e63e0a..596a03e8f30 100644
--- a/src/CodeGeneration/CodeGeneration.LowLevelClient/Overrides/Descriptors/SearchDescriptorOverrides.cs
+++ b/src/CodeGeneration/CodeGeneration.LowLevelClient/Overrides/Descriptors/SearchDescriptorOverrides.cs
@@ -33,7 +33,10 @@ public IEnumerable SkipQueryStringParams
"version",
"q", //we dont support GET searches
"fields",
- "sort"
+ "sort",
+ "_source",
+ "_source_include",
+ "_source_exclude"
};
}
}
diff --git a/src/Nest/DSL/CountDescriptor.cs b/src/Nest/DSL/CountDescriptor.cs
index 13cc9fb2ddd..b5a151ed715 100644
--- a/src/Nest/DSL/CountDescriptor.cs
+++ b/src/Nest/DSL/CountDescriptor.cs
@@ -5,19 +5,17 @@
namespace Nest
{
[DescriptorFor("Count")]
- [JsonConverter(typeof(CustomJsonConverter))]
public partial class CountDescriptor
: QueryPathDescriptorBase, T, CountQueryString>
- , IActAsQuery
, IPathInfo
- , ICustomJson
where T : class
{
- BaseQuery IActAsQuery._Query { get; set; }
+ [JsonProperty("query")]
+ internal BaseQuery _Query { get; set; }
public CountDescriptor Query(Func, BaseQuery> querySelector)
{
- ((IActAsQuery)this)._Query = querySelector(new QueryDescriptor());
+ this._Query = querySelector(new QueryDescriptor());
return this;
}
@@ -31,10 +29,5 @@ ElasticsearchPathInfo IPathInfo.ToPathInfo(I
return pathInfo;
}
-
- object ICustomJson.GetCustomJson()
- {
- return ((IActAsQuery) this)._Query;
- }
}
}
diff --git a/src/Nest/DSL/FluentDictionary.cs b/src/Nest/DSL/FluentDictionary.cs
index c5dde9f4c18..7a5e30a5bd8 100644
--- a/src/Nest/DSL/FluentDictionary.cs
+++ b/src/Nest/DSL/FluentDictionary.cs
@@ -1,7 +1,23 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
+using System.Linq.Expressions;
+using Nest.Resolvers;
namespace Nest
{
+ public class FluentFieldList : List where T : class
+ {
+ public new FluentFieldList Add(Expression> k)
+ {
+ base.Add(k);
+ return this;
+ }
+ public new FluentFieldList Add(string k)
+ {
+ base.Add(k);
+ return this;
+ }
+ }
public class FluentDictionary : Dictionary
{
public FluentDictionary()
diff --git a/src/Nest/DSL/IQueryDescriptor.cs b/src/Nest/DSL/IQueryDescriptor.cs
index c6c2aa0286e..2178d6e6351 100644
--- a/src/Nest/DSL/IQueryDescriptor.cs
+++ b/src/Nest/DSL/IQueryDescriptor.cs
@@ -41,9 +41,6 @@ interface IQueryDescriptor
BaseQuery Terms(string field, params string[] terms);
BaseQuery TermsDescriptor(Action> selector);
BaseQuery TermsDescriptor(Action> selector);
- BaseQuery Text(Action> selector);
- BaseQuery TextPhrase(Action> selector);
- BaseQuery TextPhrasePrefix(Action> selector);
BaseQuery Match(Action> selector);
BaseQuery MatchPhrase(Action> selector);
BaseQuery MatchPhrasePrefix(Action> selector);
diff --git a/src/Nest/DSL/PartialFieldDescriptor.cs b/src/Nest/DSL/PartialFieldDescriptor.cs
deleted file mode 100644
index 6aae14e6782..00000000000
--- a/src/Nest/DSL/PartialFieldDescriptor.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System.Linq.Expressions;
-using Nest.Resolvers;
-using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace Nest
-{
- public class PartialFieldDescriptor where T : class
- {
- internal string _Field { get; set; }
-
- [JsonProperty("include")]
- internal IEnumerable _Include { get; set; }
-
- [JsonProperty("exclude")]
- internal IEnumerable _Exclude { get; set; }
-
- public PartialFieldDescriptor PartialField(string field)
- {
- this._Field = field;
- return this;
- }
-
- public PartialFieldDescriptor Include(params string[] paths)
- {
- this._Include = paths.Select(p => (PropertyPathMarker) p);
- return this;
- }
-
- public PartialFieldDescriptor Exclude(params string[] paths)
- {
- this._Exclude = paths.Select(p => (PropertyPathMarker) p);
- return this;
- }
- public PartialFieldDescriptor Include(params Expression>[] paths)
- {
- this._Include = paths.Select(p => (PropertyPathMarker) p);
- return this;
- }
- public PartialFieldDescriptor Exclude(params Expression>[] paths)
- {
- this._Exclude = paths.Select(p => (PropertyPathMarker) p);
- return this;
- }
- }
-}
diff --git a/src/Nest/DSL/Query/RawQuery.cs b/src/Nest/DSL/Query/RawQuery.cs
deleted file mode 100644
index be2042cc326..00000000000
--- a/src/Nest/DSL/Query/RawQuery.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Linq.Expressions;
-using Nest.Resolvers;
-using Newtonsoft.Json.Serialization;
-using Newtonsoft.Json;
-using Nest.Resolvers.Converters;
-
-namespace Nest
-{
- [JsonConverter(typeof(CustomJsonConverter))]
- [JsonObject(MemberSerialization = MemberSerialization.OptIn)]
- public class RawQuery : IQuery, ICustomJson
- {
- internal object Json { get; set; }
- bool IQuery.IsConditionless { get { return this.Json == null || this.Json.ToString().IsNullOrEmpty(); } }
-
- object ICustomJson.GetCustomJson()
- {
- return this.Json;
- }
- }
-}
diff --git a/src/Nest/DSL/Query/TextPhrasePrefixQueryDescriptor.cs b/src/Nest/DSL/Query/TextPhrasePrefixQueryDescriptor.cs
deleted file mode 100644
index acd7d43d1a8..00000000000
--- a/src/Nest/DSL/Query/TextPhrasePrefixQueryDescriptor.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Converters;
-using System.Linq.Expressions;
-
-namespace Nest
-{
- ///
- /// A Query that matches documents containing a particular sequence of terms.
- /// It allows for prefix matches on the last term in the text.
- ///
- /// Type of document
- public class TextPhrasePrefixQueryDescriptor : TextQueryDescriptor where T : class
- {
- [JsonProperty(PropertyName = "type")]
- internal override string _Type { get { return "phrase_prefix"; } }
- }
-}
diff --git a/src/Nest/DSL/Query/TextPhraseQueryDescriptor.cs b/src/Nest/DSL/Query/TextPhraseQueryDescriptor.cs
deleted file mode 100644
index c4ad63f1219..00000000000
--- a/src/Nest/DSL/Query/TextPhraseQueryDescriptor.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Converters;
-using System.Linq.Expressions;
-
-namespace Nest
-{
- ///
- /// A Query that matches documents containing a particular sequence of terms. A PhraseQuery is built by QueryParser for input like "new york".
- ///
- /// Type of document
- public class TextPhraseQueryDescriptor : TextQueryDescriptor where T : class
- {
- [JsonProperty(PropertyName = "type")]
- internal override string _Type { get { return "phrase"; } }
- }
-}
diff --git a/src/Nest/DSL/Query/TextQueryDescriptor.cs b/src/Nest/DSL/Query/TextQueryDescriptor.cs
deleted file mode 100644
index 9e1045ce092..00000000000
--- a/src/Nest/DSL/Query/TextQueryDescriptor.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Converters;
-using System.Linq.Expressions;
-using Nest.Resolvers;
-
-namespace Nest
-{
- [JsonObject(MemberSerialization = MemberSerialization.OptIn)]
- public class TextQueryDescriptor : IQuery where T : class
- {
- [JsonProperty(PropertyName = "type")]
- internal virtual string _Type { get { return null; } }
-
- [JsonProperty(PropertyName = "query")]
- internal string _Query { get; set; }
-
- [JsonProperty(PropertyName = "analyzer")]
- internal string _Analyzer { get; set; }
-
- [JsonProperty(PropertyName = "fuzziness")]
- internal double? _Fuzziness { get; set; }
-
- [JsonProperty(PropertyName = "prefix_length")]
- internal int? _PrefixLength { get; set; }
-
- [JsonProperty(PropertyName = "max_expansions")]
- internal int? _MaxExpansions { get; set; }
-
- [JsonProperty(PropertyName = "slop")]
- internal int? _Slop { get; set; }
-
- [JsonProperty(PropertyName = "boost")]
- internal double? _Boost { get; set; }
-
- [JsonProperty(PropertyName = "operator")]
- [JsonConverter(typeof(StringEnumConverter))]
- internal Operator? _Operator { get; set; }
-
- bool IQuery.IsConditionless
- {
- get
- {
- return this._Field.IsConditionless() || this._Query.IsNullOrEmpty();
- }
- }
-
- internal PropertyPathMarker _Field { get; set; }
- public TextQueryDescriptor OnField(string field)
- {
- this._Field = field;
- return this;
- }
- public TextQueryDescriptor OnField(Expression> objectPath)
- {
- this._Field = objectPath;
- return this;
- }
-
- public TextQueryDescriptor Query(string query)
- {
- this._Query = query;
- return this;
- }
- public TextQueryDescriptor Analyzer(string analyzer)
- {
- this._Analyzer = analyzer;
- return this;
- }
- public TextQueryDescriptor Fuzziness(double fuzziness)
- {
- this._Fuzziness = fuzziness;
- return this;
- }
- public TextQueryDescriptor Boost(double boost)
- {
- this._Boost = boost;
- return this;
- }
- public TextQueryDescriptor PrefixLength(int prefixLength)
- {
- this._PrefixLength = prefixLength;
- return this;
- }
- public TextQueryDescriptor MaxExpansions(int maxExpansions)
- {
- this._MaxExpansions = maxExpansions;
- return this;
- }
- public TextQueryDescriptor Slop(int slop)
- {
- this._Slop = slop;
- return this;
- }
- public TextQueryDescriptor Operator(Operator op)
- {
- this._Operator = op;
- return this;
- }
- }
-}
diff --git a/src/Nest/DSL/QueryDescriptor.cs b/src/Nest/DSL/QueryDescriptor.cs
index b8cb2361176..0da87a80be6 100644
--- a/src/Nest/DSL/QueryDescriptor.cs
+++ b/src/Nest/DSL/QueryDescriptor.cs
@@ -281,52 +281,6 @@ public BaseQuery FuzzyDate(Action> selector)
return this.New(query, q => q.FuzzyQueryDescriptor = fuzzy);
}
- ///
- /// The default text query is of type boolean. It means that the text provided is analyzed and the analysis
- /// process constructs a boolean query from the provided text.
- ///
- public BaseQuery Text(Action> selector)
- {
- var query = new TextQueryDescriptor();
- selector(query);
-
- var text = new Dictionary()
- {
- { query._Field, query}
- };
- return this.New(query, q => q.TextQueryDescriptor = text);
- }
-
- ///
- /// The text_phrase query analyzes the text and creates a phrase query out of the analyzed text.
- ///
- public BaseQuery TextPhrase(Action> selector)
- {
- var query = new TextPhraseQueryDescriptor();
- selector(query);
-
- var text = new Dictionary()
- {
- { query._Field, query}
- };
- return this.New(query, q => q.TextQueryDescriptor = text);
- }
-
- ///
- /// The text_phrase_prefix is the same as text_phrase, expect it allows for prefix matches on the last term
- /// in the text
- ///
- public BaseQuery TextPhrasePrefix(Action> selector)
- {
- var query = new TextPhrasePrefixQueryDescriptor();
- selector(query);
-
- var text = new Dictionary()
- {
- { query._Field, query}
- };
- return this.New(query, q => q.TextQueryDescriptor = text);
- }
///
/// The default text query is of type boolean. It means that the text provided is analyzed and the analysis
diff --git a/src/Nest/DSL/Search/SourceDescriptor.cs b/src/Nest/DSL/Search/SourceDescriptor.cs
new file mode 100644
index 00000000000..e8794992e8c
--- /dev/null
+++ b/src/Nest/DSL/Search/SourceDescriptor.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Text;
+using Nest.Resolvers;
+using Newtonsoft.Json;
+
+namespace Nest.DSL.Search
+{
+ public class SourceDescriptor where T : class
+ {
+ [JsonProperty("include")]
+ internal IEnumerable _Include { get; set; }
+
+ [JsonProperty("exclude")]
+ internal IEnumerable _Exclude { get; set; }
+
+ public SourceDescriptor Include(params string[] fields)
+ {
+ this._Include = fields.Select(f => (PropertyPathMarker) f).ToList();
+ return this;
+ }
+ public SourceDescriptor Include(params Expression>[] fields)
+ {
+ this._Include = fields.Select(f => (PropertyPathMarker) f).ToList();
+ return this;
+ }
+ public SourceDescriptor Include(Func, FluentFieldList> fields)
+ {
+ this._Include = fields(new FluentFieldList()).ToList();
+ return this;
+ }
+ public SourceDescriptor Exclude(params string[] fields)
+ {
+ this._Exclude = fields.Select(f => (PropertyPathMarker) f).ToList();
+ return this;
+ }
+ public SourceDescriptor Exclude(params Expression>[] fields)
+ {
+ this._Exclude = fields.Select(f => (PropertyPathMarker) f).ToList();
+ return this;
+ }
+ public SourceDescriptor Exclude(Func, FluentFieldList> fields)
+ {
+ this._Exclude = fields(new FluentFieldList()).ToList();
+ return this;
+ }
+ }
+}
diff --git a/src/Nest/DSL/SearchDescriptor.cs b/src/Nest/DSL/SearchDescriptor.cs
index 30880e2f55d..aaa043464aa 100644
--- a/src/Nest/DSL/SearchDescriptor.cs
+++ b/src/Nest/DSL/SearchDescriptor.cs
@@ -3,6 +3,7 @@
using System.Linq;
using System.Security.Cryptography;
using System.Text;
+using Nest.DSL.Search;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Nest.Resolvers.Converters;
@@ -280,10 +281,20 @@ internal RawOrFilterDescriptor _FilterOrRaw
[JsonConverter(typeof(DictionaryKeysAreNotPropertyNamesJsonConverter))]
internal FluentDictionary _ScriptFields { get; set; }
- [JsonProperty(PropertyName = "partial_fields")]
- [JsonConverter(typeof(DictionaryKeysAreNotPropertyNamesJsonConverter))]
- internal Dictionary> _PartialFields { get; set; }
+ [JsonProperty(PropertyName = "_source")]
+ internal object _Source { get; set; }
+ public SearchDescriptor Source(bool include = true)
+ {
+ this._Source = include;
+ return this;
+ }
+
+ public SearchDescriptor Source(Func, SourceDescriptor> sourceSelector)
+ {
+ this._Source = sourceSelector(new SourceDescriptor());
+ return this;
+ }
///
/// The number of hits to return. Defaults to 10. When using scroll search type
/// size is actually multiplied by the number of shards!
@@ -449,6 +460,16 @@ public SearchDescriptor Fields(params Expression>[] expressio
this._Fields = expressions.Select(e => (PropertyPathMarker)e).ToList();
return this;
}
+
+ ///
+ /// Allows to selectively load specific fields for each document
+ /// represented by a search hit. Defaults to load the internal _source field.
+ ///
+ public SearchDescriptor Fields(Func, FluentFieldList> properties)
+ {
+ this._Fields = properties(new FluentFieldList()).ToList();
+ return this;
+ }
///
/// Allows to selectively load specific fields for each document
/// represented by a search hit. Defaults to load the internal _source field.
@@ -480,30 +501,6 @@ public SearchDescriptor ScriptFields(
return this;
}
- public SearchDescriptor PartialFields(params Action>[] partialFieldDescriptor)
- {
- if (this._PartialFields == null)
- this._PartialFields = new Dictionary>();
-
- var descriptors = new List>();
-
- foreach (var selector in partialFieldDescriptor)
- {
- var filter = new PartialFieldDescriptor();
- selector(filter);
- descriptors.Add(filter);
- }
-
- foreach (var d in descriptors)
- {
- var key = d._Field;
- if (string.IsNullOrEmpty(key))
- throw new DslException("Could not infer key for highlight field descriptor");
-
- this._PartialFields.Add(key, d);
- }
- return this;
- }
///
/// Allows to add one or more sort on specific fields. Each sort can be reversed as well.
diff --git a/src/Nest/DSL/_Descriptors.generated.cs b/src/Nest/DSL/_Descriptors.generated.cs
index 093b86565db..49f96aa9e20 100644
--- a/src/Nest/DSL/_Descriptors.generated.cs
+++ b/src/Nest/DSL/_Descriptors.generated.cs
@@ -2284,14 +2284,6 @@ public DeleteWarmerDescriptor MasterTimeout(string master_timeout)
return this;
}
-
- ///A comma-separated list of warmer names to delete (supports wildcards); use `_all` to delete all warmers in the specified indices. You must specify a name either in the uri or in the parameters.
- public DeleteWarmerDescriptor Name(params string[] name)
- {
- this._QueryString.Name(name);
- return this;
- }
-
}
@@ -4464,30 +4456,6 @@ public SearchDescriptor Source(string source)
}
- ///True or false to return the _source field or not, or a list of fields to return
- public SearchDescriptor Source(params string[] _source)
- {
- this._QueryString.Source(_source);
- return this;
- }
-
-
- ///A list of fields to exclude from the returned _source field
- public SearchDescriptor SourceExclude(params string[] _source_exclude)
- {
- this._QueryString.SourceExclude(_source_exclude);
- return this;
- }
-
-
- ///A list of fields to extract and return from the _source field
- public SearchDescriptor SourceInclude(params string[] _source_include)
- {
- this._QueryString.SourceInclude(_source_include);
- return this;
- }
-
-
///Specific 'tag' of the request for logging and statistical purposes
public SearchDescriptor Stats(params string[] stats)
{
diff --git a/src/Nest/Domain/Connection/AsyncRequestOperation.cs b/src/Nest/Domain/Connection/AsyncRequestOperation.cs
new file mode 100644
index 00000000000..b36ac9f9e4e
--- /dev/null
+++ b/src/Nest/Domain/Connection/AsyncRequestOperation.cs
@@ -0,0 +1,143 @@
+using System;
+using System.IO;
+using System.Net;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Nest.Domain.Connection;
+
+namespace Nest
+{
+ public class AsyncRequestOperation : TaskCompletionSource, IDisposable
+ {
+ private readonly HttpWebRequest m_request;
+ private readonly string m_requestData;
+ private readonly IConnectionSettings m_connectionSettings;
+ private ConnectionStatusTracer m_tracer;
+ private WebResponse m_response;
+ private Stream m_responseStream;
+
+ public AsyncRequestOperation(HttpWebRequest request, string requestData, IConnectionSettings connectionSettings, ConnectionStatusTracer tracer)
+ {
+ m_request = request;
+ m_requestData = requestData;
+ m_connectionSettings = connectionSettings;
+ m_tracer = tracer;
+ Start();
+ }
+
+ private void Start()
+ {
+ if (this.m_requestData != null)
+ WriteRequestDataAsync();
+ else
+ GetResponseAsync();
+ }
+
+ private void WriteRequestDataAsync()
+ {
+ this.m_request.BeginGetRequestStream(this.Monitor(ar =>
+ {
+ var r = this.m_request.EndGetRequestStream(ar);
+ var buffer = Encoding.UTF8.GetBytes(this.m_requestData);
+ r.BeginWrite(buffer, 0, buffer.Length, this.Monitor(writeIar =>
+ {
+ r.EndWrite(writeIar);
+ GetResponseAsync();
+ }), null);
+ }), null);
+ }
+
+ private void GetResponseAsync()
+ {
+ this.m_request.BeginGetResponse(this.Monitor(iarResponse =>
+ {
+ m_response = m_request.EndGetResponse(iarResponse);
+ m_responseStream = m_response.GetResponseStream();
+
+ var buffer = new byte[8192];
+ var result = new MemoryStream(buffer.Length);
+ ReadResponseStreamAsync(this.m_responseStream, buffer, result);
+
+ }), null);
+ }
+
+ private void ReadResponseStreamAsync(Stream stream, byte[] buffer, MemoryStream result)
+ {
+ stream.BeginRead(buffer, 0, buffer.Length, this.Monitor(iar =>
+ {
+ var bytes = stream.EndRead(iar);
+ if (bytes == 0)
+ {
+ Done(result);
+ return;
+ }
+
+ result.Write(buffer, 0, bytes);
+ ReadResponseStreamAsync(stream, buffer, result);
+
+ }), null);
+ }
+
+ private void Done(ConnectionStatus connectionStatus)
+ {
+ m_tracer.SetResult(connectionStatus);
+ TrySetResult(connectionStatus);
+ Dispose();
+ }
+
+ private void Done(Stream result)
+ {
+ result.Position = 0;
+ var reader = new StreamReader(result);
+ Done(new ConnectionStatus(this.m_connectionSettings, reader.ReadToEnd())
+ {
+ Request = this.m_requestData,
+ RequestUrl = this.m_request.RequestUri.ToString(),
+ RequestMethod = this.m_request.Method
+ });
+
+ }
+
+ private AsyncCallback Monitor(AsyncCallback callback)
+ {
+ return ar =>
+ {
+ try
+ {
+ callback(ar);
+ }
+ catch (WebException webException)
+ {
+ var connectionStatus = new ConnectionStatus(this.m_connectionSettings, webException)
+ {
+ Request = this.m_requestData,
+ RequestUrl = this.m_request.RequestUri.ToString(),
+ RequestMethod = this.m_request.Method
+ };
+ m_connectionSettings.ConnectionStatusHandler(connectionStatus);
+ Done(connectionStatus);
+ }
+ catch (Exception e)
+ {
+ TrySetException(e);
+ Dispose();
+ }
+ };
+ }
+
+ public void Dispose()
+ {
+ Dispose(ref m_response);
+ Dispose(ref m_responseStream);
+ Dispose(ref m_tracer);
+ }
+
+ private static void Dispose(ref T disposable) where T : class, IDisposable
+ {
+ var d = Interlocked.Exchange(ref disposable, null);
+ if (d != null)
+ d.Dispose();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Nest/Domain/CovariantDictionary.cs b/src/Nest/Domain/CovariantDictionary.cs
deleted file mode 100644
index d94da70fe2f..00000000000
--- a/src/Nest/Domain/CovariantDictionary.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace Nest
-{
- public interface ICovariantDictionary where T : class
- {
- T this[string key] { get; }
-
- IEnumerable> Items { get; }
- }
-
- public interface ICovariantItem where T : class
- {
- string Key { get; }
- T Value { get; }
- }
-
- public class CovariantDictionary : ICovariantDictionary where T : class
- {
- public T this[string key]
- {
- get
- {
- var pair = this.Items.EmptyIfNull().FirstOrDefault(x => x.Key == key);
- return pair == null ? null : pair.Value;
- }
- }
-
- public IEnumerable> Items { get; internal set; }
- }
-
- public class CovariantItem : ICovariantItem
- where T : class
- {
- public string Key { get; internal set; }
- public T Value { get; internal set; }
- }
-}
diff --git a/src/Nest/Domain/DSL/Query.cs b/src/Nest/Domain/DSL/Query.cs
index 40a0762f882..66b2d9d2c01 100644
--- a/src/Nest/Domain/DSL/Query.cs
+++ b/src/Nest/Domain/DSL/Query.cs
@@ -201,20 +201,6 @@ public static BaseQuery TermsDescriptor(Action> se
return new QueryDescriptor().TermsDescriptor(selector);
}
- public static BaseQuery Text(Action> selector)
- {
- return new QueryDescriptor().Text(selector);
- }
-
- public static BaseQuery TextPhrase(Action> selector)
- {
- return new QueryDescriptor().TextPhrase(selector);
- }
-
- public static BaseQuery TextPhrasePrefix(Action> selector)
- {
- return new QueryDescriptor().TextPhrasePrefix(selector);
- }
public static BaseQuery Match(Action> selector)
{
diff --git a/src/Nest/Domain/FieldSelection.cs b/src/Nest/Domain/FieldSelection.cs
index 3d321e90a8a..8cefc30df99 100644
--- a/src/Nest/Domain/FieldSelection.cs
+++ b/src/Nest/Domain/FieldSelection.cs
@@ -11,7 +11,7 @@
namespace Nest.Domain
{
- public interface IFieldSelection
+ public interface IFieldSelection
{
}
@@ -34,15 +34,15 @@ internal FieldSelection(ElasticInferrer inferrer, IDictionary va
[JsonConverter(typeof(DictionaryKeysAreNotPropertyNamesJsonConverter))]
internal IDictionary FieldValues { get; set; }
- public K FieldValue(Expression> objectPath)
+ public K[] FieldValue(Expression> objectPath)
{
var path = this.Infer.PropertyPath(objectPath);
- return this.FieldValue(path);
+ return this.FieldValue(path);
}
- public K FieldValue(Expression> objectPath)
+ public K[] FieldValue(Expression> objectPath)
{
var path = this.Infer.PropertyPath(objectPath);
- return this.FieldValue(path);
+ return this.FieldValue(path);
}
public K FieldValue(string path)
diff --git a/src/Nest/Domain/Hit/Hit.cs b/src/Nest/Domain/Hit/Hit.cs
index fdf65118666..c47378d1adb 100644
--- a/src/Nest/Domain/Hit/Hit.cs
+++ b/src/Nest/Domain/Hit/Hit.cs
@@ -2,51 +2,53 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using Nest.Domain;
using Newtonsoft.Json;
namespace Nest
{
//[JsonConverter(typeof(ConcreteTypeConverter))]
- public interface IHit where T : class
- {
- T Fields { get; }
- T Source { get; }
- string Index { get; }
- double Score { get; }
- string Type { get; }
- string Version { get; }
- string Id { get; }
+ public interface IHit where T : class
+ {
+ //IFieldSelection Fields { get; }
+ T Source { get; }
+ string Index { get; }
+ double Score { get; }
+ string Type { get; }
+ string Version { get; }
+ string Id { get; }
- IEnumerable
/// defaults to clearing all the caches on all indices
- public IIndicesResponse ClearCache(Func selector = null)
+ public IShardsOperationResponse ClearCache(Func selector = null)
{
selector = selector ?? (s => s);
- return this.Dispatch(
+ return this.Dispatch(
selector,
(p, d)=> this.RawDispatch.IndicesClearCacheDispatch(p)
);
@@ -25,10 +25,10 @@ public IIndicesResponse ClearCache(Func
/// defaults to clearing all the caches on all indices
- public Task ClearCacheAsync(Func selector = null)
+ public Task ClearCacheAsync(Func selector = null)
{
selector = selector ?? (s => s);
- return this.DispatchAsync(
+ return this.DispatchAsync(
selector,
(p, d)=> this.RawDispatch.IndicesClearCacheDispatchAsync(p)
);
diff --git a/src/Nest/ElasticClient-Flush.cs b/src/Nest/ElasticClient-Flush.cs
index 0eee4dc4d89..98c44816561 100644
--- a/src/Nest/ElasticClient-Flush.cs
+++ b/src/Nest/ElasticClient-Flush.cs
@@ -6,17 +6,17 @@ namespace Nest
{
public partial class ElasticClient
{
- public IIndicesOperationResponse Flush(Func selector)
+ public IShardsOperationResponse Flush(Func selector)
{
- return this.Dispatch(
+ return this.Dispatch(
selector,
(p, d) => this.RawDispatch.IndicesFlushDispatch(p)
);
}
- public Task FlushAsync(Func selector)
+ public Task FlushAsync(Func selector)
{
- return this.DispatchAsync(
+ return this.DispatchAsync(
selector,
(p, d) => this.RawDispatch.IndicesFlushDispatchAsync(p)
);
diff --git a/src/Nest/ElasticClient-MappingIndex.cs b/src/Nest/ElasticClient-MappingIndex.cs
index b6ff3c5f0ef..cf12af3e1be 100644
--- a/src/Nest/ElasticClient-MappingIndex.cs
+++ b/src/Nest/ElasticClient-MappingIndex.cs
@@ -17,7 +17,7 @@ public partial class ElasticClient
public IIndexSettingsResponse GetIndexSettings(Func selector)
{
return this.Dispatch(
- selector,
+ s=> selector(s.FlatSettings()),
(p, d) => this.RawDispatch.IndicesGetSettingsDispatch(p),
(c, d) => this.Serializer.DeserializeIndexSettingsResponse(c)
);
@@ -26,7 +26,7 @@ public IIndexSettingsResponse GetIndexSettings(Func GetIndexSettingsAsync(Func selector)
{
return this.DispatchAsync(
- selector,
+ s=> selector(s.FlatSettings()),
(p, d) => this.RawDispatch.IndicesGetSettingsDispatchAsync(p),
(c, d) => this.Serializer.DeserializeIndexSettingsResponse(c)
);
diff --git a/src/Nest/ElasticClient-Optimize.cs b/src/Nest/ElasticClient-Optimize.cs
index 82d6e8f283f..cf87a81915b 100644
--- a/src/Nest/ElasticClient-Optimize.cs
+++ b/src/Nest/ElasticClient-Optimize.cs
@@ -7,19 +7,19 @@ namespace Nest
public partial class ElasticClient
{
- public IIndicesOperationResponse Optimize(Func optimizeSelector = null)
+ public IShardsOperationResponse Optimize(Func optimizeSelector = null)
{
optimizeSelector = optimizeSelector ?? (s => s);
- return this.Dispatch(
+ return this.Dispatch(
optimizeSelector,
(p,d) => this.RawDispatch.IndicesOptimizeDispatch(p)
);
}
- public Task OptimizeAsync(Func optimizeSelector = null)
+ public Task OptimizeAsync(Func optimizeSelector = null)
{
optimizeSelector = optimizeSelector ?? (s => s);
- return this.DispatchAsync(
+ return this.DispatchAsync(
optimizeSelector,
(p,d) => this.RawDispatch.IndicesOptimizeDispatchAsync(p)
);
diff --git a/src/Nest/ElasticClient-Refresh.cs b/src/Nest/ElasticClient-Refresh.cs
index 7e14df7da88..b8d762d183b 100644
--- a/src/Nest/ElasticClient-Refresh.cs
+++ b/src/Nest/ElasticClient-Refresh.cs
@@ -7,19 +7,19 @@ namespace Nest
public partial class ElasticClient
{
- public IIndicesShardResponse Refresh(Func refreshSelector = null)
+ public IShardsOperationResponse Refresh(Func refreshSelector = null)
{
refreshSelector = refreshSelector ?? (s => s);
- return this.Dispatch(
+ return this.Dispatch(
refreshSelector,
(p,d) => this.RawDispatch.IndicesRefreshDispatch(p)
);
}
- public Task RefreshAsync(Func refreshSelector = null)
+ public Task RefreshAsync(Func refreshSelector = null)
{
refreshSelector = refreshSelector ?? (s => s);
- return this.DispatchAsync(
+ return this.DispatchAsync(
refreshSelector,
(p,d)=> this.RawDispatch.IndicesRefreshDispatchAsync(p)
);
diff --git a/src/Nest/ElasticClient-Snapshot.cs b/src/Nest/ElasticClient-Snapshot.cs
index 4578fc9ea11..9205c49f69c 100644
--- a/src/Nest/ElasticClient-Snapshot.cs
+++ b/src/Nest/ElasticClient-Snapshot.cs
@@ -6,19 +6,19 @@ namespace Nest
{
public partial class ElasticClient
{
- public IIndicesShardResponse Snapshot(Func snapshotSelector = null)
+ public IShardsOperationResponse Snapshot(Func snapshotSelector = null)
{
snapshotSelector = snapshotSelector ?? (s => s);
- return this.Dispatch(
+ return this.Dispatch(
snapshotSelector,
(p, d) => this.RawDispatch.IndicesSnapshotIndexDispatch(p)
);
}
- public Task SnapshotAsync(Func snapshotSelector = null)
+ public Task SnapshotAsync(Func snapshotSelector = null)
{
snapshotSelector = snapshotSelector ?? (s => s);
- return this.DispatchAsync(
+ return this.DispatchAsync(
snapshotSelector,
(p, d) => this.RawDispatch.IndicesSnapshotIndexDispatchAsync(p)
);
diff --git a/src/Nest/ExposedInternals/ElasticSerializer.cs b/src/Nest/ExposedInternals/ElasticSerializer.cs
index de6206956cf..a3a69560076 100644
--- a/src/Nest/ExposedInternals/ElasticSerializer.cs
+++ b/src/Nest/ExposedInternals/ElasticSerializer.cs
@@ -125,10 +125,7 @@ public IQueryResponse DeserializeSearchResponse(ConnectionS
{
var types = (originalSearchDescriptor._Types ?? Enumerable.Empty())
.Where(t => t.Type != null);
- var partialFields = originalSearchDescriptor._PartialFields.EmptyIfNull().Select(x => x.Key);
- if (originalSearchDescriptor._ConcreteTypeSelector == null && (
- types.Any(t => t.Type != typeof(TResult)))
- || partialFields.Any())
+ if (originalSearchDescriptor._ConcreteTypeSelector == null && types.Any(t => t.Type != typeof(TResult)))
{
var inferrer = new ElasticInferrer(this._settings);
var typeDictionary = types
@@ -148,7 +145,7 @@ public IQueryResponse DeserializeSearchResponse(ConnectionS
return this.DeserializeInternal>(
status,
- piggyBackJsonConverter: new ConcreteTypeConverter(originalSearchDescriptor._ConcreteTypeSelector, partialFields)
+ piggyBackJsonConverter: new ConcreteTypeConverter(originalSearchDescriptor._ConcreteTypeSelector)
);
}
@@ -297,10 +294,11 @@ public TemplateResponse DeserializeTemplateResponse(ConnectionStatus c, GetTempl
};
}
+
public GetMappingResponse DeserializeGetMappingResponse(ConnectionStatus c)
{
var dict = c.Success
- ? c.Deserialize>()
+ ? c.Deserialize()
: null;
return new GetMappingResponse(c, dict);
diff --git a/src/Nest/IElasticClient.cs b/src/Nest/IElasticClient.cs
index a409af4dab6..9cb1516dbe6 100644
--- a/src/Nest/IElasticClient.cs
+++ b/src/Nest/IElasticClient.cs
@@ -36,10 +36,10 @@ Task UpdateAsync(Func, UpdateDescr
Task OpenIndexAsync(Func openIndexSelector);
IIndicesOperationResponse CloseIndex(Func closeIndexSelector);
Task CloseIndexAsync(Func closeIndexSelector);
- IIndicesShardResponse Snapshot(Func snapShotSelector = null);
- Task SnapshotAsync(Func snapShotSelector = null);
- IIndicesShardResponse Refresh(Func refreshSelector = null);
- Task RefreshAsync(Func refreshSelector = null);
+ IShardsOperationResponse Snapshot(Func snapShotSelector = null);
+ Task SnapshotAsync(Func snapShotSelector = null);
+ IShardsOperationResponse Refresh(Func refreshSelector = null);
+ Task RefreshAsync(Func refreshSelector = null);
ISegmentsResponse Segments(Func segmentsSelector = null);
Task SegmentsAsync(Func segmentsSelector = null);
IClusterStateResponse ClusterState(Func clusterStateSelector = null);
@@ -70,14 +70,14 @@ Task UpdateAsync(Func, UpdateDescr
Task GetMappingAsync(Func selector);
IIndicesResponse DeleteMapping(Func selector);
Task DeleteMappingAsync(Func selector);
- IIndicesOperationResponse Flush(Func selector);
- Task FlushAsync(Func selector);
+ IShardsOperationResponse Flush(Func selector);
+ Task FlushAsync(Func selector);
IIndexSettingsResponse GetIndexSettings(Func selector);
Task GetIndexSettingsAsync(Func selector);
IIndicesResponse DeleteIndex(Func selector);
Task DeleteIndexAsync(Func selector);
- IIndicesResponse ClearCache(Func selector = null);
- Task ClearCacheAsync(Func selector = null);
+ IShardsOperationResponse ClearCache(Func selector = null);
+ Task ClearCacheAsync(Func selector = null);
IIndicesOperationResponse CreateIndex(string index, Func createIndexSelector = null);
Task CreateIndexAsync(string index, Func createIndexSelector);
IRootInfoResponse RootNodeInfo(Func selector = null);
@@ -144,8 +144,8 @@ Task IndexAsync(T @object, Func, IndexDesc
Task IndexManyAsync(IEnumerable objects, string index = null, string type = null)
where T : class;
- IIndicesOperationResponse Optimize(Func optimizeSelector = null);
- Task OptimizeAsync(Func optimizeSelector = null);
+ IShardsOperationResponse Optimize(Func optimizeSelector = null);
+ Task OptimizeAsync(Func optimizeSelector = null);
IStatusResponse Status(Func selector = null);
Task StatusAsync(Func selector = null);
diff --git a/src/Nest/Nest.csproj b/src/Nest/Nest.csproj
index 730357dc3cb..01fc3ec557e 100644
--- a/src/Nest/Nest.csproj
+++ b/src/Nest/Nest.csproj
@@ -109,6 +109,7 @@
+
@@ -138,6 +139,7 @@
+
@@ -262,7 +264,6 @@
-
@@ -270,7 +271,6 @@
-
@@ -448,9 +448,6 @@
-
-
-
@@ -577,7 +574,6 @@
-
diff --git a/src/Nest/QueryStringParameters/FluentQueryString.cs b/src/Nest/QueryStringParameters/FluentQueryString.cs
index 28c13d8738d..ee29736c8c3 100644
--- a/src/Nest/QueryStringParameters/FluentQueryString.cs
+++ b/src/Nest/QueryStringParameters/FluentQueryString.cs
@@ -17,7 +17,7 @@ public abstract class FluentQueryString where T : FluentQueryString
public T Add(string name, object value)
{
- _QueryStringDictionary.Add(name, value);
+ _QueryStringDictionary[name] = value;
return (T)this;
}
diff --git a/src/Nest/QueryStringParameters/QueryStringParameters.Generated.cs b/src/Nest/QueryStringParameters/QueryStringParameters.Generated.cs
index e1b325fbdf5..8c6244d69ea 100644
--- a/src/Nest/QueryStringParameters/QueryStringParameters.Generated.cs
+++ b/src/Nest/QueryStringParameters/QueryStringParameters.Generated.cs
@@ -2601,16 +2601,6 @@ public DeleteWarmerQueryString MasterTimeout(string master_timeout)
return this;
}
-
- internal string[] _name { get; set; }
- ///A comma-separated list of warmer names to delete (supports wildcards); use `_all` to delete all warmers in the specified indices. You must specify a name either in the uri or in the parameters.
- public DeleteWarmerQueryString Name(params string[] name)
- {
- this._name = name;
- this.Add("name", this._name);
- return this;
- }
-
}
@@ -5042,36 +5032,6 @@ public SearchQueryString Source(string source)
}
- internal string[] __source { get; set; }
- ///True or false to return the _source field or not, or a list of fields to return
- public SearchQueryString Source(params string[] _source)
- {
- this.__source = _source;
- this.Add("_source", this.__source);
- return this;
- }
-
-
- internal string[] __source_exclude { get; set; }
- ///A list of fields to exclude from the returned _source field
- public SearchQueryString SourceExclude(params string[] _source_exclude)
- {
- this.__source_exclude = _source_exclude;
- this.Add("_source_exclude", this.__source_exclude);
- return this;
- }
-
-
- internal string[] __source_include { get; set; }
- ///A list of fields to extract and return from the _source field
- public SearchQueryString SourceInclude(params string[] _source_include)
- {
- this.__source_include = _source_include;
- this.Add("_source_include", this.__source_include);
- return this;
- }
-
-
internal string[] _stats { get; set; }
///Specific 'tag' of the request for logging and statistical purposes
public SearchQueryString Stats(params string[] stats)
diff --git a/src/Nest/RawElasticClient.cs b/src/Nest/RawElasticClient.cs
index b8bbfdc71da..9212b92ddd0 100644
--- a/src/Nest/RawElasticClient.cs
+++ b/src/Nest/RawElasticClient.cs
@@ -121,6 +121,10 @@ protected ConnectionStatus DoRequest(string method, string path, object data = n
private static byte[] _enter = Encoding.UTF8.GetBytes("\n");
private byte[] PostData(object data)
{
+ var bytes = data as byte[];
+ if (bytes != null)
+ return bytes;
+
var s = data as string;
if (s != null)
return s.Utf8Bytes();
diff --git a/src/Nest/Resolvers/Converters/ConcreteTypeConverter.cs b/src/Nest/Resolvers/Converters/ConcreteTypeConverter.cs
index 1aaba3500a3..43c8b936cf2 100644
--- a/src/Nest/Resolvers/Converters/ConcreteTypeConverter.cs
+++ b/src/Nest/Resolvers/Converters/ConcreteTypeConverter.cs
@@ -2,6 +2,7 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
+using Nest.Domain;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Nest.Resolvers;
@@ -46,23 +47,19 @@ internal class ConcreteTypeConverter : JsonConverter where T : class
{
internal readonly Type _baseType;
internal readonly Func, Type> _concreteTypeSelector;
- internal readonly IEnumerable _partialFields;
public override bool CanWrite { get { return false; } }
public override bool CanRead { get { return true; } }
public ConcreteTypeConverter() {}
- public ConcreteTypeConverter(Func, Type> concreteTypeSelector)
- : this(concreteTypeSelector, new string[0]) { }
- public ConcreteTypeConverter(Func, Type> concreteTypeSelector, IEnumerable partialFields)
+ public ConcreteTypeConverter(Func, Type> concreteTypeSelector)
{
concreteTypeSelector.ThrowIfNull("concreteTypeSelector");
this._baseType = typeof(T);
this._concreteTypeSelector = concreteTypeSelector;
- this._partialFields = partialFields;
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
@@ -76,20 +73,19 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
return GetUsingConcreteTypeConverter(reader, serializer, realConcreteConverter);
}
- var instance = typeof(Hit).CreateInstance();
+ var instance = (Hit)(typeof(Hit).CreateInstance());
serializer.Populate(reader, instance);
+ instance.Fields = new FieldSelection(elasticContractResolver.Infer, instance._fields);
return instance;
}
private static object GetUsingConcreteTypeConverter(JsonReader reader, JsonSerializer serializer, ConcreteTypeConverter realConcreteConverter)
{
var jObject = CreateIntermediateJObject(reader);
- var concreteType = GetConcreteTypeUsingSelector(realConcreteConverter, jObject);
+ var concreteType = GetConcreteTypeUsingSelector(serializer, realConcreteConverter, jObject);
var hit = GetHitTypeInstance(concreteType);
PopulateHit(serializer, jObject.CreateReader(), hit);
- AppendPartialFields(serializer, realConcreteConverter, concreteType, hit, jObject);
-
return hit;
}
@@ -109,48 +105,23 @@ private static object GetHitTypeInstance(Type concreteType)
return hitType.CreateInstance();
}
- private static void AppendPartialFields(JsonSerializer serializer,
- ConcreteTypeConverter realConcreteConverter,
- Type concreteType, dynamic hit, JObject jObject)
- {
- if (realConcreteConverter == null)
- return;
- dynamic d = jObject;
- var partialFields = realConcreteConverter._partialFields;
- if (partialFields.Any())
- {
- var item = typeof (CovariantItem<>).CreateGenericInstance(concreteType);
-
- dynamic items = typeof(List<>).CreateGenericInstance(item.GetType());
- foreach (var pf in partialFields)
- {
- dynamic partial = concreteType.CreateInstance();
-
- serializer.Populate(d.fields[pf].CreateReader(), partial);
-
- dynamic dictItem = item.GetType().CreateInstance();
- dictItem.Key = pf;
- dictItem.Value = partial;
- items.Add(dictItem);
- }
- dynamic dict = typeof(CovariantDictionary<>).CreateGenericInstance(concreteType); ;
- dict.Items = items;
- hit.PartialFields = dict;
- }
- }
private static dynamic GetConcreteTypeUsingSelector(
+ JsonSerializer serializer,
ConcreteTypeConverter