Class SearchServiceInternalImpl

    • Field Detail

      • EXACT_MATCH_PATTERN

        public static final Pattern EXACT_MATCH_PATTERN
      • PATH_MATCH_PATTERN

        public static final Pattern PATH_MATCH_PATTERN
      • MAX_RESULT_WINDOW

        public static final int MAX_RESULT_WINDOW
        Corresponds to 'index.max_result_window' default value
        See Also:
        Constant Field Values
      • pathFieldName

        protected String pathFieldName
        Name of the field for paths
      • internalNameFieldName

        protected String internalNameFieldName
        Name of the field for internal name
      • lastEditFieldName

        protected String lastEditFieldName
        Name of the field for last edit date
      • lastEditorFieldName

        protected String lastEditorFieldName
        Name of the field for last edit user
      • sizeFieldName

        protected String sizeFieldName
        Name of the field for size
      • mimeTypeName

        protected String mimeTypeName
        Name of the field for mimeType
      • searchFields

        protected Map<String,​String> searchFields
        List of fields to include during searching
      • highlightFields

        protected String[] highlightFields
        List of fields to include during highlighting
      • snippetSize

        protected int snippetSize
        Number of characters to include for snippets
      • numberOfSnippets

        protected int numberOfSnippets
        Number of snippets to generate for each file
      • defaultType

        protected String defaultType
        Default label used for unknown file types
      • studioConfiguration

        protected StudioConfiguration studioConfiguration
        The Studio configuration
      • servicesConfig

        protected ServicesConfig servicesConfig
        The site configuration
      • types

        protected Map<String,​org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode>> types
        Configurations for types
    • Constructor Detail

      • SearchServiceInternalImpl

        public SearchServiceInternalImpl()
    • Method Detail

      • setPathFieldName

        public void setPathFieldName​(String pathFieldName)
      • setInternalNameFieldName

        public void setInternalNameFieldName​(String internalNameFieldName)
      • setLastEditFieldName

        public void setLastEditFieldName​(String lastEditFieldName)
      • setLastEditorFieldName

        public void setLastEditorFieldName​(String lastEditorFieldName)
      • setSizeFieldName

        public void setSizeFieldName​(String sizeFieldName)
      • setMimeTypeName

        public void setMimeTypeName​(String mimeTypeName)
      • setDefaultType

        public void setDefaultType​(String defaultType)
      • setHighlightFields

        public void setHighlightFields​(String[] highlightFields)
      • setSnippetSize

        public void setSnippetSize​(int snippetSize)
      • setNumberOfSnippets

        public void setNumberOfSnippets​(int numberOfSnippets)
      • setStudioConfiguration

        public void setStudioConfiguration​(StudioConfiguration studioConfiguration)
      • setServicesConfig

        public void setServicesConfig​(ServicesConfig servicesConfig)
      • init

        public void init()
        Loads facets and type mapping from the global configuration
      • addBoosting

        protected String addBoosting​(String field,
                                     float boosting)
      • loadFieldsFromGlobalConfiguration

        protected void loadFieldsFromGlobalConfiguration()
      • loadFacetsFromGlobalConfiguration

        protected void loadFacetsFromGlobalConfiguration()
        Loads the facets from the global configuration
      • loadTypesFromGlobalConfiguration

        protected void loadTypesFromGlobalConfiguration()
        Loads the type mapping from the global configuration
      • processSearchHit

        protected SearchResultItem processSearchHit​(Map<String,​Object> source,
                                                    Map<String,​List<String>> highlights,
                                                    List<String> additionalFields)
        Maps the information from Elasticsearch for a single SearchResultItem
        Parameters:
        source - the fields returned by Elasticsearch
        highlights - the highlights returned by Elasticsearch
        Returns:
        the search item object
      • updateFilters

        protected void updateFilters​(co.elastic.clients.elasticsearch._types.query_dsl.BoolQuery.Builder query,
                                     SearchParams params,
                                     Map<String,​FacetTO> siteFacets)
        Adds the required filters based on the given parameters
        Parameters:
        query - the query to update
        params - the parameters to add
        siteFacets - the facets configured for the site
      • updateHighlighting

        protected void updateHighlighting​(co.elastic.clients.elasticsearch.core.SearchRequest.Builder builder)
        Adds the configured highlighting to the given builder
        Parameters:
        builder - the search builder to update
      • processResults

        protected SearchResult processResults​(co.elastic.clients.elasticsearch.core.SearchResponse<Map> response,
                                              Map<String,​FacetTO> siteFacets,
                                              List<String> additionalFields)
        Maps the Elasticsearch SearchResponse to a SearchResult object
        Parameters:
        response - the response to map
        Returns:
        the search result object
      • buildAggregations

        protected void buildAggregations​(co.elastic.clients.elasticsearch.core.SearchRequest.Builder builder,
                                         Map<String,​FacetTO> siteFacets)
        Adds the aggregations needed to the given builder
        Parameters:
        builder - the search source builder
        siteFacets - the facets from the site configuration
      • getSortFieldName

        protected String getSortFieldName​(String name)
        Maps the field name from the configured facets, if it's not found returns the same value.
        Parameters:
        name - the facet name
        Returns:
        name of the field to sort
      • getItemType

        protected String getItemType​(Map<String,​Object> source)
        Maps the item type for the given source based on the configuration
        Parameters:
        source - the source to map
        Returns:
        the item type
      • getItemSnippets

        protected List<String> getItemSnippets​(Map<String,​List<String>> highlights)
        Maps the Elasticsearch highlighting to simple text snippets
        Parameters:
        highlights - the highlighting to map
        Returns:
        the list of snippets
      • getMimeType

        protected String getMimeType​(Map<String,​Object> source)
        Finds the mime type for the given item
        Parameters:
        source - the item to map
        Returns:
        the mime type