Hybris FlexibleSearch Pagination

5.5k views Asked by At

I was going through wiki documentation on Flexible Search and found out that pagination could be handled by setting 3 attributes on FlexibleSearchQuery namely start, count and needTotal.

However, in my project I have come across examples were pagedFlexibleSearchService is used along with PageableData which also holds the above attributes.

Could someone please let me know what is the difference between the 2 approaches? Would I be able to achieve pagination using FlexibleSearchService?

Also what is the significance of needTotal?

1

There are 1 answers

1
Mafick On BEST ANSWER

you mentioned out the two different points.

FlexibleSearch is just for searching that will you return a Collection from your search.

PagedFlexibleSearch will you return a resultList in a pagination. This pagination has some more information, that you can use in your frontend. For example:

getFlexibleSearchService.search(query)

Here you just but in your searchQuery.

getPagedFlexibleSearchService().search(sortQueries, defaultSortCode, queryParams, pageableData)

Here you will have the following information.

  • sortQueries - the result list can be sorted by the given attributes
  • defaultSortCode - if no sortCode is given, which one will be the deafult one
  • queryParams - the params for the flexibleSearch
  • pageableData - this object will hold the 'pageSize', 'currentPage' and 'maxSize' (I am not quit sure about this here, but it will definitely hold information for the pagination.

So in common you will use the FlexibleSearch just to get all results by the given params (for example the 'freeTextSearch') and the PagedFlexibleSearch if you want to sort and only show a subset the results (for example the 'productSearch' on the productGridPage)