You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/Nest.OData.Tests/FilterFunctionTests.cs
+132Lines changed: 132 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -118,6 +118,138 @@ public void ContainsToLowerFunction()
118
118
Assert.True(JToken.DeepEquals(expectedJObject,actualJObject),"Expected and actual JSON do not match.");
119
119
}
120
120
121
+
[Fact]
122
+
publicvoidMultipleIdenticalFunctionCalls()
123
+
{
124
+
varqueryOptions="$filter=(contains(Category,'Goods')) or (contains(Category,'Goods')) or (contains(Category,'Goods'))".GetODataQueryOptions<Product>();
125
+
126
+
varelasticQuery=queryOptions.ToElasticQuery();
127
+
128
+
Assert.NotNull(elasticQuery);
129
+
130
+
varqueryJson=elasticQuery.ToJson();
131
+
132
+
varexpectedJson=@"
133
+
{
134
+
""query"": {
135
+
""wildcard"": {
136
+
""Category"": {
137
+
""value"": ""*goods*""
138
+
}
139
+
}
140
+
}
141
+
}";
142
+
143
+
varactualJObject=JObject.Parse(queryJson);
144
+
varexpectedJObject=JObject.Parse(expectedJson);
145
+
146
+
Assert.True(JToken.DeepEquals(expectedJObject,actualJObject),"Expected and actual JSON do not match.");
147
+
}
148
+
149
+
[Fact]
150
+
publicvoidMultipleDifferentFunctionCalls()
151
+
{
152
+
varqueryOptions="$filter=(contains(Category,'Goods')) or (contains(Category,'Food')) or (contains(Name,'Merchandise'))".GetODataQueryOptions<Product>();
153
+
154
+
varelasticQuery=queryOptions.ToElasticQuery();
155
+
156
+
Assert.NotNull(elasticQuery);
157
+
158
+
varqueryJson=elasticQuery.ToJson();
159
+
160
+
varexpectedJson=@"
161
+
{
162
+
""query"": {
163
+
""bool"": {
164
+
""minimum_should_match"": 1,
165
+
""should"": [
166
+
{
167
+
""wildcard"": {
168
+
""Category"": {
169
+
""value"": ""*goods*""
170
+
}
171
+
}
172
+
},
173
+
{
174
+
""wildcard"": {
175
+
""Category"": {
176
+
""value"": ""*food*""
177
+
}
178
+
}
179
+
},
180
+
{
181
+
""wildcard"": {
182
+
""Name"": {
183
+
""value"": ""*merchandise*""
184
+
}
185
+
}
186
+
}
187
+
]
188
+
}
189
+
}
190
+
}";
191
+
192
+
varactualJObject=JObject.Parse(queryJson);
193
+
varexpectedJObject=JObject.Parse(expectedJson);
194
+
195
+
Assert.True(JToken.DeepEquals(expectedJObject,actualJObject),"Expected and actual JSON do not match.");
196
+
}
197
+
198
+
[Fact]
199
+
publicvoidMultipleOperatorsFunctionCall()
200
+
{
201
+
varqueryOptions="$filter=(contains(Category,'Food') and contains(Category,'Goods')) or contains(Name,'Merchandise')".GetODataQueryOptions<Product>();
202
+
203
+
varelasticQuery=queryOptions.ToElasticQuery();
204
+
205
+
Assert.NotNull(elasticQuery);
206
+
207
+
varqueryJson=elasticQuery.ToJson();
208
+
209
+
varexpectedJson=@"
210
+
{
211
+
""query"": {
212
+
""bool"": {
213
+
""minimum_should_match"": 1,
214
+
""should"": [
215
+
{
216
+
""bool"": {
217
+
""must"": [
218
+
{
219
+
""wildcard"": {
220
+
""Category"": {
221
+
""value"": ""*food*""
222
+
}
223
+
}
224
+
},
225
+
{
226
+
""wildcard"": {
227
+
""Category"": {
228
+
""value"": ""*goods*""
229
+
}
230
+
}
231
+
}
232
+
]
233
+
}
234
+
},
235
+
{
236
+
""wildcard"": {
237
+
""Name"": {
238
+
""value"": ""*merchandise*""
239
+
}
240
+
}
241
+
}
242
+
],
243
+
}
244
+
}
245
+
}";
246
+
247
+
varactualJObject=JObject.Parse(queryJson);
248
+
varexpectedJObject=JObject.Parse(expectedJson);
249
+
250
+
Assert.True(JToken.DeepEquals(expectedJObject,actualJObject),"Expected and actual JSON do not match.");
0 commit comments