Class PageContentSearchConnector

java.lang.Object
io.meeds.social.cms.storage.elasticsearch.PageContentSearchConnector

public class PageContentSearchConnector extends Object
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

    Constructors
    Constructor
    Description
    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 Summary

    Modifier and Type
    Method
    Description
     
    getById(String id, Locale locale)
    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)
     
    search(String term, int offset, int limit, Locale locale, List<Long> spaceIds, boolean favorites, String site)
    Same as search(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 (see isPresentedInSite(java.lang.String, java.lang.String, java.lang.String)).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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, mandatory
      offset - the result offset
      limit - the result limit
      locale - the user's locale, used to pick the excerpts' language
      spaceIds - the space ids to restrict results to, or null/empty for none
      favorites - 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 declaring favoritesEnabled, 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 as search(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 (see isPresentedInSite(java.lang.String, java.lang.String, java.lang.String)).
      Parameters:
      site - the name of the portal site the user searches from, or null/blank when unknown
    • getById

      public PageSearchResult getById(String id, Locale locale)
      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. Unlike search(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 id
      locale - the user's locale, used to pick the excerpt's language
      Returns:
      the matching PageSearchResult, or null if none was found or id isn't shaped like a block id
    • findIndexedDocumentIds

      public List<String> findIndexedDocumentIds(String pageStorageId)
      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 CMSSetting still 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, when pageStorageId isn't shaped like one (defends the same way getById(java.lang.String, java.util.Locale) does, in case this public method is ever reached with untrusted input).