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 String
CORE_SESSION_PROPERTY
protected HashMap<String,Aggregate<? extends Bucket>>
currentAggregates
static long
DEFAULT_ES_MAX_RESULT_WINDOW_VALUE
static String
ES_MAX_RESULT_WINDOW_PROPERTY
protected static org.apache.logging.log4j.Logger
log
protected Long
maxResultWindow
static String
SEARCH_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 CoreSession
getCoreSession()
List<DocumentModel>
getCurrentPage()
Returns the list of current page items.org.elasticsearch.index.query.QueryBuilder
getCurrentQueryAsEsBuilder()
protected int
getLimit()
long
getMaxResultWindow()
Returns the max result window where the PP can navigate without raising Elasticsearch QueryPhaseExecutionException.long
getPageLimit()
Returns the page limit.protected NxQueryBuilder
getQueryBuilder(CoreSession session)
long
getResultsCountLimit()
Limit of number of results beyond which the page provider may not be able to computePageProvider.getResultsCount()
or navigate.boolean
hasAggregateSupport()
protected void
incorporateAggregates(Map<String,Serializable> eventProps)
Extends the default implementation to add results of aggregatesboolean
isLastPageAvailable()
Returns a boolean expressing if the last page can be displayed.boolean
isNextPageAvailable()
Returns a boolean expressing if there are further pages.protected void
pageChanged()
Page change hook, to override for custom behaviorvoid
refresh()
Refresh hook, to override for custom behaviorprotected boolean
searchOnAllRepositories()
void
setMaxResultWindow(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:AbstractPageProvider
Returns the list of current page items.Custom implementation can be added here, based on the page provider properties, parameters and
WhereClauseDefinition
on 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.errorMessage
andAbstractPageProvider.error
can 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 inCoreQueryAndFetchPageProvider
is 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,CoreQueryDocumentPageProvider
is a good example.- Specified by:
getCurrentPage
in interfacePageProvider<DocumentModel>
- Overrides:
getCurrentPage
in 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:AbstractPageProvider
Page change hook, to override for custom behaviorWhen overriding it, call
super.pageChanged()
as last statement to make sure that thePageProviderChangedListener
is called with the up-to-date @{code PageProvider} state.- Overrides:
pageChanged
in classCoreQueryDocumentPageProvider
-
refresh
public void refresh()
Description copied from class:AbstractPageProvider
Refresh hook, to override for custom behaviorWhen overriding it, call
super.refresh()
as last statement to make sure that thePageProviderChangedListener
is called with the up-to-date @{code PageProvider} state.- Specified by:
refresh
in interfacePageProvider<DocumentModel>
- Overrides:
refresh
in classCoreQueryDocumentPageProvider
-
getCoreSession
protected CoreSession getCoreSession()
- Overrides:
getCoreSession
in classCoreQueryDocumentPageProvider
-
buildAggregates
protected List<AggregateEsBase<? extends org.elasticsearch.search.aggregations.Aggregation,? extends Bucket>> buildAggregates()
-
searchOnAllRepositories
protected boolean searchOnAllRepositories()
-
hasAggregateSupport
public boolean hasAggregateSupport()
- Specified by:
hasAggregateSupport
in interfacePageProvider<DocumentModel>
- Overrides:
hasAggregateSupport
in classAbstractPageProvider<DocumentModel>
-
getAggregates
public Map<String,Aggregate<? extends Bucket>> getAggregates()
- Specified by:
getAggregates
in interfacePageProvider<DocumentModel>
- Overrides:
getAggregates
in classAbstractPageProvider<DocumentModel>
-
incorporateAggregates
protected void incorporateAggregates(Map<String,Serializable> eventProps)
Extends the default implementation to add results of aggregates- Overrides:
incorporateAggregates
in classAbstractPageProvider<DocumentModel>
- Since:
- 7.4
-
isLastPageAvailable
public boolean isLastPageAvailable()
Description copied from interface:PageProvider
Returns a boolean expressing if the last page can be displayed.- Specified by:
isLastPageAvailable
in interfacePageProvider<DocumentModel>
- Overrides:
isLastPageAvailable
in classAbstractPageProvider<DocumentModel>
-
isNextPageAvailable
public boolean isNextPageAvailable()
Description copied from interface:PageProvider
Returns a boolean expressing if there are further pages.- Specified by:
isNextPageAvailable
in interfacePageProvider<DocumentModel>
- Overrides:
isNextPageAvailable
in classAbstractPageProvider<DocumentModel>
-
getPageLimit
public long getPageLimit()
Description copied from class:CoreQueryDocumentPageProvider
Returns the page limit. The n first page we know they exist. We don't compute the number of page beyond this limit.- Specified by:
getPageLimit
in interfacePageProvider<DocumentModel>
- Overrides:
getPageLimit
in classCoreQueryDocumentPageProvider
-
getMaxResultWindow
public long getMaxResultWindow()
Returns the max result window where the PP can navigate without raising Elasticsearch QueryPhaseExecutionException.from + size
must be less than or equal to this value.- Since:
- 9.2
-
getResultsCountLimit
public long getResultsCountLimit()
Description copied from interface:PageProvider
Limit 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:
getResultsCountLimit
in interfacePageProvider<DocumentModel>
- Overrides:
getResultsCountLimit
in 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
-
-