[TEST] fix testMoreLikeThisArtificialDocs

Ensure that the indexed doc hasn't all its fields empty and that the
artificial doc requested is always routed to the shard having that doc.
This commit is contained in:
Alex Ksikes 2015-07-06 15:27:38 +02:00
parent b93512e000
commit 8ef1708395
1 changed files with 2 additions and 2 deletions

View File

@ -451,14 +451,14 @@ public class MoreLikeThisTests extends ElasticsearchIntegrationTest {
logger.info("Indexing a single document ...");
XContentBuilder doc = jsonBuilder().startObject();
for (int i = 0; i < numFields; i++) {
doc.field("field"+i, generateRandomStringArray(5, 10, false));
doc.field("field"+i, generateRandomStringArray(5, 10, false)+"a"); // make sure they are not all empty
}
doc.endObject();
indexRandom(true, client().prepareIndex("test", "type1", "0").setSource(doc));
logger.info("Checking the document matches ...");
MoreLikeThisQueryBuilder mltQuery = moreLikeThisQuery()
.like((Item) new Item().doc(doc).index("test").type("type1"))
.like((Item) new Item().doc(doc).index("test").type("type1").routing("0")) // routing to ensure we hit the shard with the doc
.minTermFreq(0)
.minDocFreq(0)
.maxQueryTerms(100)