Skip to content

Commit 4b1e942

Browse files
committed
Merge pull request #1710 from elastic/fix/eager-conditionless
fix #1709 did a pass over all conditionless checks and fixed those th…
2 parents a1cdabd + 4d20a3f commit 4b1e942

File tree

12 files changed

+10
-20
lines changed

12 files changed

+10
-20
lines changed

Diff for: src/Nest/QueryDsl/Compound/Filtered/FilteredQuery.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ internal static bool IsConditionless(IFilteredQuery q)
3232
return q.Query.IsConditionless;
3333
if (q.Filter != null && q.Query == null)
3434
return q.Filter.IsConditionless;
35-
return q.Query.IsConditionless && q.Filter.IsConditionless;
35+
return q.Query.IsConditionless() && q.Filter.IsConditionless();
3636
}
3737
}
3838

Diff for: src/Nest/QueryDsl/Compound/FunctionScore/FunctionScoreQuery.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@ public class FunctionScoreQuery : QueryBase, IFunctionScoreQuery
3939

4040
internal override void WrapInContainer(IQueryContainer c) => c.FunctionScore = this;
4141

42-
internal static bool IsConditionless(IFunctionScoreQuery q, bool force = false)
43-
{
44-
return force || !q.Functions.HasAny();
45-
}
42+
internal static bool IsConditionless(IFunctionScoreQuery q, bool force = false) =>
43+
force || !q.Functions.HasAny();
4644
}
4745

4846
public class FunctionScoreQueryDescriptor<T>

Diff for: src/Nest/QueryDsl/FullText/QueryString/QueryStringQuery.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ public class QueryStringQuery : QueryBase, IQueryStringQuery
120120
public int? MaximumDeterminizedStates { get; set; }
121121

122122
internal override void WrapInContainer(IQueryContainer c) => c.QueryString = this;
123-
internal static bool IsConditionless(IQueryStringQuery q) =>
124-
(q.Fields == null && q.DefaultField == null) || q.Query.IsNullOrEmpty();
123+
internal static bool IsConditionless(IQueryStringQuery q) => q.Query.IsNullOrEmpty();
125124
}
126125

127126
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]

Diff for: src/Nest/QueryDsl/FullText/SimpleQueryString/SimpleQueryStringQuery.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ public class SimpleQueryStringQuery : QueryBase, ISimpleQueryStringQuery
5353
public MinimumShouldMatch MinimumShouldMatch { get; set; }
5454

5555
internal override void WrapInContainer(IQueryContainer c) => c.SimpleQueryString = this;
56-
internal static bool IsConditionless(ISimpleQueryStringQuery q) =>
57-
q.Fields == null || q.Query.IsNullOrEmpty();
56+
internal static bool IsConditionless(ISimpleQueryStringQuery q) => q.Query.IsNullOrEmpty();
5857
}
5958

6059
public class SimpleQueryStringQueryDescriptor<T>

Diff for: src/Nest/QueryDsl/Geo/Distance/GeoDistanceQuery.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public class GeoDistanceQuery : FieldNameQueryBase, IGeoDistanceQuery
4343

4444
internal override void WrapInContainer(IQueryContainer c) => c.GeoDistance = this;
4545

46-
internal static bool IsConditionless(IGeoDistanceQuery q) => q.Location == null || q.Distance == null || q.Field.IsConditionless();
46+
internal static bool IsConditionless(IGeoDistanceQuery q) =>
47+
q.Location == null || q.Distance == null || q.Field.IsConditionless();
4748
}
4849

4950
public class GeoDistanceQueryDescriptor<T>

Diff for: src/Nest/QueryDsl/Specialized/Script/ScriptQuery.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public class ScriptQuery : QueryBase, IScriptQuery
3636
public string Lang { get; set; }
3737

3838
internal override void WrapInContainer(IQueryContainer c) => c.Script = this;
39-
internal static bool IsConditionless(IScriptQuery q) => q.Inline.IsNullOrEmpty();
39+
internal static bool IsConditionless(IScriptQuery q) =>
40+
q.Inline.IsNullOrEmpty() && q.Id == null && q.File.IsNullOrEmpty();
4041
}
4142

4243
public class ScriptQueryDescriptor<T>

Diff for: src/Nest/QueryDsl/TermLevel/Fuzzy/FuzzyQueryBase.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public interface IFuzzyQuery<TValue, TFuzziness> : IFuzzyQuery
3030
internal static class FuzzyQueryBase
3131
{
3232
internal static bool IsConditionless<TValue, TFuzziness>(IFuzzyQuery<TValue, TFuzziness> fuzzy) =>
33-
fuzzy == null || fuzzy.Value == null || fuzzy.Fuzziness == null || fuzzy.Field == null;
33+
fuzzy == null || fuzzy.Value == null || fuzzy.Field == null;
3434
}
3535

3636
public abstract class FuzzyQueryBase<TValue, TFuzziness> : FieldNameQueryBase, IFuzzyQuery<TValue, TFuzziness>

Diff for: src/Tests/QueryDsl/FullText/QueryString/QueryStringUsageTests.cs

-4
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,6 @@ protected override QueryContainer QueryFluent(QueryContainerDescriptor<Project>
109109
{
110110
q => q.Query = null,
111111
q => q.Query = string.Empty,
112-
q => {
113-
q.Fields = null;
114-
q.DefaultField = null;
115-
}
116112
};
117113
}
118114
}

Diff for: src/Tests/QueryDsl/FullText/SimpleQueryString/SimpleQueryStringUsageTests.cs

-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ protected override QueryContainer QueryFluent(QueryContainerDescriptor<Project>
6464
{
6565
q => q.Query = null,
6666
q => q.Query = string.Empty,
67-
q => q.Fields = null
6867
};
6968
}
7069
}

Diff for: src/Tests/QueryDsl/TermLevel/Fuzzy/FuzzyDateQueryUsageTests.cs

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ protected override QueryContainer QueryFluent(QueryContainerDescriptor<Project>
5959
)
6060
{
6161
q => q.Field = null,
62-
q => q.Fuzziness = null,
6362
q => q.Value = null
6463
};
6564
}

Diff for: src/Tests/QueryDsl/TermLevel/Fuzzy/FuzzyNumericQueryUsageTests.cs

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ protected override QueryContainer QueryFluent(QueryContainerDescriptor<Project>
5858
)
5959
{
6060
q => q.Field = null,
61-
q => q.Fuzziness = null,
6261
q => q.Value = null
6362
};
6463
}

Diff for: src/Tests/QueryDsl/TermLevel/Fuzzy/FuzzyQueryUsageTests.cs

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ protected override QueryContainer QueryFluent(QueryContainerDescriptor<Project>
5757
)
5858
{
5959
q => q.Field = null,
60-
q => q.Fuzziness = null,
6160
q => q.Value = null
6261
};
6362
}

0 commit comments

Comments
 (0)