Skip to content

Commit 3ad399a

Browse files
committed
Close #928 included unit test to showcase how to get the desired json from NEST
1 parent b64c61b commit 3ad399a

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

Diff for: src/Tests/Nest.Tests.Unit/Nest.Tests.Unit.csproj

+4
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@
371371
<Compile Include="QueryParsers\Visitor\DslPrettyPrintVisitor.cs" />
372372
<Compile Include="QueryParsers\Visitor\VisitorDemoUseCase.cs" />
373373
<Compile Include="QueryParsers\Visitor\VisitorTests.cs" />
374+
<Compile Include="Reproduce\Reproduce928Tests.cs" />
374375
<Compile Include="Reproduce\Reproduce902Tests.cs" />
375376
<Compile Include="Reproduce\Reproduce646Tests.cs" />
376377
<Compile Include="Reproduce\Reproduce579Tests.cs" />
@@ -775,6 +776,9 @@
775776
<None Include="Reproduce\Issue579.json">
776777
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
777778
</None>
779+
<None Include="Reproduce\Issue928.json">
780+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
781+
</None>
778782
<None Include="Reproduce\Issue902.json">
779783
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
780784
</None>

Diff for: src/Tests/Nest.Tests.Unit/Reproduce/Issue928.json

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"filter": {
3+
"bool": {
4+
"must": [
5+
{
6+
"fquery": {
7+
"query": {
8+
"term": {
9+
"field1": {
10+
"value": "value"
11+
}
12+
}
13+
},
14+
"_cache": true
15+
}
16+
},
17+
{
18+
"fquery": {
19+
"query": {
20+
"term": {
21+
"field2": {
22+
"value": "value"
23+
}
24+
}
25+
},
26+
"_cache": true
27+
}
28+
}
29+
]
30+
}
31+
}
32+
}
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Reflection;
5+
using Nest.Tests.MockData.Domain;
6+
using NUnit.Framework;
7+
8+
namespace Nest.Tests.Unit.Reproduce
9+
{
10+
/// <summary>
11+
/// tests to reproduce reported errors
12+
/// </summary>
13+
[TestFixture]
14+
public class Reproduce928Tests : BaseJsonTests
15+
{
16+
[Test]
17+
public void Issue928()
18+
{
19+
var result = this._client.Search<ElasticsearchProject>(s => s
20+
.Filter(f => f
21+
.Bool(bf => bf
22+
.Must(
23+
mf => mf.Cache(true).Query(q => q.Term("field1", "value"))
24+
,mf => mf.Cache(true).Query(q => q.Term("field2", "value"))
25+
)
26+
)
27+
)
28+
);
29+
30+
this.JsonEquals(result.ConnectionStatus.Request, MethodBase.GetCurrentMethod());
31+
}
32+
33+
[Test]
34+
public void Issue928_And()
35+
{
36+
var result = this._client.Search<ElasticsearchProject>(s => s
37+
.Filter(f =>
38+
f.Cache(true).Query(q => q.Term("field1", "value"))
39+
&& f.Cache(true).Query(q => q.Term("field2", "value"))
40+
)
41+
);
42+
43+
this.JsonEquals(result.ConnectionStatus.Request, MethodBase.GetCurrentMethod(), "Issue928");
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)