Skip to content

Commit 1808005

Browse files
committed
Merge pull request #1383 from elastic/feature/querystring-timezone
fix #1342 add timezone to query_string
2 parents 702d27a + 2d8e647 commit 1808005

File tree

1 file changed

+36
-23
lines changed

1 file changed

+36
-23
lines changed

src/Nest/DSL/Query/QueryStringDescriptor.cs

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ public interface IQueryStringQuery : IQuery
1515
[JsonProperty(PropertyName = "query")]
1616
string Query { get; set; }
1717

18+
[JsonProperty(PropertyName = "timezone")]
19+
string Timezone { get; set; }
20+
1821
[JsonProperty(PropertyName = "default_field")]
1922
PropertyPathMarker DefaultField { get; set; }
2023

@@ -85,6 +88,7 @@ protected override void WrapInContainer(IQueryContainer container)
8588
public string Name { get; set; }
8689

8790
public string Query { get; set; }
91+
public string Timezone { get; set; }
8892

8993
public PropertyPathMarker DefaultField { get; set; }
9094

@@ -116,6 +120,8 @@ public class QueryStringQueryDescriptor<T> : IQueryStringQuery where T : class
116120

117121
string IQueryStringQuery.Query { get; set; }
118122

123+
string IQueryStringQuery.Timezone { get; set; }
124+
119125
PropertyPathMarker IQueryStringQuery.DefaultField { get; set; }
120126

121127
IEnumerable<PropertyPathMarker> IQueryStringQuery.Fields { get; set; }
@@ -170,124 +176,131 @@ public QueryStringQueryDescriptor<T> Name(string name)
170176

171177
public QueryStringQueryDescriptor<T> DefaultField(string field)
172178
{
173-
((IQueryStringQuery)this).DefaultField = field;
179+
Self.DefaultField = field;
174180
return this;
175181
}
176182

177183
public QueryStringQueryDescriptor<T> DefaultField(Expression<Func<T, object>> objectPath)
178184
{
179-
((IQueryStringQuery)this).DefaultField = objectPath;
185+
Self.DefaultField = objectPath;
180186
return this;
181187
}
182188
public QueryStringQueryDescriptor<T> OnFields(IEnumerable<string> fields)
183189
{
184-
((IQueryStringQuery)this).Fields = fields.Select(f=>(PropertyPathMarker)f);
190+
Self.Fields = fields.Select(f=>(PropertyPathMarker)f);
185191
return this;
186192
}
187193
public QueryStringQueryDescriptor<T> OnFields(
188194
params Expression<Func<T, object>>[] objectPaths)
189195
{
190-
((IQueryStringQuery)this).Fields = objectPaths.Select(e=>(PropertyPathMarker)e);
196+
Self.Fields = objectPaths.Select(e=>(PropertyPathMarker)e);
191197
return this;
192198
}
193199
public QueryStringQueryDescriptor<T> OnFieldsWithBoost(Action<FluentDictionary<Expression<Func<T, object>>, double?>> boostableSelector)
194200
{
195201
var d = new FluentDictionary<Expression<Func<T, object>>, double?>();
196202
boostableSelector(d);
197-
((IQueryStringQuery)this).Fields = d.Select(o => PropertyPathMarker.Create(o.Key, o.Value));
203+
Self.Fields = d.Select(o => PropertyPathMarker.Create(o.Key, o.Value));
198204
return this;
199205
}
200206
public QueryStringQueryDescriptor<T> OnFieldsWithBoost(Action<FluentDictionary<string, double?>> boostableSelector)
201207
{
202208
var d = new FluentDictionary<string, double?>();
203209
boostableSelector(d);
204-
((IQueryStringQuery)this).Fields = d.Select(o => PropertyPathMarker.Create(o.Key, o.Value));
210+
Self.Fields = d.Select(o => PropertyPathMarker.Create(o.Key, o.Value));
205211
return this;
206212
}
207213

208214
public QueryStringQueryDescriptor<T> Query(string query)
209215
{
210-
((IQueryStringQuery)this).Query = query;
216+
Self.Query = query;
211217
return this;
212218
}
219+
220+
public QueryStringQueryDescriptor<T> Timezone(string timezone)
221+
{
222+
Self.Timezone = timezone;
223+
return this;
224+
}
225+
213226
public QueryStringQueryDescriptor<T> DefaultOperator(Operator op)
214227
{
215-
((IQueryStringQuery)this).DefaultOperator = op;
228+
Self.DefaultOperator = op;
216229
return this;
217230
}
218231
public QueryStringQueryDescriptor<T> Analyzer(string analyzer)
219232
{
220-
((IQueryStringQuery)this).Analyzer = analyzer;
233+
Self.Analyzer = analyzer;
221234
return this;
222235
}
223236
public QueryStringQueryDescriptor<T> AllowLeadingWildcard(bool allowLeadingWildcard = true)
224237
{
225-
((IQueryStringQuery)this).AllowLeadingWildcard = allowLeadingWildcard;
238+
Self.AllowLeadingWildcard = allowLeadingWildcard;
226239
return this;
227240
}
228241
public QueryStringQueryDescriptor<T> LowercaseExpendedTerms(bool lowercaseExpendedTerms = true)
229242
{
230-
((IQueryStringQuery)this).LowercaseExpendedTerms = lowercaseExpendedTerms;
243+
Self.LowercaseExpendedTerms = lowercaseExpendedTerms;
231244
return this;
232245
}
233246
public QueryStringQueryDescriptor<T> EnablePositionIncrements(bool enablePositionIncrements = true)
234247
{
235-
((IQueryStringQuery)this).EnablePositionIncrements = enablePositionIncrements;
248+
Self.EnablePositionIncrements = enablePositionIncrements;
236249
return this;
237250
}
238251
public QueryStringQueryDescriptor<T> FuzzyPrefixLength(int fuzzyPrefixLength)
239252
{
240-
((IQueryStringQuery)this).FuzzyPrefixLength = fuzzyPrefixLength;
253+
Self.FuzzyPrefixLength = fuzzyPrefixLength;
241254
return this;
242255
}
243256
public QueryStringQueryDescriptor<T> FuzzyMinimumSimilarity(double fuzzyMinimumSimilarity)
244257
{
245-
((IQueryStringQuery)this).FuzzyMinimumSimilarity = fuzzyMinimumSimilarity;
258+
Self.FuzzyMinimumSimilarity = fuzzyMinimumSimilarity;
246259
return this;
247260
}
248261
public QueryStringQueryDescriptor<T> PhraseSlop(double phraseSlop)
249262
{
250-
((IQueryStringQuery)this).PhraseSlop = phraseSlop;
263+
Self.PhraseSlop = phraseSlop;
251264
return this;
252265
}
253266
public QueryStringQueryDescriptor<T> Boost(double boost)
254267
{
255-
((IQueryStringQuery)this).Boost = boost;
268+
Self.Boost = boost;
256269
return this;
257270
}
258271
public QueryStringQueryDescriptor<T> Rewrite(RewriteMultiTerm rewriteMultiTerm)
259272
{
260-
((IQueryStringQuery)this).Rewrite = rewriteMultiTerm;
273+
Self.Rewrite = rewriteMultiTerm;
261274
return this;
262275
}
263276
public QueryStringQueryDescriptor<T> Lenient(bool lenient = true)
264277
{
265-
((IQueryStringQuery)this).Lenient = lenient;
278+
Self.Lenient = lenient;
266279
return this;
267280
}
268281
public QueryStringQueryDescriptor<T> AnalyzeWildcard(bool analyzeWildcard = true)
269282
{
270-
((IQueryStringQuery)this).AnalyzeWildcard = analyzeWildcard;
283+
Self.AnalyzeWildcard = analyzeWildcard;
271284
return this;
272285
}
273286
public QueryStringQueryDescriptor<T> AutoGeneratePhraseQueries(bool autoGeneratePhraseQueries = true)
274287
{
275-
((IQueryStringQuery)this).AutoGeneratePhraseQueries = autoGeneratePhraseQueries;
288+
Self.AutoGeneratePhraseQueries = autoGeneratePhraseQueries;
276289
return this;
277290
}
278291
public QueryStringQueryDescriptor<T> MinimumShouldMatchPercentage(int minimumShouldMatchPercentage)
279292
{
280-
((IQueryStringQuery)this).MinimumShouldMatchPercentage = "{0}%".F(minimumShouldMatchPercentage);
293+
Self.MinimumShouldMatchPercentage = "{0}%".F(minimumShouldMatchPercentage);
281294
return this;
282295
}
283296
public QueryStringQueryDescriptor<T> UseDisMax(bool useDismax = true)
284297
{
285-
((IQueryStringQuery)this).UseDisMax = useDismax;
298+
Self.UseDisMax = useDismax;
286299
return this;
287300
}
288301
public QueryStringQueryDescriptor<T> TieBreaker(double tieBreaker)
289302
{
290-
((IQueryStringQuery)this).TieBreaker = tieBreaker;
303+
Self.TieBreaker = tieBreaker;
291304
return this;
292305
}
293306

0 commit comments

Comments
 (0)