Skip to content

Commit 87640aa

Browse files
committed
Merge pull request #1431 from robertlyson/MoreLikeThisConditionlessBug
MoreLikeThis query should accept documents or ids
2 parents de421cf + 9258c35 commit 87640aa

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Nest/DSL/Query/MoreLikeThisQueryDescriptor.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ bool IQuery.IsConditionless
145145
{
146146
get
147147
{
148-
return this.Self.LikeText.IsNullOrEmpty();
148+
return this.Self.LikeText.IsNullOrEmpty()
149+
&& (this.Self.Ids == null || !this.Self.Ids.Any())
150+
&& (this.Self.Documents == null || !this.Self.Documents.Any());
149151
}
150152
}
151153

src/Tests/Nest.Tests.Unit/Search/Query/Singles/MoreLikeThisQueryJson.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void MoreLikeThisWithDocuments()
8888
.Document<MoreLikeThisTestDoc>(new MoreLikeThisTestDoc { Name = "foo" }, "myindex", "mytype")
8989
);
9090
var json = TestElasticClient.Serialize(s);
91-
91+
9292
const string expected = @"{
9393
fields: [ ""name""],
9494
docs: [
@@ -135,6 +135,7 @@ public void MoreLikeThisWithDocuments()
135135
}";
136136

137137
Verify<MoreLikeThisQueryDescriptor<object>>(json, expected);
138+
Assert.AreEqual(false, ((IQuery)s).IsConditionless);
138139
}
139140

140141
[Test]

0 commit comments

Comments
 (0)