From 5e4928ca9211e61d577e780d34a6d72920fc9fe8 Mon Sep 17 00:00:00 2001 From: Leonardo Menezes Date: Fri, 1 Nov 2013 18:02:44 +0100 Subject: [PATCH] Resolve aliases on redirects inside TransportMoreLikeThisAction fixes #4045 --- .../action/mlt/TransportMoreLikeThisAction.java | 3 ++- .../java/org/elasticsearch/mlt/MoreLikeThisActionTests.java | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/elasticsearch/action/mlt/TransportMoreLikeThisAction.java b/src/main/java/org/elasticsearch/action/mlt/TransportMoreLikeThisAction.java index 04b57d0d640..4c127c961d9 100644 --- a/src/main/java/org/elasticsearch/action/mlt/TransportMoreLikeThisAction.java +++ b/src/main/java/org/elasticsearch/action/mlt/TransportMoreLikeThisAction.java @@ -236,7 +236,8 @@ public class TransportMoreLikeThisAction extends TransportAction 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()); diff --git a/src/test/java/org/elasticsearch/mlt/MoreLikeThisActionTests.java b/src/test/java/org/elasticsearch/mlt/MoreLikeThisActionTests.java index 0a26f101896..9549ceff651 100644 --- a/src/test/java/org/elasticsearch/mlt/MoreLikeThisActionTests.java +++ b/src/test/java/org/elasticsearch/mlt/MoreLikeThisActionTests.java @@ -119,6 +119,12 @@ public class MoreLikeThisActionTests extends AbstractIntegrationTest { 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