Troubleshooting OpenSearch
Query fails due to large number of spaces a user can access
Context
Confluence applies a space permission check as terms to every search query. OpenSearch index settings has a default limit of index.max_terms_count
as 65536.
Failure
When a user has access to more than 65536 spaces, the search request will fail and the log will contain an error message:
ERROR [http-nio-8080-exec-1] [spring.interceptors.OpenSearchExceptionHandlingInterceptor] invoke Exception while calling OpenSearch. Root causes: [type : query_shard_exception, reason : failed to create query: The number of terms [100002] used in the Terms Query request has exceeded the allowed maximum of [65536]. This maximum can be set by changing the [index.max_terms_count] index level setting., stacktrace : null]
Resolution
Increase index.max_terms_count
of the related indexes so that it’s equal to or greater than the maximum number of spaces that a user can have access to.
Refer to Configuring index settings on OpenSearch for details on how to configure index settings.