Class ElasticSearchNxqlPageProvider
- java.lang.Object
-
- org.nuxeo.ecm.platform.query.api.AbstractPageProvider<DocumentModel>
-
- org.nuxeo.ecm.platform.query.nxql.CoreQueryDocumentPageProvider
-
- org.nuxeo.elasticsearch.provider.ElasticSearchNxqlPageProvider
-
- All Implemented Interfaces:
Serializable,PageProvider<DocumentModel>
public class ElasticSearchNxqlPageProvider extends CoreQueryDocumentPageProvider
Elasticsearch Page provider that converts the NXQL query build by CoreQueryDocumentPageProvider.- Since:
- 5.9.3
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringCORE_SESSION_PROPERTYprotected HashMap<String,Aggregate<? extends Bucket>>currentAggregatesstatic longDEFAULT_ES_MAX_RESULT_WINDOW_VALUEstatic StringES_MAX_RESULT_WINDOW_PROPERTYprotected static org.apache.logging.log4j.Loggerlogprotected LongmaxResultWindowstatic StringSEARCH_ON_ALL_REPOSITORIES_PROPERTY-
Fields inherited from class org.nuxeo.ecm.platform.query.nxql.CoreQueryDocumentPageProvider
CHECK_QUERY_CACHE_PROPERTY, currentPageDocuments, DEFAULT_NAVIGATION_RESULTS_KEY, DEFAULT_NAVIGATION_RESULTS_PROPERTY, DEFAULT_NAVIGATION_RESULTS_VALUE, DETACH_DOCUMENTS_PROPERTY, MAX_RESULTS_PROPERTY, maxResults, PAGE_SIZE_RESULTS_KEY, query, USE_UNRESTRICTED_SESSION_PROPERTY
-
Fields inherited from class org.nuxeo.ecm.platform.query.api.AbstractPageProvider
currentEntryIndex, currentHigherNonEmptyPageIndex, currentSelectPage, definition, error, errorMessage, highlights, maxPageSize, name, offset, PAGEPROVIDER_TRACK_PROPERTY_NAME, pageProviderChangedListener, pageSize, pageSizeOptions, parameters, properties, quickFilters, resultsCount, searchDocumentModel, selectedEntries, SKIPPED_SCHEMAS_FOR_SEARCHFIELD, sortable, sortInfos, tracking
-
Fields inherited from interface org.nuxeo.ecm.platform.query.api.PageProvider
DEFAULT_MAX_PAGE_SIZE, DEFAULT_MAX_PAGE_SIZE_RUNTIME_PROP, HIGHLIGHT_CTX_DATA, PAGE_LIMIT_UNKNOWN, SKIP_AGGREGATES_PROP, UNKNOWN_SIZE, UNKNOWN_SIZE_AFTER_QUERY
-
-
Constructor Summary
Constructors Constructor Description ElasticSearchNxqlPageProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<AggregateEsBase<? extends org.elasticsearch.search.aggregations.Aggregation,? extends Bucket>>buildAggregates()Map<String,Aggregate<? extends Bucket>>getAggregates()protected CoreSessiongetCoreSession()List<DocumentModel>getCurrentPage()Returns the list of current page items.org.elasticsearch.index.query.QueryBuildergetCurrentQueryAsEsBuilder()protected intgetLimit()longgetMaxResultWindow()Returns the max result window where the PP can navigate without raising Elasticsearch QueryPhaseExecutionException.longgetPageLimit()Returns the page limit.protected NxQueryBuildergetQueryBuilder(CoreSession session)longgetResultsCountLimit()Limit of number of results beyond which the page provider may not be able to computePageProvider.getResultsCount()or navigate.booleanhasAggregateSupport()protected voidincorporateAggregates(Map<String,Serializable> eventProps)Extends the default implementation to add results of aggregatesbooleanisLastPageAvailable()Returns a boolean expressing if the last page can be displayed.booleanisNextPageAvailable()Returns a boolean expressing if there are further pages.protected voidpageChanged()Page change hook, to override for custom behaviorvoidrefresh()Refresh hook, to override for custom behaviorprotected booleansearchOnAllRepositories()voidsetMaxResultWindow(long maxResultWindow)Set the max result window where the PP can navigate, for testing purpose.-
Methods inherited from class org.nuxeo.ecm.platform.query.nxql.CoreQueryDocumentPageProvider
buildQuery, checkQueryCache, detachDocuments, getCurrentQuery, getCurrentSelectPage, getFilter, getMaxResults, rewindSelectablePage, setMaxResults, useUnrestrictedSession
-
Methods inherited from class org.nuxeo.ecm.platform.query.api.AbstractPageProvider
addQuickFilter, addSortInfo, fireSearchEvent, firstPage, getAggregateDefinitions, getAvailableQuickFilters, getBooleanProperty, getCurrentEntry, getCurrentHigherNonEmptyPageIndex, getCurrentPageIndex, getCurrentPageOffset, getCurrentPageSize, getCurrentPageStatus, getDefaultMaxPageSize, getDefinition, getError, getErrorMessage, getHighlights, getMaxNumberOfEmptyPages, getMaxPageSize, getMinMaxPageSize, getName, getNumberOfPages, getPageSize, getPageSizeOptions, getParameters, getParametersChanged, getProperties, getQuickFilters, getResultsCount, getSearchDocumentModel, getSortInfo, getSortInfoIndex, getSortInfos, hasChangedParameters, hasError, isNextEntryAvailable, isPreviousEntryAvailable, isPreviousPageAvailable, isSkipAggregates, isSortable, isTrackingEnabled, lastPage, nextEntry, nextPage, notifyPageChanged, notifyRefresh, previousEntry, previousPage, searchDocumentModelChanged, setCurrentEntry, setCurrentEntryIndex, setCurrentHigherNonEmptyPageIndex, setCurrentPage, setCurrentPageIndex, setCurrentPageOffset, setDefinition, setHighlights, setMaxPageSize, setName, setPageProviderChangedListener, setPageSize, setPageSizeOptions, setParameters, setProperties, setQuickFilters, setResultsCount, setSearchDocumentModel, setSelectedEntries, setSortable, setSortInfo, setSortInfo, setSortInfos, sortInfoChanged
-
-
-
-
Field Detail
-
CORE_SESSION_PROPERTY
public static final String CORE_SESSION_PROPERTY
- See Also:
- Constant Field Values
-
SEARCH_ON_ALL_REPOSITORIES_PROPERTY
public static final String SEARCH_ON_ALL_REPOSITORIES_PROPERTY
- See Also:
- Constant Field Values
-
ES_MAX_RESULT_WINDOW_PROPERTY
public static final String ES_MAX_RESULT_WINDOW_PROPERTY
- See Also:
- Constant Field Values
-
DEFAULT_ES_MAX_RESULT_WINDOW_VALUE
public static final long DEFAULT_ES_MAX_RESULT_WINDOW_VALUE
- See Also:
- Constant Field Values
-
log
protected static final org.apache.logging.log4j.Logger log
-
maxResultWindow
protected Long maxResultWindow
-
-
Method Detail
-
getCurrentPage
public List<DocumentModel> getCurrentPage()
Description copied from class:AbstractPageProviderReturns the list of current page items.Custom implementation can be added here, based on the page provider properties, parameters and
WhereClauseDefinitionon thePageProviderDefinition, as well as search document, sort information, etc...Implementation of this method usually consists in setting a non-null value to a field caching current items, and nullifying this field by overriding
AbstractPageProvider.pageChanged()andAbstractPageProvider.refresh().Fields
AbstractPageProvider.errorMessageandAbstractPageProvider.errorcan also be filled to provide accurate feedback in case an error occurs during the search.When items are retrieved, a call to
AbstractPageProvider.setResultsCount(long)should be made to ensure proper pagination as implemented in this abstract class. The implementation inCoreQueryAndFetchPageProvideris a good example when the total results count is known.If for performance reasons, for instance, the number of results cannot be known, a fall-back strategy can be applied to provide the "next" button but not the "last" one, by calling
AbstractPageProvider.getCurrentHigherNonEmptyPageIndex()andAbstractPageProvider.setCurrentHigherNonEmptyPageIndex(int). In this case,CoreQueryDocumentPageProvideris a good example.- Specified by:
getCurrentPagein interfacePageProvider<DocumentModel>- Overrides:
getCurrentPagein classCoreQueryDocumentPageProvider- Returns:
- the current page
-
getLimit
protected int getLimit()
-
getCurrentQueryAsEsBuilder
public org.elasticsearch.index.query.QueryBuilder getCurrentQueryAsEsBuilder()
-
pageChanged
protected void pageChanged()
Description copied from class:AbstractPageProviderPage change hook, to override for custom behaviorWhen overriding it, call
super.pageChanged()as last statement to make sure that thePageProviderChangedListeneris called with the up-to-date @{code PageProvider} state.- Overrides:
pageChangedin classCoreQueryDocumentPageProvider
-
refresh
public void refresh()
Description copied from class:AbstractPageProviderRefresh hook, to override for custom behaviorWhen overriding it, call
super.refresh()as last statement to make sure that thePageProviderChangedListeneris called with the up-to-date @{code PageProvider} state.- Specified by:
refreshin interfacePageProvider<DocumentModel>- Overrides:
refreshin classCoreQueryDocumentPageProvider
-
getCoreSession
protected CoreSession getCoreSession()
- Overrides:
getCoreSessionin classCoreQueryDocumentPageProvider
-
buildAggregates
protected List<AggregateEsBase<? extends org.elasticsearch.search.aggregations.Aggregation,? extends Bucket>> buildAggregates()
-
searchOnAllRepositories
protected boolean searchOnAllRepositories()
-
hasAggregateSupport
public boolean hasAggregateSupport()
- Specified by:
hasAggregateSupportin interfacePageProvider<DocumentModel>- Overrides:
hasAggregateSupportin classAbstractPageProvider<DocumentModel>
-
getAggregates
public Map<String,Aggregate<? extends Bucket>> getAggregates()
- Specified by:
getAggregatesin interfacePageProvider<DocumentModel>- Overrides:
getAggregatesin classAbstractPageProvider<DocumentModel>
-
incorporateAggregates
protected void incorporateAggregates(Map<String,Serializable> eventProps)
Extends the default implementation to add results of aggregates- Overrides:
incorporateAggregatesin classAbstractPageProvider<DocumentModel>- Since:
- 7.4
-
isLastPageAvailable
public boolean isLastPageAvailable()
Description copied from interface:PageProviderReturns a boolean expressing if the last page can be displayed.- Specified by:
isLastPageAvailablein interfacePageProvider<DocumentModel>- Overrides:
isLastPageAvailablein classAbstractPageProvider<DocumentModel>
-
isNextPageAvailable
public boolean isNextPageAvailable()
Description copied from interface:PageProviderReturns a boolean expressing if there are further pages.- Specified by:
isNextPageAvailablein interfacePageProvider<DocumentModel>- Overrides:
isNextPageAvailablein classAbstractPageProvider<DocumentModel>
-
getPageLimit
public long getPageLimit()
Description copied from class:CoreQueryDocumentPageProviderReturns the page limit. The n first page we know they exist. We don't compute the number of page beyond this limit.- Specified by:
getPageLimitin interfacePageProvider<DocumentModel>- Overrides:
getPageLimitin classCoreQueryDocumentPageProvider
-
getMaxResultWindow
public long getMaxResultWindow()
Returns the max result window where the PP can navigate without raising Elasticsearch QueryPhaseExecutionException.from + sizemust be less than or equal to this value.- Since:
- 9.2
-
getResultsCountLimit
public long getResultsCountLimit()
Description copied from interface:PageProviderLimit of number of results beyond which the page provider may not be able to computePageProvider.getResultsCount()or navigate.Requesting results beyond this limit may result in error. When
PageProvider.getResultsCount()is negative, it means there may be more results than this limit.0 means there is no limit.
- Specified by:
getResultsCountLimitin interfacePageProvider<DocumentModel>- Overrides:
getResultsCountLimitin classCoreQueryDocumentPageProvider
-
setMaxResultWindow
public void setMaxResultWindow(long maxResultWindow)
Set the max result window where the PP can navigate, for testing purpose.- Since:
- 9.2
-
getQueryBuilder
protected NxQueryBuilder getQueryBuilder(CoreSession session)
- Since:
- 2021.11
-
-