request.index(clusterState.metaData().concreteIndex(request.index()));
return clusterState.routingTable().index(request.index()).randomAllActiveShardsIt();
}
@Override protected AnalyzeResponse shardOperation(AnalyzeRequest request, int shardId) throws ElasticSearchException {
IndexService indexService = indicesService.indexServiceSafe(request.index());
Analyzer analyzer = null;
String field = null;
if (request.field() != null) {
FieldMapper fieldMapper = indexService.mapperService().smartNameFieldMapper(request.field());
if (fieldMapper != null) {
analyzer = fieldMapper.indexAnalyzer();
field = fieldMapper.names().indexName();
}
}
if (field == null) {
field = "_all";
}
if (analyzer == null && request.analyzer() != null) {
analyzer = indexService.analysisService().analyzer(request.analyzer());
} else if (analyzer == null) {
analyzer = indexService.analysisService().defaultIndexAnalyzer();
}
if (analyzer == null) {
throw new ElasticSearchIllegalArgumentException("failed to find analyzer");
}