Resolve aliases on redirects inside TransportMoreLikeThisAction

fixes #4045
This commit is contained in:
Leonardo Menezes 2013-11-01 18:02:44 +01:00 committed by Igor Motov
parent f2840c5ccf
commit 5e4928ca92
2 changed files with 8 additions and 1 deletions

View File

@ -236,7 +236,8 @@ public class TransportMoreLikeThisAction extends TransportAction<MoreLikeThisReq
// Redirects the request to a data node, that has the index meta data locally available. // 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) { 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(); ShardRouting shardRouting = shardIterator.firstOrNull();
if (shardRouting == null) { if (shardRouting == null) {
throw new ElasticSearchException("No shards for index " + request.index()); throw new ElasticSearchException("No shards for index " + request.index());

View File

@ -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(); mltResponse = client().moreLikeThis(moreLikeThisRequest("test").type("type1").id("1").minTermFreq(1).minDocFreq(1).searchIndices("release")).actionGet();
assertHitCount(mltResponse, 1l); assertHitCount(mltResponse, 1l);
assertThat(mltResponse.getHits().getAt(0).id(), equalTo("2")); 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 @Test