Skip to content

Commit 2aa6a31

Browse files
committed
Fix #876: Verbatim() producing null match query
1 parent cf000f2 commit 2aa6a31

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

Diff for: src/Nest/Resolvers/Converters/Queries/MatchQueryJsonConverter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public TReturn GetPropValue<TReturn>(JObject jObject, string propertyName)
7373
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
7474
{
7575
var v = value as IFieldNameQuery;
76-
if (v == null || v.IsConditionless)
76+
if (v == null)
7777
return;
7878

7979
var fieldName = v.GetFieldName();

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

+1
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@
369369
<Compile Include="Reproduce\Reproduce579Tests.cs" />
370370
<Compile Include="Reproduce\Reproduce860Tests.cs" />
371371
<Compile Include="Reproduce\Reproduce806Tests.cs" />
372+
<Compile Include="Reproduce\Reproduce876Tests.cs" />
372373
<Compile Include="Search\Fields\FieldsTests.cs" />
373374
<Compile Include="Search\Filter\Modes\ConditionlessFilterJson.cs" />
374375
<Compile Include="Search\Filter\Modes\FilterModesTests.cs" />

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

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"query": {
3+
"match": {
4+
"name": {
5+
"query": ""
6+
}
7+
}
8+
}
9+
}
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using FluentAssertions;
2+
using Nest.Tests.MockData.Domain;
3+
using NUnit.Framework;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Reflection;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
11+
namespace Nest.Tests.Unit.Reproduce
12+
{
13+
[TestFixture]
14+
public class Reproduce876Tests : BaseJsonTests
15+
{
16+
[Test]
17+
public void Issue876()
18+
{
19+
var result = new SearchDescriptor<ElasticsearchProject>()
20+
.Query(q => q
21+
.Verbatim()
22+
.Match(m => m
23+
.OnField(p => p.Name)
24+
.Query(string.Empty)
25+
)
26+
);
27+
28+
this.JsonEquals(result, MethodInfo.GetCurrentMethod());
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)