Skip to Content
0
Oct 26, 2019 at 10:38 AM

FlexibleSearchQuery getting into ranges.

165 Views

Hello Friends,

As per the documentation when we retrieve the Products using FlexibleSearch SAP Hybris recommends to get the data into ranges to improve the performance using below approach.

 String query = "SELECT {" + UnitModel.PK + "} FROM {" + UnitModel._TYPECODE + "} ORDER BY " + UnitModel._TYPECODE;
 final FlexibleSearchQuery fQuery = new FlexibleSearchQuery(query);
 fQuery.setCount(range);
 fQuery.setNeedTotal(true);
 
 int start = 0;
 final int range = 3;
 int total;
 
 do
 {
        fQuery.setStart(start);
        final SearchResult<UnitModel> searchResult = flexibleSearchService.search(fQuery);
        total = searchResult.getTotalCount();
        start += range;
 }
 while (start < total);

i expected 3 items each iteration. But i am getting all the time full records from Product Table. Am I misssing anything here.

https://help.sap.com/doc/c74a78df6c654be3a432b9c1ab173d42/6.7.0.0/en-US/index.html

Thanks