-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
TermsLookupFilterJson.cs
70 lines (67 loc) · 1.55 KB
/
TermsLookupFilterJson.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using NUnit.Framework;
using Nest.Tests.MockData.Domain;
namespace Nest.Tests.Unit.Search.Filter.Singles
{
[TestFixture]
public class TermsLookupFilterJson
{
[Test]
public void TermsLookupFilter()
{
var s = new SearchDescriptor<ElasticsearchProject>()
.From(0)
.Size(10)
.Filter(ff=>ff
.TermsLookup(f=>f.Name, t => t.Lookup<ElasticsearchProject>(p=>p.Name, "NEST"))
);
var json = TestElasticClient.Serialize(s);
var expected = @"{ from: 0, size: 10,
filter : {
terms: {
""name"": {
id: ""NEST"",
type: ""elasticsearchprojects"",
index: ""nest_test_data"",
path: ""name""
}
}
}
}";
Assert.True(json.JsonEquals(expected), json);
}
[Test]
public void TermsLookupFilterWithCache()
{
var s = new SearchDescriptor<ElasticsearchProject>()
.From(0)
.Size(10)
.Filter(ff => ff
.Cache(true)
.Name("terms_filter")
.CacheKey("NEST_TERMS")
.TermsLookup(f => f.Name, t => t
.Lookup<ElasticsearchProject>(p => p.Name, "NEST")
.Routing("dot_net_clients")
)
);
var json = TestElasticClient.Serialize(s);
var expected = @"{ from: 0, size: 10,
filter : {
terms: {
""name"": {
id: ""NEST"",
type: ""elasticsearchprojects"",
index: ""nest_test_data"",
path: ""name"",
routing: ""dot_net_clients""
},
_cache:true,
_cache_key: ""NEST_TERMS"",
_name: ""terms_filter""
}
}
}";
Assert.True(json.JsonEquals(expected), json);
}
}
}