Collapse results by multipli fields( highRestClient java

I need do collapse by two fields :field1 and field2
I use java
collapse by field1
searchSourceBuilder.collapse(new CollapseBuilder("field1").setInnerHits(innerHitBuilder));

In my case I need additional collapse by field2
Is there way to do it?

try second level of collapse

Thank you for the answer .Will try it.
Please , can you refer me where I can find it java code ?I don't see it .
Thanks again

Use it like this:

SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(QueryBuilders.matchQuery("text", "elastic"));
CollapseBuilder sb=new CollapseBuilder("firstField");
InnerHitBuilder ib =new InnerHitBuilder("secondField");

Thank you

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