Skip to content

Commit fcc603b

Browse files
committed
Add test for conditionless match query
1 parent 2aa6a31 commit fcc603b

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/Tests/Nest.Tests.Unit/Nest.Tests.Unit.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,9 @@
765765
<None Include="Reproduce\Issue579.json">
766766
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
767767
</None>
768+
<None Include="Reproduce\Issue876.json">
769+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
770+
</None>
768771
<None Include="Search\Fields\FixedCovariantSearchResult.json">
769772
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
770773
</None>

src/Tests/Nest.Tests.Unit/Search/Query/Modes/ConditionlessQueryJson.cs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Nest.Tests.Unit.Search.Query.Singles
77
public class ConditionlessQueryJson
88
{
99
[Test]
10-
public void Fallback()
10+
public void FallbackTerm()
1111
{
1212
var s = new SearchDescriptor<ElasticsearchProject>().From(0).Size(10)
1313
.Query(q=>q
@@ -29,6 +29,40 @@ public void Fallback()
2929
Assert.True(json.JsonEquals(expected), json);
3030
}
3131

32+
[Test]
33+
public void FallbackMatch()
34+
{
35+
var s = new SearchDescriptor<ElasticsearchProject>().From(0).Size(10)
36+
.Query(q => q
37+
.Conditionless(qs => qs
38+
.Query(qcq => qcq
39+
.Match(m => m
40+
.OnField(p => p.Name)
41+
.Query("")
42+
)
43+
)
44+
.Fallback(qcf=>qcf
45+
.Match(m => m
46+
.OnField(p => p.Name)
47+
.Query("do_me_instead")
48+
)
49+
)
50+
)
51+
);
52+
53+
var json = TestElasticClient.Serialize(s);
54+
var expected = @"{ from: 0, size: 10,
55+
query : {
56+
match : {
57+
name : {
58+
query: ""do_me_instead""
59+
}
60+
}
61+
}
62+
}";
63+
Assert.True(json.JsonEquals(expected), json);
64+
}
65+
3266
[Test]
3367
public void UseQuery()
3468
{

0 commit comments

Comments
 (0)