@StableMinor(version="12.3", sinceVersion="8.1") public class SearchDataProvider extends Object implements IDataProvider<SearchSource>
Modifier and Type | Class and Description |
---|---|
static class |
SearchDataProvider.ParsedUserQuery
Class that holds optional parsed user query and query filter.
|
Modifier and Type | Field and Description |
---|---|
static String |
SOURCE_PARAMETER_NAME_AGGREGATED_VALUES
Name of the parameter that holds the aggregated values (user's filters).
|
static String |
SOURCE_PARAMETER_NAME_AGGREGATIONS
Name of the parameter that holds the aggregations that should be performed during search.
|
static String |
SOURCE_PARAMETER_NAME_CONTROL_QUERY |
static String |
SOURCE_PARAMETER_NAME_QUERY |
static String |
SOURCE_PARAMETER_NAME_SCOPE_SERVICE_INSTANCE |
static String |
SOURCE_PARAMETER_NAME_STATUS |
static String |
SOURCE_PARAMETER_TARGET_OBJECTS_SOURCE_ID |
INTERFACE_INSTANCE_PROPERTY_FIELDS, INTERFACE_INSTANCE_PROPERTY_FILTERS, INTERFACE_INSTANCE_PROPERTY_MAX_ROWS, INTERFACE_INSTANCE_PROPERTY_ORDER_BY, MAX_NUM_ORDER_BY_FIELDS
Constructor and Description |
---|
SearchDataProvider() |
Modifier and Type | Method and Description |
---|---|
protected Map<DocumentTypeField,Float> |
getFieldsBoost(SessionConfig sessionConfig,
SearchSource searchSource,
ServiceInstanceConfig searchServiceInstanceConfig,
ITransaction transaction)
Returns the fields boosts configuration.
|
protected Object |
getHighlight(ISearchHit hit,
ISourceData row)
Returns the highlight value for the given row.
|
protected HighlightConfig |
getHighlightConfiguration()
Returns the highlight configuration.
|
protected String |
getMainPublishedContextUrlValue(ISearchHit hit)
Returns the main context URL value that user has access permission.
|
protected Object |
getPublications(ISearchHit hit,
ISourceData row,
SearchSource searchSource)
Returns the publications of the given search hit.
|
protected Collection<String> |
getPublishedContextIdsIncludedInSearch(SearchSource searchSource,
ServiceInstanceConfig searchServiceInstanceConfig)
Returns the identifiers of the published contexts that should be included in search.
|
protected Set<String> |
getSearchFieldIds(SessionConfig sessionConfig,
SearchSource searchSource,
ITransaction transaction)
Returns the search fields identifiers.
|
protected IMonitor |
getSearchMonitor(String userQuery,
String unparsedUserQuery,
SearchSource searchSource,
ITransaction transaction)
Returns the
monitor object to be used in monitoring or null if the search will not be monitored. |
protected ServiceInstanceConfig |
getSearchServiceInstance(SessionConfig sessionConfig,
SearchSource searchSource,
ITransaction transaction)
Returns the search service instance.
|
protected List<SearchQuerySort> |
getSearchSorts(SessionConfig sessionConfig,
SearchSource searchSource,
ServiceInstanceConfig searchServiceInstanceConfig,
ITransaction transaction)
Returns the search's
sorts . |
protected ISearchQueryFilter |
getTargetObjectsSourceFilter(SearchSource source,
ITransaction transaction)
Returns the target objects source id filter.
|
protected String |
getUserQuery(SessionConfig sessionConfig,
SearchSource searchSource,
ITransaction transaction)
Returns the user query to be used in search.
|
protected boolean |
hasUserQueryChanged(SearchSource searchSource)
Returns whether the user query parameter has changed for the current
request.
|
void |
loadData(SessionConfig sessionConfig,
SearchSource searchSource,
ITransaction transaction) |
protected SearchDataProvider.ParsedUserQuery |
parseUserQuery(String query)
Parse the given user query to generate a
parsed version of it . |
protected void |
populateRow(SessionConfig sessionConfig,
ISourceData row,
ISearchHit hit,
Set<String> fieldIds,
SearchSource searchSource,
ITransaction transaction)
Populate the given row with the given search hit.
|
protected void |
populateRowField(SessionConfig sessionConfig,
ISourceData row,
ISearchHit hit,
String fieldId,
SearchSource searchSource,
ITransaction transaction)
Populates the given field within the row with the given hit.
|
public static final String SOURCE_PARAMETER_NAME_SCOPE_SERVICE_INSTANCE
public static final String SOURCE_PARAMETER_NAME_QUERY
public static final String SOURCE_PARAMETER_NAME_AGGREGATIONS
public static final String SOURCE_PARAMETER_NAME_AGGREGATED_VALUES
public static final String SOURCE_PARAMETER_NAME_CONTROL_QUERY
public static final String SOURCE_PARAMETER_NAME_STATUS
public static final String SOURCE_PARAMETER_TARGET_OBJECTS_SOURCE_ID
public void loadData(SessionConfig sessionConfig, SearchSource searchSource, ITransaction transaction) throws PortalException
loadData
in interface IDataProvider<SearchSource>
PortalException
protected Map<DocumentTypeField,Float> getFieldsBoost(SessionConfig sessionConfig, SearchSource searchSource, ServiceInstanceConfig searchServiceInstanceConfig, ITransaction transaction) throws PortalException
null
if no boosting configuration must be applied.sessionConfig
- the user's session.searchSource
- the search source.searchServiceInstanceConfig
- the search service instance.transaction
- the transaction.PortalException
SearchQuery.addFieldBoost(DocumentTypeField, float)
protected boolean hasUserQueryChanged(SearchSource searchSource)
searchSource
- the search source.true
if the user query parameter has changed, false
otherwise.protected ISearchQueryFilter getTargetObjectsSourceFilter(SearchSource source, ITransaction transaction)
SOURCE_PARAMETER_TARGET_OBJECTS_SOURCE_ID
.
This value may be either a full source id (service id + '.' + source id, like 'lumis.service.news.default')
or a simple source id (like 'default').
In the case of a simple source id, the source's service id will be retrieved from current request's context.
ContentVersionDocumentType.ContentFields.SOURCE_ID
- using the source id.
StandardDocumentType.StandardFields.CONTEXT_IDS
- using source's service id.
source
- transaction
- protected IMonitor getSearchMonitor(String userQuery, String unparsedUserQuery, SearchSource searchSource, ITransaction transaction) throws PortalException
monitor
object to be used in monitoring or null
if the search will not be monitored.userQuery
- the user query (extracted from unparsed user query).unparsedUserQuery
- the unparsed user query.searchSource
- the search sourcetransaction
- the transaction.monitor
object to be used in monitoring or null
if the search will not be monitored.PortalException
protected SearchDataProvider.ParsedUserQuery parseUserQuery(String query)
parsed version of it
.
This method must not return null.
The default implementation follows the following rules:
ContentLocaleFields#TAG_NORMALIZED_NAME
), identifying them
by terms starting with #
. The #
char must be followed by a letter
char. All chars after #
char, that are alphanumeric will be identified as a tag filter.
The tags filters will be transformed in lower case
.
All tags filters will be removed from user query and filters
to the tag normalized name field
will be created using
them.
trimmed
and multiple spaces will be transformed in
a single space char.
Seattle Seahawks #nfl #twelves #Love#NFL #"GoHawks"
, the parsed user query would be:
Seattle Seahawks #"GoHawks"
nfl
twelves
love
query
- the user query.protected HighlightConfig getHighlightConfiguration()
protected Collection<String> getPublishedContextIdsIncludedInSearch(SearchSource searchSource, ServiceInstanceConfig searchServiceInstanceConfig) throws PortalException
null
. If no published contexts should be included, an empty set
should be returned instead.searchSource
- the search source.searchServiceInstanceConfig
- the search service instance.PortalException
protected void populateRow(SessionConfig sessionConfig, ISourceData row, ISearchHit hit, Set<String> fieldIds, SearchSource searchSource, ITransaction transaction) throws PortalException
sessionConfig
- the user's session.row
- the row to be populated.hit
- the search hit.fieldIds
- the source fields identifiers.searchSource
- the source.transaction
- the transaction.PortalException
protected Object getHighlight(ISearchHit hit, ISourceData row)
hit
- the search hit.row
- the row.protected Object getPublications(ISearchHit hit, ISourceData row, SearchSource searchSource) throws PortalException
hit
- the search hit.row
- the row being processed.searchSource
- the search source.PortalException
protected void populateRowField(SessionConfig sessionConfig, ISourceData row, ISearchHit hit, String fieldId, SearchSource searchSource, ITransaction transaction) throws PortalException
sessionConfig
- the user's session.row
- the row to be populated.hit
- the search hit.fieldId
- the identifier of the field currently being populated.searchSource
- the search source.transaction
- the transaction.PortalException
protected String getMainPublishedContextUrlValue(ISearchHit hit) throws PortalException
hit
- the search hit.PortalException
protected List<SearchQuerySort> getSearchSorts(SessionConfig sessionConfig, SearchSource searchSource, ServiceInstanceConfig searchServiceInstanceConfig, ITransaction transaction)
sorts
. This method is not supposed to return null
. If no
sort is to be applied in search, an empty list
should be returned instead.sessionConfig
- the user's session.searchSource
- the search source.searchServiceInstanceConfig
- the search service instance.transaction
- the transaction.sorts
SearchQuerySort
,
SearchQuery#addSort(SearchQuerySort)
protected String getUserQuery(SessionConfig sessionConfig, SearchSource searchSource, ITransaction transaction)
null
should be returned.sessionConfig
- the user's session.searchSource
- the search source.transaction
- the transaction.SearchQuery.setUserQuery(String)
protected Set<String> getSearchFieldIds(SessionConfig sessionConfig, SearchSource searchSource, ITransaction transaction)
fields
identifiers
.sessionConfig
- the user's session.searchSource
- the search source.transaction
- the transaction.protected ServiceInstanceConfig getSearchServiceInstance(SessionConfig sessionConfig, SearchSource searchSource, ITransaction transaction) throws PortalException
null
.sessionConfig
- the user's session.searchSource
- the search source.transaction
- the transaction.PortalException
LumisXP 12.3.0.200408 - Copyright © 2006–2020 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.