How to retrieve snippet of attribute from result using java

I have a post with 3 attributes
title,authorwebid,text
for text i only want snippet as the text field is large.

         Query query = new Query("searchstring").setAttributesToRetrieve
					(Arrays.asList("title", "authorwebid"));
					
			query.setAttributesToHighlight(Arrays.asList("text"));
			query.setAttributesToSnippet(Arrays.asList("text:80"));
			
			SearchResult<SearchPost> result = index_post.search(query);

from the result object how do i get snippet of attribute text

Hi @nishant.07, you should be able to use _snippetResult from the response object.

You may also be interested in the snippet widget if you are using instantsearch.

i am able to this via javascript and i get the snippet result but i am unable to do this via java api

You can find the documentation about Java api here: https://www.algolia.com/doc/api-reference/api-parameters/attributesToSnippet/?language=java#the-response-object