Resolve aliases on redirects inside TransportMoreLikeThisAction
fixes #4045
This commit is contained in:
parent
f2840c5ccf
commit
5e4928ca92
|
@ -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.
|
||||
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());
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue