How to add contexts to Suggestion Builder in java

SuggestionBuilder suggestionBuilder = SuggestBuilders.completionSuggestion("suggest").prefix("test").contexts(Collections.singletonMap("cat", Collections.singletonList(CategoryQueryContext.builder().setCategory("cat0").build())));
			SuggestBuilder suggestBuilder = new SuggestBuilder();
			suggestBuilder.addSuggestion("test123", suggestionBuilder);
			
			SearchRequest searchRequest = new SearchRequest("test");
			SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
			searchSourceBuilder.suggest(suggestBuilder);
			searchRequest.source(searchSourceBuilder);
			
			SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);`Preformatted text`

In the above code, the contexts method does not let me pass the argument as above. It says : The method contexts(Map<String,List<? extends ToXContent>>) in the type CompletionSuggestionBuilder is not applicable for the arguments (Map<String,List<
CategoryQueryContext>>)

Is there a different way to add context in the SuggestionBuilder in java?
I am using elastic 7.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.