Getting the doc value settings shouldn't use the API callers headers. We only use this value internally.
This commit is contained in:
parent
e022b78198
commit
a9be4181c6
|
@ -117,8 +117,7 @@ public class ExplainDataFrameAnalyticsRestIT extends ESRestTestCase {
|
||||||
addSecondaryAuthHeader(options, ML_ADMIN);
|
addSecondaryAuthHeader(options, ML_ADMIN);
|
||||||
explain.setOptions(options);
|
explain.setOptions(options);
|
||||||
// Should throw
|
// Should throw
|
||||||
ResponseException ex = expectThrows(ResponseException.class, () -> client().performRequest(explain));
|
expectThrows(ResponseException.class, () -> client().performRequest(explain));
|
||||||
assertThat(ex.getResponse().getStatusLine().getStatusCode(), equalTo(403));
|
|
||||||
}
|
}
|
||||||
{ // request with secondary headers with perms
|
{ // request with secondary headers with perms
|
||||||
Request explain = explainRequestViaConfig(config);
|
Request explain = explainRequestViaConfig(config);
|
||||||
|
@ -160,8 +159,7 @@ public class ExplainDataFrameAnalyticsRestIT extends ESRestTestCase {
|
||||||
addSecondaryAuthHeader(options, ML_ADMIN);
|
addSecondaryAuthHeader(options, ML_ADMIN);
|
||||||
explain.setOptions(options);
|
explain.setOptions(options);
|
||||||
// Should throw
|
// Should throw
|
||||||
ResponseException ex = expectThrows(ResponseException.class, () -> client().performRequest(explain));
|
expectThrows(ResponseException.class, () -> client().performRequest(explain));
|
||||||
assertThat(ex.getResponse().getStatusLine().getStatusCode(), equalTo(403));
|
|
||||||
}
|
}
|
||||||
{ // request with secondary headers with perms
|
{ // request with secondary headers with perms
|
||||||
Request explain = explainRequestConfigId(configId);
|
Request explain = explainRequestConfigId(configId);
|
||||||
|
|
|
@ -376,8 +376,10 @@ public class ExtractedFieldsDetector {
|
||||||
if (preferSource) {
|
if (preferSource) {
|
||||||
extractedFields = fetchFromSourceIfSupported(extractedFields);
|
extractedFields = fetchFromSourceIfSupported(extractedFields);
|
||||||
if (extractedFields.getDocValueFields().size() > docValueFieldsLimit) {
|
if (extractedFields.getDocValueFields().size() > docValueFieldsLimit) {
|
||||||
throw ExceptionsHelper.badRequestException("[{}] fields must be retrieved from doc_values but the limit is [{}]; " +
|
throw ExceptionsHelper.badRequestException(
|
||||||
"please adjust the index level setting [{}]", extractedFields.getDocValueFields().size(), docValueFieldsLimit,
|
"[{}] fields must be retrieved from doc_values and this is greater than the configured limit. " +
|
||||||
|
"Please adjust the index level setting [{}]",
|
||||||
|
extractedFields.getDocValueFields().size(),
|
||||||
IndexSettings.MAX_DOCVALUE_FIELDS_SEARCH_SETTING.getKey());
|
IndexSettings.MAX_DOCVALUE_FIELDS_SEARCH_SETTING.getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.logging.log4j.message.ParameterizedMessage;
|
import org.apache.logging.log4j.message.ParameterizedMessage;
|
||||||
import org.elasticsearch.ResourceNotFoundException;
|
import org.elasticsearch.ResourceNotFoundException;
|
||||||
import org.elasticsearch.action.ActionListener;
|
import org.elasticsearch.action.ActionListener;
|
||||||
|
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsAction;
|
||||||
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest;
|
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest;
|
||||||
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse;
|
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse;
|
||||||
import org.elasticsearch.action.fieldcaps.FieldCapabilities;
|
import org.elasticsearch.action.fieldcaps.FieldCapabilities;
|
||||||
|
@ -45,6 +46,9 @@ import java.util.Objects;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
|
import static org.elasticsearch.xpack.core.ClientHelper.ML_ORIGIN;
|
||||||
|
import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A factory that retrieves all the parts necessary to build a {@link ExtractedFieldsDetector}.
|
* A factory that retrieves all the parts necessary to build a {@link ExtractedFieldsDetector}.
|
||||||
*/
|
*/
|
||||||
|
@ -138,7 +142,7 @@ public class ExtractedFieldsDetectorFactory {
|
||||||
}
|
}
|
||||||
SearchRequest searchRequest = new SearchRequest(index).source(searchSourceBuilder);
|
SearchRequest searchRequest = new SearchRequest(index).source(searchSourceBuilder);
|
||||||
ClientHelper.executeWithHeadersAsync(
|
ClientHelper.executeWithHeadersAsync(
|
||||||
config.getHeaders(), ClientHelper.ML_ORIGIN, client, SearchAction.INSTANCE, searchRequest, searchListener);
|
config.getHeaders(), ML_ORIGIN, client, SearchAction.INSTANCE, searchRequest, searchListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildFieldCardinalitiesMap(DataFrameAnalyticsConfig config, SearchResponse searchResponse,
|
private void buildFieldCardinalitiesMap(DataFrameAnalyticsConfig config, SearchResponse searchResponse,
|
||||||
|
@ -168,7 +172,7 @@ public class ExtractedFieldsDetectorFactory {
|
||||||
fieldCapabilitiesRequest.fields("*");
|
fieldCapabilitiesRequest.fields("*");
|
||||||
LOGGER.debug(() -> new ParameterizedMessage(
|
LOGGER.debug(() -> new ParameterizedMessage(
|
||||||
"[{}] Requesting field caps for index {}", config.getId(), Arrays.toString(index)));
|
"[{}] Requesting field caps for index {}", config.getId(), Arrays.toString(index)));
|
||||||
ClientHelper.executeWithHeaders(config.getHeaders(), ClientHelper.ML_ORIGIN, client, () -> {
|
ClientHelper.executeWithHeaders(config.getHeaders(), ML_ORIGIN, client, () -> {
|
||||||
client.execute(FieldCapabilitiesAction.INSTANCE, fieldCapabilitiesRequest, listener);
|
client.execute(FieldCapabilitiesAction.INSTANCE, fieldCapabilitiesRequest, listener);
|
||||||
// This response gets discarded - the listener handles the real response
|
// This response gets discarded - the listener handles the real response
|
||||||
return null;
|
return null;
|
||||||
|
@ -205,6 +209,6 @@ public class ExtractedFieldsDetectorFactory {
|
||||||
getSettingsRequest.indices(index);
|
getSettingsRequest.indices(index);
|
||||||
getSettingsRequest.includeDefaults(true);
|
getSettingsRequest.includeDefaults(true);
|
||||||
getSettingsRequest.names(IndexSettings.MAX_DOCVALUE_FIELDS_SEARCH_SETTING.getKey());
|
getSettingsRequest.names(IndexSettings.MAX_DOCVALUE_FIELDS_SEARCH_SETTING.getKey());
|
||||||
client.admin().indices().getSettings(getSettingsRequest, settingsListener);
|
executeAsyncWithOrigin(client, ML_ORIGIN, GetSettingsAction.INSTANCE, getSettingsRequest, settingsListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue