Skip to content

Commit

Permalink
Resolve aliases on redirects inside TransportMoreLikeThisAction
Browse files Browse the repository at this point in the history
fixes #4045
  • Loading branch information
Leonardo Menezes authored and imotov committed Nov 5, 2013
1 parent d1510a5 commit b29e73b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Expand Up @@ -236,7 +236,8 @@ public void onFailure(Throwable e) {

// Redirects the request to a data node, that has the index meta data locally available.
private void redirect(MoreLikeThisRequest request, final ActionListener<SearchResponse> listener, ClusterState clusterState) {
ShardIterator shardIterator = clusterService.operationRouting().getShards(clusterState, request.index(), request.type(), request.id(), request.routing(), null);
final String concreteIndex = clusterState.metaData().concreteIndex(request.index());
ShardIterator shardIterator = clusterService.operationRouting().getShards(clusterState, concreteIndex, request.type(), request.id(), request.routing(), null);
ShardRouting shardRouting = shardIterator.firstOrNull();
if (shardRouting == null) {
throw new ElasticSearchException("No shards for index " + request.index());
Expand Down
Expand Up @@ -119,6 +119,12 @@ public void testMoreLikeThisWithAliases() throws Exception {
mltResponse = client().moreLikeThis(moreLikeThisRequest("test").type("type1").id("1").minTermFreq(1).minDocFreq(1).searchIndices("release")).actionGet();
assertHitCount(mltResponse, 1l);
assertThat(mltResponse.getHits().getAt(0).id(), equalTo("2"));

logger.info("Running moreLikeThis on alias with node client");
mltResponse = cluster().clientNodeClient().moreLikeThis(moreLikeThisRequest("beta").type("type1").id("1").minTermFreq(1).minDocFreq(1)).actionGet();
assertHitCount(mltResponse, 1l);
assertThat(mltResponse.getHits().getAt(0).id(), equalTo("3"));

}

@Test
Expand Down

0 comments on commit b29e73b

Please sign in to comment.