About Elasticsearch5.4 java api

I used es5.4 java api build CompletionSuggestionBuilder.why cannot use compBuilder.field("suggest"),here is my code

CompletionSuggestionBuilder compBuilder = new
CompletionSuggestionBuilder("complete");
compBuilder.text("n");
compBuilder.field("suggest");
SuggestRequestBuilder suggestRequestBuilder =
client.prepareSuggest(INDEX_NAME);
suggestRequestBuilder.addSuggestion(compBuilder);
SuggestResponse suggestResponse =
suggestRequestBuilder.execute().actionGet();

			CompletionSuggestion compSuggestion = 
			suggestResponse.getSuggest().getSuggestion("complete"); 

			List entryList = compSuggestion.getEntries(); 
			if(entryList != null) { 
				CompletionSuggestion.Entry entry = entryList.get(0); 
				List options =entry.getOptions(); 
				if(options != null) { 
					CompletionSuggestion.Entry.Option option = options.get(0); 
					toReturn = option.getText().string(); 
				} 
			} 
			return toReturn;

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