Skip to content

Commit 18b7066

Browse files
committed
Fix #1217: add matched_queries to search response
1 parent af0424d commit 18b7066

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/Nest/Domain/Hit/Hit.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ public interface IHit<out T> where T : class
1616
string Type { get; }
1717
string Version { get; }
1818
string Id { get; }
19-
2019
IEnumerable<object> Sorts { get; }
21-
2220
HighlightFieldDictionary Highlights { get; }
2321
Explanation Explanation { get; }
22+
IEnumerable<string> MatchedQueries { get; }
2423
}
2524

2625
[JsonObject]
@@ -76,5 +75,7 @@ public HighlightFieldDictionary Highlights
7675
[JsonProperty(PropertyName = "_explanation")]
7776
public Explanation Explanation { get; internal set; }
7877

78+
[JsonProperty(PropertyName = "matched_queries")]
79+
public IEnumerable<string> MatchedQueries { get; internal set; }
7980
}
8081
}

src/Tests/Nest.Tests.Integration/Search/NamedFilter/NamedFilterTests.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Linq;
1+
using FluentAssertions;
2+
using System.Linq;
23
using Nest.Tests.MockData;
34
using Nest.Tests.MockData.Domain;
45
using NUnit.Framework;
@@ -22,11 +23,12 @@ public void SimpleNamedFilter()
2223
|| f.Name("myfilter2").Terms(p => p.Name.Suffix("sort"), new[] {"nest"})
2324
)
2425
);
25-
Assert.True(queryResults.IsValid);
26-
//Assert.True(queryResults.Documents.Any());
27-
//Assert matched_filters is returned
28-
//Possible ES bug
29-
//https://github.com/elasticsearch/elasticsearch/issues/3097
26+
queryResults.IsValid.Should().BeTrue();
27+
foreach(var hit in queryResults.Hits)
28+
{
29+
hit.MatchedQueries.Should().NotBeNull().And.NotBeEmpty();
30+
hit.MatchedQueries.Any(mq => mq.Contains("myfilter") || mq.Contains("myfilter2"));
31+
}
3032
}
3133
}
3234

0 commit comments

Comments
 (0)