[TEST] Beef up MoreLikeThisActionTests#testCompareMoreLikeThisDSLWithAPI
This commit is contained in:
parent
91b74931a3
commit
d9441747e8
|
@ -401,10 +401,12 @@ public class MoreLikeThisActionTests extends ElasticsearchIntegrationTest {
|
||||||
builders.add(client().prepareIndex("test", "type1").setSource("text", texts[i]).setId(String.valueOf(i)));
|
builders.add(client().prepareIndex("test", "type1").setSource("text", texts[i]).setId(String.valueOf(i)));
|
||||||
}
|
}
|
||||||
indexRandom(true, builders);
|
indexRandom(true, builders);
|
||||||
|
int iters = between(10, 20);
|
||||||
|
for (int j = 0; j < iters; j++) {
|
||||||
logger.info("Running MoreLikeThis DSL with IDs");
|
logger.info("Running MoreLikeThis DSL with IDs");
|
||||||
|
String id = String.valueOf(getRandom().nextInt(texts.length));
|
||||||
Client client = client();
|
Client client = client();
|
||||||
MoreLikeThisQueryBuilder queryBuilder = QueryBuilders.moreLikeThisQuery("text").ids("0").minTermFreq(1).minDocFreq(1);
|
MoreLikeThisQueryBuilder queryBuilder = QueryBuilders.moreLikeThisQuery("text").ids(id).minTermFreq(1).minDocFreq(1);
|
||||||
SearchResponse mltResponseDSL = client.prepareSearch()
|
SearchResponse mltResponseDSL = client.prepareSearch()
|
||||||
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
.setSearchType(SearchType.QUERY_THEN_FETCH)
|
||||||
.setTypes("type1")
|
.setTypes("type1")
|
||||||
|
@ -414,7 +416,7 @@ public class MoreLikeThisActionTests extends ElasticsearchIntegrationTest {
|
||||||
assertSearchResponse(mltResponseDSL);
|
assertSearchResponse(mltResponseDSL);
|
||||||
|
|
||||||
logger.info("Running MoreLikeThis API");
|
logger.info("Running MoreLikeThis API");
|
||||||
MoreLikeThisRequest mltRequest = moreLikeThisRequest("test").type("type1").searchSize(texts.length).id("0").minTermFreq(1).minDocFreq(1);
|
MoreLikeThisRequest mltRequest = moreLikeThisRequest("test").type("type1").searchSize(texts.length).id(id).minTermFreq(1).minDocFreq(1);
|
||||||
SearchResponse mltResponseAPI = client.moreLikeThis(mltRequest).actionGet();
|
SearchResponse mltResponseAPI = client.moreLikeThis(mltRequest).actionGet();
|
||||||
assertSearchResponse(mltResponseAPI);
|
assertSearchResponse(mltResponseAPI);
|
||||||
|
|
||||||
|
@ -444,6 +446,7 @@ public class MoreLikeThisActionTests extends ElasticsearchIntegrationTest {
|
||||||
hitsAPI[i].getScore(), equalTo(hitsDSL[i].getScore()));
|
hitsAPI[i].getScore(), equalTo(hitsDSL[i].getScore()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleMoreLikeThisIdsMultipleTypes() throws Exception {
|
public void testSimpleMoreLikeThisIdsMultipleTypes() throws Exception {
|
||||||
|
|
Loading…
Reference in New Issue