Skip to content

Commit 15ba526

Browse files
author
Moran
committed
Bool query with disable coord option
Text query with boost option
1 parent d765168 commit 15ba526

File tree

2 files changed

+121
-103
lines changed

2 files changed

+121
-103
lines changed

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

Lines changed: 10 additions & 1 deletion
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

@@ -148,7 +157,7 @@ public BoolQueryDescriptor<T> Boost(double boost)
148157
/// <summary>
149158
/// The clause(s) that must appear in matching documents
150159
/// </summary>
151-
public BoolQueryDescriptor<T> Must(params Func<QueryDescriptor<T>, BaseQuery>[] filters)
160+
public BoolQueryDescriptor<T> Must(params Func<QueryDescriptor<T>, BaseQuery>[] filters)
152161
{
153162
var descriptors = new List<BaseQuery>();
154163
foreach (var selector in filters)
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+
}

0 commit comments

Comments
 (0)