Class ElasticSearchServiceConnector
- java.lang.Object
-
- org.exoplatform.container.component.BaseComponentPlugin
-
- org.exoplatform.commons.api.search.SearchServiceConnector
-
- org.exoplatform.commons.search.es.ElasticSearchServiceConnector
-
- All Implemented Interfaces:
org.exoplatform.container.component.ComponentPlugin
public class ElasticSearchServiceConnector extends org.exoplatform.commons.api.search.SearchServiceConnectorCreated by The eXo Platform SAS Author : Thibault Clement tclement@exoplatform.com 7/30/15
-
-
Field Summary
Fields Modifier and Type Field Description static StringGROUPstatic intHIGHLIGHT_FRAGMENT_NUMBER_DEFAULT_VALUEstatic StringHIGHLIGHT_FRAGMENT_NUMBER_PARAM_NAMEstatic intHIGHLIGHT_FRAGMENT_SIZE_DEFAULT_VALUEstatic StringHIGHLIGHT_FRAGMENT_SIZE_PARAM_NAMEstatic StringWIKI_TYPE
-
Constructor Summary
Constructors Constructor Description ElasticSearchServiceConnector(org.exoplatform.container.xml.InitParams initParams, ElasticSearchingClient client)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringbuildDetail(org.json.simple.JSONObject jsonHit, org.exoplatform.commons.api.search.data.SearchContext searchContext)protected StringbuildDlpQuery(String query, String id)protected StringbuildFilteredQuery(String query, Collection<String> sites, List<ElasticSearchFilter> filters, int offset, int limit, String sort, String order)protected org.exoplatform.commons.api.search.data.SearchResultbuildHit(org.json.simple.JSONObject jsonHit, org.exoplatform.commons.api.search.data.SearchContext searchContext)protected StringbuildQuery(String query, Collection<String> sites, int offset, int limit, String sort, String order)protected Collection<org.exoplatform.commons.api.search.data.SearchResult>buildResult(String jsonResponse, org.exoplatform.commons.api.search.data.SearchContext context)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 parameterprotected StringescapeReservedCharacters(String query)Escaped reserved characters by ES when using query_string.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)protected StringgetAdditionalFilters(List<ElasticSearchFilter> filters)ElasticSearchingClientgetClient()protected StringgetFields()StringgetImg()StringgetIndex()protected StringgetPermissionFilter()protected StringgetPermissionFilterWiki(String permission)List<String>getSearchFields()protected StringgetSitesFilter(Collection<String> sitesCollection)protected StringgetSourceFields()StringgetTitleElasticFieldName()protected StringgetTitleFromJsonResult(org.json.simple.JSONObject hitSource)protected LonggetUpdatedDateFromResult(org.json.simple.JSONObject hitSource)protected StringgetUrlFromJsonResult(org.json.simple.JSONObject hitSource, org.exoplatform.commons.api.search.data.SearchContext context)booleanisIndexed(org.exoplatform.commons.api.search.data.SearchContext context, String id)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)voidsetImg(String img)voidsetIndex(String index)voidsetSearchFields(List<String> searchFields)voidsetTitleElasticFieldName(String titleElasticFieldName)-
Methods inherited from class org.exoplatform.commons.api.search.SearchServiceConnector
getDisplayName, getSearchType, isEnable, isEnabledForAnonymous, setDisplayName, setEnable, setEnabledForAnonymous, setSearchType
-
-
-
-
Field Detail
-
HIGHLIGHT_FRAGMENT_SIZE_PARAM_NAME
public static final String HIGHLIGHT_FRAGMENT_SIZE_PARAM_NAME
- See Also:
- Constant Field Values
-
HIGHLIGHT_FRAGMENT_SIZE_DEFAULT_VALUE
public static final int HIGHLIGHT_FRAGMENT_SIZE_DEFAULT_VALUE
- See Also:
- Constant Field Values
-
HIGHLIGHT_FRAGMENT_NUMBER_PARAM_NAME
public static final String HIGHLIGHT_FRAGMENT_NUMBER_PARAM_NAME
- See Also:
- Constant Field Values
-
HIGHLIGHT_FRAGMENT_NUMBER_DEFAULT_VALUE
public static final int HIGHLIGHT_FRAGMENT_NUMBER_DEFAULT_VALUE
- See Also:
- Constant Field Values
-
GROUP
public static final String GROUP
- See Also:
- Constant Field Values
-
WIKI_TYPE
public static final String WIKI_TYPE
- See Also:
- Constant Field Values
-
-
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:
searchin classorg.exoplatform.commons.api.search.SearchServiceConnector
-
isIndexed
public boolean isIndexed(org.exoplatform.commons.api.search.data.SearchContext context, String id)- Overrides:
isIndexedin classorg.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
-
buildQuery
protected String buildQuery(String query, Collection<String> sites, int offset, int limit, String sort, String order)
-
buildFilteredQuery
protected String buildFilteredQuery(String query, Collection<String> sites, List<ElasticSearchFilter> filters, int offset, int limit, String sort, String order)
-
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)
-
getAdditionalFilters
protected String getAdditionalFilters(List<ElasticSearchFilter> filters)
-
getFields
protected String getFields()
-
getPermissionFilter
protected String getPermissionFilter()
-
getSitesFilter
protected String getSitesFilter(Collection<String> sitesCollection)
-
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)
-
getClient
public ElasticSearchingClient getClient()
-
-