Skip to content

Commit 76e3406

Browse files
committed
Merge branch 'master' of github.com:Moran007/NEST
Conflicts: src/Nest/DSL/Descriptors/Query/BoolQueryDescriptor.cs
2 parents c5590d1 + 15ba526 commit 76e3406

File tree

4 files changed

+167
-157
lines changed

4 files changed

+167
-157
lines changed

src/Nest/DSL/Descriptors/Query/BoolQueryDescriptor.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ internal bool _CanJoinMustNot()
110110
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
111111
public class BoolQueryDescriptor<T> : BoolBaseQueryDescriptor, IQuery where T : class
112112
{
113+
[JsonProperty("disable_coord")]
114+
internal bool _DisableCoord { get; set; }
115+
116+
public BoolQueryDescriptor<T> DisableCoord()
117+
{
118+
this._DisableCoord = true;
119+
return this;
120+
}
121+
113122
[JsonProperty("minimum_number_should_match")]
114123
internal int? _MinimumNumberShouldMatches { get; set; }
115124

Lines changed: 111 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,111 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using Newtonsoft.Json;
6-
using Newtonsoft.Json.Converters;
7-
using System.Linq.Expressions;
8-
using Nest.Resolvers;
9-
10-
namespace Nest
11-
{
12-
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
13-
public class TextQueryDescriptor<T> : IQuery where T : class
14-
{
15-
[JsonProperty(PropertyName = "type")]
16-
internal virtual string _Type { get { return null; } }
17-
18-
[JsonProperty(PropertyName = "query")]
19-
internal string _Query { get; set; }
20-
21-
[JsonProperty(PropertyName = "analyzer")]
22-
internal string _Analyzer { get; set; }
23-
24-
[JsonProperty(PropertyName = "fuzziness")]
25-
internal double? _Fuzziness { get; set; }
26-
27-
[JsonProperty(PropertyName = "prefix_length")]
28-
internal int? _PrefixLength { get; set; }
29-
30-
[JsonProperty(PropertyName = "max_expansions")]
31-
internal int? _MaxExpansions { get; set; }
32-
33-
[JsonProperty(PropertyName = "slop")]
34-
internal int? _Slop { get; set; }
35-
36-
[JsonProperty(PropertyName = "operator")]
37-
[JsonConverter(typeof(StringEnumConverter))]
38-
internal Operator? _Operator { get; set; }
39-
40-
internal bool IsConditionless
41-
{
42-
get
43-
{
44-
return this._Field.IsNullOrEmpty() || this._Query.IsNullOrEmpty();
45-
}
46-
}
47-
48-
49-
internal string _Field { get; set; }
50-
public TextQueryDescriptor<T> OnField(string field)
51-
{
52-
this._Field = field;
53-
return this;
54-
}
55-
public TextQueryDescriptor<T> OnField(Expression<Func<T, object>> objectPath)
56-
{
57-
var fieldName = new PropertyNameResolver().Resolve(objectPath);
58-
return this.OnField(fieldName);
59-
}
60-
61-
public TextQueryDescriptor<T> QueryString(string queryString)
62-
{
63-
this._Query = queryString;
64-
return this;
65-
}
66-
public TextQueryDescriptor<T> Analyzer(string analyzer)
67-
{
68-
analyzer.ThrowIfNullOrEmpty("analyzer");
69-
this._Analyzer = analyzer;
70-
return this;
71-
}
72-
public TextQueryDescriptor<T> Fuzziness(double fuzziness)
73-
{
74-
fuzziness.ThrowIfNull("fuzziness");
75-
this._Fuzziness = fuzziness;
76-
return this;
77-
}
78-
public TextQueryDescriptor<T> PrefixLength(int prefixLength)
79-
{
80-
prefixLength.ThrowIfNull("prefixLength");
81-
this._PrefixLength = prefixLength;
82-
return this;
83-
}
84-
public TextQueryDescriptor<T> MaxExpansions(int maxExpansions)
85-
{
86-
maxExpansions.ThrowIfNull("maxExpansions");
87-
this._MaxExpansions = maxExpansions;
88-
return this;
89-
}
90-
public TextQueryDescriptor<T> Slop(int slop)
91-
{
92-
slop.ThrowIfNull("slop");
93-
this._Slop = slop;
94-
return this;
95-
}
96-
public TextQueryDescriptor<T> Operator(Operator op)
97-
{
98-
this._Operator = op;
99-
return this;
100-
}
101-
}
102-
}
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using Newtonsoft.Json;
6+
using Newtonsoft.Json.Converters;
7+
using System.Linq.Expressions;
8+
using Nest.Resolvers;
9+
10+
namespace Nest
11+
{
12+
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
13+
public class TextQueryDescriptor<T> : IQuery where T : class
14+
{
15+
[JsonProperty(PropertyName = "type")]
16+
internal virtual string _Type { get { return null; } }
17+
18+
[JsonProperty(PropertyName = "query")]
19+
internal string _Query { get; set; }
20+
21+
[JsonProperty(PropertyName = "analyzer")]
22+
internal string _Analyzer { get; set; }
23+
24+
[JsonProperty(PropertyName = "fuzziness")]
25+
internal double? _Fuzziness { get; set; }
26+
27+
[JsonProperty(PropertyName = "prefix_length")]
28+
internal int? _PrefixLength { get; set; }
29+
30+
[JsonProperty(PropertyName = "max_expansions")]
31+
internal int? _MaxExpansions { get; set; }
32+
33+
[JsonProperty(PropertyName = "slop")]
34+
internal int? _Slop { get; set; }
35+
36+
[JsonProperty(PropertyName = "boost")]
37+
internal double? _Boost { get; set; }
38+
39+
[JsonProperty(PropertyName = "operator")]
40+
[JsonConverter(typeof(StringEnumConverter))]
41+
internal Operator? _Operator { get; set; }
42+
43+
internal bool IsConditionless
44+
{
45+
get
46+
{
47+
return this._Field.IsNullOrEmpty() || this._Query.IsNullOrEmpty();
48+
}
49+
}
50+
51+
52+
internal string _Field { get; set; }
53+
public TextQueryDescriptor<T> OnField(string field)
54+
{
55+
this._Field = field;
56+
return this;
57+
}
58+
public TextQueryDescriptor<T> OnField(Expression<Func<T, object>> objectPath)
59+
{
60+
var fieldName = new PropertyNameResolver().Resolve(objectPath);
61+
return this.OnField(fieldName);
62+
}
63+
64+
public TextQueryDescriptor<T> QueryString(string queryString)
65+
{
66+
this._Query = queryString;
67+
return this;
68+
}
69+
public TextQueryDescriptor<T> Analyzer(string analyzer)
70+
{
71+
analyzer.ThrowIfNullOrEmpty("analyzer");
72+
this._Analyzer = analyzer;
73+
return this;
74+
}
75+
public TextQueryDescriptor<T> Fuzziness(double fuzziness)
76+
{
77+
fuzziness.ThrowIfNull("fuzziness");
78+
this._Fuzziness = fuzziness;
79+
return this;
80+
}
81+
public TextQueryDescriptor<T> Boost(double boost)
82+
{
83+
boost.ThrowIfNull("boost");
84+
this._Boost = boost;
85+
return this;
86+
}
87+
public TextQueryDescriptor<T> PrefixLength(int prefixLength)
88+
{
89+
prefixLength.ThrowIfNull("prefixLength");
90+
this._PrefixLength = prefixLength;
91+
return this;
92+
}
93+
public TextQueryDescriptor<T> MaxExpansions(int maxExpansions)
94+
{
95+
maxExpansions.ThrowIfNull("maxExpansions");
96+
this._MaxExpansions = maxExpansions;
97+
return this;
98+
}
99+
public TextQueryDescriptor<T> Slop(int slop)
100+
{
101+
slop.ThrowIfNull("slop");
102+
this._Slop = slop;
103+
return this;
104+
}
105+
public TextQueryDescriptor<T> Operator(Operator op)
106+
{
107+
this._Operator = op;
108+
return this;
109+
}
110+
}
111+
}

src/Nest/ElasticClient-Search.cs

Lines changed: 46 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
using Nest.FactoryDsl;
33
using System.Diagnostics;
44

5-
namespace Nest
6-
{
7-
public partial class ElasticClient
5+
namespace Nest
6+
{
7+
public partial class ElasticClient
88
{
99

1010
/// <summary>
1111
/// Search using dynamic as its return type.
1212
/// </summary>
1313
public IQueryResponse<dynamic> Search(
14-
SearchBuilder searchBuilder,
14+
SearchBuilder searchBuilder,
1515
string index = null,
1616
string type = null,
1717
string routing = null,
@@ -58,62 +58,53 @@ public IQueryResponse<T> Search<T>(SearchBuilder searchBuilder,
5858
ConnectionStatus status = this.Connection.PostSync(path, query);
5959
var r = this.ToParsedResponse<QueryResponse<T>>(status);
6060
return r;
61-
}
62-
63-
64-
/// <summary>
65-
/// Search using dynamic as its return type.
66-
/// </summary>
67-
public IQueryResponse<dynamic> Search(Func<SearchDescriptor<dynamic>, SearchDescriptor<dynamic>> searcher)
68-
{
69-
var search = new SearchDescriptor<dynamic>();
61+
}
62+
63+
64+
/// <summary>
65+
/// Search using dynamic as its return type.
66+
/// </summary>
67+
public IQueryResponse<dynamic> Search(Func<SearchDescriptor<dynamic>, SearchDescriptor<dynamic>> searcher)
68+
{
69+
var search = new SearchDescriptor<dynamic>();
7070
var descriptor = searcher(search);
71-
var path = this.PathResolver.GetSearchPathForDynamic(descriptor);
72-
var query = this.Serialize(descriptor);
73-
74-
ConnectionStatus status = this.Connection.PostSync(path, query);
75-
var r = this.ToParsedResponse<QueryResponse<dynamic>>(status);
76-
return r;
77-
}
78-
/// <summary>
79-
/// Search using T as the return type
80-
/// </summary>
81-
public IQueryResponse<T> Search<T>(Func<SearchDescriptor<T>, SearchDescriptor<T>> searcher) where T : class
71+
var path = this.PathResolver.GetSearchPathForDynamic(descriptor);
72+
var query = this.Serialize(descriptor);
73+
74+
ConnectionStatus status = this.Connection.PostSync(path, query);
75+
var r = this.ToParsedResponse<QueryResponse<dynamic>>(status);
76+
return r;
77+
}
78+
79+
/// <summary>
80+
/// Search using T as the return type
81+
/// </summary>
82+
public IQueryResponse<T> Search<T>(Func<SearchDescriptor<T>, SearchDescriptor<T>> searcher) where T : class
8283
{
83-
var sw2 = new Stopwatch(); sw2.Start();
84-
var sw = new Stopwatch();
85-
sw.Start();
86-
var search = new SearchDescriptor<T>();
84+
var search = new SearchDescriptor<T>();
8785
var descriptor = searcher(search);
88-
var xx = sw.Elapsed;
89-
sw.Restart();
86+
return Search(descriptor);
87+
}
88+
89+
public IQueryResponse<T> Search<T>(SearchDescriptor<T> descriptor) where T : class
90+
{
9091
var query = this.Serialize(descriptor);
91-
var xY = sw.Elapsed;
92-
sw.Restart();
9392
var path = this.PathResolver.GetSearchPathForTyped(descriptor);
94-
var xxx = sw.Elapsed;
95-
sw.Restart();
93+
var status = this.Connection.PostSync(path, query);
94+
return this.ToParsedResponse<QueryResponse<T>>(status);
95+
}
96+
97+
/// <summary>
98+
/// Search using T as the return type, string based.
99+
/// </summary>
100+
[Obsolete("Deprecated but will never be removed. Found a bug in the DSL? https://github.com/Mpdreamz/NEST/issues")]
101+
public IQueryResponse<T> SearchRaw<T>(string query) where T : class
102+
{
103+
var descriptor = new SearchDescriptor<T>();
104+
var path = this.PathResolver.GetSearchPathForTyped(descriptor);
96105
ConnectionStatus status = this.Connection.PostSync(path, query);
97-
var xxxx = sw.Elapsed;
98-
sw.Restart();
99106
var r = this.ToParsedResponse<QueryResponse<T>>(status);
100-
var xxxxx = sw.Elapsed;
101-
sw.Restart();
102-
sw2.Stop();
103-
var total = sw2.Elapsed;
104-
return r;
105-
}
106-
/// <summary>
107-
/// Search using T as the return type, string based.
108-
/// </summary>
109-
[Obsolete("Deprecated but will never be removed. Found a bug in the DSL? https://github.com/Mpdreamz/NEST/issues")]
110-
public IQueryResponse<T> SearchRaw<T>(string query) where T : class
111-
{
112-
var descriptor = new SearchDescriptor<T>();
113-
var path = this.PathResolver.GetSearchPathForTyped(descriptor);
114-
ConnectionStatus status = this.Connection.PostSync(path, query);
115-
var r = this.ToParsedResponse<QueryResponse<T>>(status);
116-
return r;
117-
}
118-
}
107+
return r;
108+
}
109+
}
119110
}

src/Nest/IElasticClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,5 +242,6 @@ IQueryResponse<T> Search<T>(SearchBuilder searchBuilder,
242242
ISettingsOperationResponse UpdateSettings(IndexSettings settings);
243243
ISettingsOperationResponse UpdateSettings(string index, IndexSettings settings);
244244
IElasticSearchVersionInfo VersionInfo { get; }
245+
IQueryResponse<T> Search<T>(SearchDescriptor<T> descriptor) where T : class;
245246
}
246247
}

0 commit comments

Comments
 (0)