Class ElasticSearchServiceConnector

  • All Implemented Interfaces:
    org.exoplatform.container.component.ComponentPlugin

    public class ElasticSearchServiceConnector
    extends org.exoplatform.commons.api.search.SearchServiceConnector
    Created by The eXo Platform SAS Author : Thibault Clement tclement@exoplatform.com 7/30/15
    • Constructor Detail

      • ElasticSearchServiceConnector

        public ElasticSearchServiceConnector​(org.exoplatform.container.xml.InitParams initParams,
                                             ElasticSearchingClient client)
    • Method Detail

      • search

        public Collection<org.exoplatform.commons.api.search.data.SearchResult> search​(org.exoplatform.commons.api.search.data.SearchContext context,
                                                                                       String query,
                                                                                       Collection<String> sites,
                                                                                       int offset,
                                                                                       int limit,
                                                                                       String sort,
                                                                                       String order)
        Specified by:
        search in class org.exoplatform.commons.api.search.SearchServiceConnector
      • isIndexed

        public boolean isIndexed​(org.exoplatform.commons.api.search.data.SearchContext context,
                                 String id)
        Overrides:
        isIndexed in class org.exoplatform.commons.api.search.SearchServiceConnector
      • filteredSearch

        public Collection<org.exoplatform.commons.api.search.data.SearchResult> filteredSearch​(org.exoplatform.commons.api.search.data.SearchContext context,
                                                                                               String query,
                                                                                               List<ElasticSearchFilter> filters,
                                                                                               Collection<String> sites,
                                                                                               int offset,
                                                                                               int limit,
                                                                                               String sort,
                                                                                               String order)
        Search on ES with additional filter on the search query Different Filter are: - Term Filter (Check if a specific term of a field exist) - Not exist Filter (Check if a term not exist) - Exist Filter (check if a term exist)
        Parameters:
        context -
        query -
        filters -
        sites -
        offset -
        limit -
        sort -
        order -
        Returns:
        a collection of SearchResult
      • dlpSearch

        public Collection<org.exoplatform.commons.api.search.data.SearchResult> dlpSearch​(org.exoplatform.commons.api.search.data.SearchContext context,
                                                                                          String query,
                                                                                          String entityId)
        Search on ES for dlp Search keyword in query with an OR And search only for the entity in parameter
        Parameters:
        query -
        entityId -
        Returns:
        a collection of SearchResult
      • escapeReservedCharacters

        protected String escapeReservedCharacters​(String query)
        Escaped reserved characters by ES when using query_string. Only ~ is not escaped since it is used for fuzzy search parameter. The list of reserved characters is documented at https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters
        Parameters:
        query - The unescaped query string
        Returns:
        The escaped query string
      • buildResult

        protected Collection<org.exoplatform.commons.api.search.data.SearchResult> buildResult​(String jsonResponse,
                                                                                               org.exoplatform.commons.api.search.data.SearchContext context)
      • buildHit

        protected org.exoplatform.commons.api.search.data.SearchResult buildHit​(org.json.simple.JSONObject jsonHit,
                                                                                org.exoplatform.commons.api.search.data.SearchContext searchContext)
      • buildDetail

        protected String buildDetail​(org.json.simple.JSONObject jsonHit,
                                     org.exoplatform.commons.api.search.data.SearchContext searchContext)
      • getUpdatedDateFromResult

        protected Long getUpdatedDateFromResult​(org.json.simple.JSONObject hitSource)
      • getUrlFromJsonResult

        protected String getUrlFromJsonResult​(org.json.simple.JSONObject hitSource,
                                              org.exoplatform.commons.api.search.data.SearchContext context)
      • getTitleFromJsonResult

        protected String getTitleFromJsonResult​(org.json.simple.JSONObject hitSource)
      • getFields

        protected String getFields()
      • getPermissionFilter

        protected String getPermissionFilter()
      • getPermissionFilterWiki

        protected String getPermissionFilterWiki​(String permission)
      • getUserMemberships

        protected Set<String> getUserMemberships()
      • getSourceFields

        protected String getSourceFields()
      • getIndex

        public String getIndex()
      • setIndex

        public void setIndex​(String index)
      • getImg

        public String getImg()
      • setImg

        public void setImg​(String img)
      • getTitleElasticFieldName

        public String getTitleElasticFieldName()
      • setTitleElasticFieldName

        public void setTitleElasticFieldName​(String titleElasticFieldName)
      • getSearchFields

        public List<String> getSearchFields()
      • setSearchFields

        public void setSearchFields​(List<String> searchFields)