use of org.elasticsearch.index.query.MoreLikeThisQueryBuilder in project elasticsearch by elastic.
the class ContextAndHeaderTransportIT method testThatMoreLikeThisQueryMultiTermVectorRequestContainsContextAndHeaders.
public void testThatMoreLikeThisQueryMultiTermVectorRequestContainsContextAndHeaders() throws Exception {
transportClient().prepareIndex(lookupIndex, "type", "1").setSource(jsonBuilder().startObject().field("name", "Star Wars - The new republic").endObject()).get();
transportClient().prepareIndex(queryIndex, "type", "1").setSource(jsonBuilder().startObject().field("name", "Jar Jar Binks - A horrible mistake").endObject()).get();
transportClient().prepareIndex(queryIndex, "type", "2").setSource(jsonBuilder().startObject().field("name", "Star Wars - Return of the jedi").endObject()).get();
transportClient().admin().indices().prepareRefresh(lookupIndex, queryIndex).get();
MoreLikeThisQueryBuilder moreLikeThisQueryBuilder = QueryBuilders.moreLikeThisQuery(new String[] { "name" }, null, new Item[] { new Item(lookupIndex, "type", "1") }).minTermFreq(1).minDocFreq(1);
SearchResponse searchResponse = transportClient().prepareSearch(queryIndex).setQuery(moreLikeThisQueryBuilder).get();
assertNoFailures(searchResponse);
assertHitCount(searchResponse, 1);
assertRequestsContainHeader(MultiTermVectorsRequest.class);
}
Aggregations