Class PageContentSearchConnector
java.lang.Object
io.meeds.social.cms.storage.elasticsearch.PageContentSearchConnector
Searches pages previously indexed by
PageContentIndexingConnector
(index alias page_content_alias) for the unified search bar —
content block documents and bare page documents alike, both carrying the
page's title, name and site.
Results come back in three tiers, decided by the query template
(page-search-query.json) rather than here so that paging stays
consistent across calls: pages whose name (title or name) and
content both match the term, then pages matched by name only,
then pages matched by content only. Each tier is a constant_score
clause whose boost dwarfs the relevance score, which only orders results
within a tier.
-
Constructor Summary
ConstructorsConstructorDescriptionPageContentSearchConnector(org.exoplatform.container.configuration.ConfigurationManager configurationManager, org.exoplatform.commons.search.es.client.ElasticSearchingClient client, org.exoplatform.portal.mop.service.LayoutService layoutService, org.exoplatform.services.resources.ResourceBundleManager resourceBundleManager, org.exoplatform.social.metadata.favorite.FavoriteService favoriteService, org.exoplatform.social.core.manager.IdentityManager identityManager, org.exoplatform.social.core.space.spi.SpaceService spaceService, org.exoplatform.services.resources.LocaleConfigService localeConfigService, org.exoplatform.portal.config.UserPortalConfigService portalConfigService, org.exoplatform.container.xml.InitParams initParams) -
Method Summary
Modifier and TypeMethodDescriptionfindIndexedDocumentIds(String pageStorageId) Fetches a single previously-indexed page by its storage id, regardless of whether any term matches it — used to hydrate a page that a user already bookmarked for display in their favorites list.search(String term, int offset, int limit, Locale locale, List<Long> spaceIds, boolean favorites, String site) Same assearch(String, int, int, Locale, List, boolean), with the portal site the user searches from: a page of the global site, whose navigation the portal appends to every portal site's own, is then presented as an entry of that site (seeisPresentedInSite(java.lang.String, java.lang.String, java.lang.String)).
-
Constructor Details
-
PageContentSearchConnector
public PageContentSearchConnector(org.exoplatform.container.configuration.ConfigurationManager configurationManager, org.exoplatform.commons.search.es.client.ElasticSearchingClient client, org.exoplatform.portal.mop.service.LayoutService layoutService, org.exoplatform.services.resources.ResourceBundleManager resourceBundleManager, org.exoplatform.social.metadata.favorite.FavoriteService favoriteService, org.exoplatform.social.core.manager.IdentityManager identityManager, org.exoplatform.social.core.space.spi.SpaceService spaceService, org.exoplatform.services.resources.LocaleConfigService localeConfigService, org.exoplatform.portal.config.UserPortalConfigService portalConfigService, org.exoplatform.container.xml.InitParams initParams)
-
-
Method Details
-
search
public List<PageSearchResult> search(String term, int offset, int limit, Locale locale, List<Long> spaceIds, boolean favorites) - Parameters:
term- the search term, mandatoryoffset- the result offsetlimit- the result limitlocale- the user's locale, used to pick the excerpts' languagespaceIds- the space ids to restrict results to, ornull/empty for nonefavorites- whether to restrict results to the pages the current user bookmarked — the unified search bar's "Favorites" toggle appends it as a query parameter for every connector declaringfavoritesEnabled, so it has to be honoured here rather than silently dropped- Returns:
- the matching
PageSearchResults
-
search
public List<PageSearchResult> search(String term, int offset, int limit, Locale locale, List<Long> spaceIds, boolean favorites, String site) Same assearch(String, int, int, Locale, List, boolean), with the portal site the user searches from: a page of the global site, whose navigation the portal appends to every portal site's own, is then presented as an entry of that site (seeisPresentedInSite(java.lang.String, java.lang.String, java.lang.String)).- Parameters:
site- the name of the portal site the user searches from, ornull/blank when unknown
-
getById
Fetches a single previously-indexed page by its storage id, regardless of whether any term matches it — used to hydrate a page that a user already bookmarked for display in their favorites list. Unlikesearch(java.lang.String, int, int, java.util.Locale, java.util.List<java.lang.Long>, boolean), there is no query term to highlight against, so the excerpt is a plain (non-highlighted) snippet of the user's own language content, falling back to the default content.- Parameters:
id- the page's storage idlocale- the user's locale, used to pick the excerpt's language- Returns:
- the matching
PageSearchResult, ornullif none was found oridisn't shaped like a block id
-
findIndexedDocumentIds
- Parameters:
pageStorageId- the storage id of the page to look up- Returns:
- the ids of every document currently indexed under the given
page — its content blocks, regardless of whether a
CMSSettingstill binds them, and its bare page document when it has one — used to detect what no longer represents the page (a block detached from it, the bare document of a page that received a block, the page itself removed or never re-saved) so the caller can unindex it. Returns an empty list, without ever querying Elasticsearch, whenpageStorageIdisn't shaped like one (defends the same waygetById(java.lang.String, java.util.Locale)does, in case this public method is ever reached with untrusted input).
-