此内容没有您所选择的语言版本。
5.2. Retrieving the results
Once the Hibernate Search query is built, executing it is in no way different than executing a HQL or Criteria query. The same paradigm and object semantic applies. All the common operations are available:
list(), uniqueResult(), iterate(), scroll().
5.2.1. Performance considerations 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
If you expect a reasonable number of results (for example using pagination) and expect to work on all of them,
list() or uniqueResult() are recommended. list() work best if the entity batch-size is set up properly. Note that Hibernate Search has to process all Lucene Hits elements (within the pagination) when using list() , uniqueResult() and iterate().
If you wish to minimize Lucene document loading,
scroll() is more appropriate. Do not forget to close the ScrollableResults object when you are done, since it keeps Lucene resources. If you expect to use scroll, but wish to load objects in batch, you can use query.setFetchSize(). When an object is accessed, and if not already loaded, Hibernate Search will load the next fetchSize objects in one pass.
Pagination is a preferred method over scrolling though.