Suggest isn t supported if document level security is enabled – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-7.15

Briefly, this error occurs when you try to use the “suggest” feature in Elasticsearch while document level security is enabled. Document level security restricts access to certain documents within an index. The “suggest” feature doesn’t support this level of security, hence the error. To resolve this issue, you can either disable document level security if it’s not necessary, or avoid using the “suggest” feature. Alternatively, you can implement your own suggestion logic at the application level, bypassing the need for Elasticsearch’s “suggest” feature.

This guide will help you check for common problems that cause the log ” Suggest isn’t supported if document level security is enabled ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: plugin, document.

Log Context

Log “Suggest isn’t supported if document level security is enabled” class name is SearchRequestInterceptor.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 final SearchSourceBuilder source = request.source();  if (indexAccessControlByIndex.values().stream().anyMatch(iac -> iac.getDocumentPermissions().hasDocumentLevelPermissions())) {
 if (source != null && source.suggest() != null) {
 listener.onFailure(new ElasticsearchSecurityException("Suggest isn't supported if document level security is enabled";
 RestStatus.BAD_REQUEST));
 } else if (source != null && source.profile()) {
 listener.onFailure(new ElasticsearchSecurityException("A search request cannot be profiled if document level security " +
 "is enabled"; RestStatus.BAD_REQUEST));
 } else {

 

 [ratemypost]