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.SearchServiceConnector
Created by The eXo Platform SAS
Author : Thibault Clement
tclement@exoplatform.com
7/30/15
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final intstatic final Stringstatic final intstatic final Stringstatic final StringFields inherited from class org.exoplatform.container.component.BaseComponentPlugin
desc, name -
Constructor Summary
ConstructorsConstructorDescriptionElasticSearchServiceConnector(org.exoplatform.container.xml.InitParams initParams, ElasticSearchingClient client) -
Method Summary
Modifier and TypeMethodDescriptionprotected StringbuildDetail(org.json.simple.JSONObject jsonHit, org.exoplatform.commons.api.search.data.SearchContext searchContext) 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) protected StringbuilQueryWithEntityId(String query, String id) protected 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) protected StringgetImg()getIndex()protected StringgetMetadataQuery(List<ElasticSearchFilter> filters) protected Stringprotected StringgetPermissionFilterWiki(String permission) protected StringgetSitesFilter(Collection<String> sitesCollection) protected Stringprotected 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) booleanCollection<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) Collection<org.exoplatform.commons.api.search.data.SearchResult>searchByEntityId(org.exoplatform.commons.api.search.data.SearchContext context, String query, String entityId) Search on ES with entity id Search keyword in query with an OR And search only for the entity in parametervoidvoidvoidsetSearchFields(List<String> searchFields) voidsetTitleElasticFieldName(String titleElasticFieldName) Methods inherited from class org.exoplatform.commons.api.search.SearchServiceConnector
getDisplayName, getSearchType, isEnable, isEnabledForAnonymous, setDisplayName, setEnable, setEnabledForAnonymous, setSearchTypeMethods inherited from class org.exoplatform.container.component.BaseComponentPlugin
getDescription, getName, setDescription, setName
-
Field Details
-
HIGHLIGHT_FRAGMENT_SIZE_PARAM_NAME
- See Also:
-
HIGHLIGHT_FRAGMENT_SIZE_DEFAULT_VALUE
public static final int HIGHLIGHT_FRAGMENT_SIZE_DEFAULT_VALUE- See Also:
-
HIGHLIGHT_FRAGMENT_NUMBER_PARAM_NAME
- See Also:
-
HIGHLIGHT_FRAGMENT_NUMBER_DEFAULT_VALUE
public static final int HIGHLIGHT_FRAGMENT_NUMBER_DEFAULT_VALUE- See Also:
-
GROUP
- See Also:
-
WIKI_TYPE
- See Also:
-
-
Constructor Details
-
ElasticSearchServiceConnector
public ElasticSearchServiceConnector(org.exoplatform.container.xml.InitParams initParams, ElasticSearchingClient client)
-
-
Method Details
-
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
- 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
-
searchByEntityId
public Collection<org.exoplatform.commons.api.search.data.SearchResult> searchByEntityId(org.exoplatform.commons.api.search.data.SearchContext context, String query, String entityId) Search on ES with entity id Search keyword in query with an OR And search only for the entity in parameter- Parameters:
query-entityId-- Returns:
- a collection of SearchResult
-
buildQuery
-
builQueryWithEntityId
-
buildFilteredQuery
protected String buildFilteredQuery(String query, Collection<String> sites, List<ElasticSearchFilter> filters, int offset, int limit, String sort, String order) -
escapeReservedCharacters
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
-
getUrlFromJsonResult
protected String getUrlFromJsonResult(org.json.simple.JSONObject hitSource, org.exoplatform.commons.api.search.data.SearchContext context) -
getTitleFromJsonResult
-
getAdditionalFilters
-
getMetadataQuery
-
getFields
-
getPermissionFilter
-
getSitesFilter
-
getPermissionFilterWiki
-
getUserMemberships
-
getSourceFields
-
getIndex
-
setIndex
-
getImg
-
setImg
-
getTitleElasticFieldName
-
setTitleElasticFieldName
-
getSearchFields
-
setSearchFields
-
getClient
-