Class DefaultSolrDocumentBuilder

  • All Implemented Interfaces:
    com.broadleafcommerce.search.index.core.document.DocumentBuilder<org.apache.solr.common.SolrInputDocument>

    public class DefaultSolrDocumentBuilder
    extends com.broadleafcommerce.search.index.core.document.AbstractDocumentBuilder<org.apache.solr.common.SolrInputDocument>
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultSolrDocumentBuilder​(com.broadleafcommerce.search.index.core.service.IndexerSearchService<com.broadleafcommerce.search.api.domain.FieldDefinition> searchFieldService, List<com.broadleafcommerce.search.index.core.document.DocumentBuilderContributor<org.apache.solr.common.SolrInputDocument>> contributors, List<com.broadleafcommerce.search.index.core.document.DocumentBuilderPreProcessor> preProcessors, com.broadleafcommerce.search.provider.solr.SolrFieldService solrFieldService, com.broadleafcommerce.search.index.core.document.helper.DocumentBuilderHelper documentBuilderHelper)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected String buildId​(com.broadleafcommerce.search.api.domain.Indexable<?> indexable)
      Build an ID value which routes documents based on context ID and is a unique representation of its context.
      protected org.apache.solr.common.SolrInputDocument createDocument​(com.broadleafcommerce.search.api.domain.Indexable<?> indexable)
      Creates an empty SolrInputDocument, except for the IndexableType and ID fields, which are required and which will be populated.
      protected String getCatalogId​(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState)
      Retrieve the catalog ID from this ContextState.
      protected com.broadleafcommerce.search.index.core.document.helper.DocumentBuilderHelper getDocumentBuilderHelper()  
      protected com.broadleafcommerce.search.provider.solr.SolrFieldService getSolrFieldService()  
      protected String idMapEntryToString​(Map.Entry<String,​Object> entry)
      Convert an ID map entry into a String format for concatenation into a compound ID.
      protected boolean isEmptyOrNull​(Object value)  
      protected void populateDocument​(com.broadleafcommerce.search.api.domain.Indexable<?> indexable, org.apache.solr.common.SolrInputDocument solrInputDocument, List<com.broadleafcommerce.search.api.domain.FieldDefinition> fields, com.jayway.jsonpath.DocumentContext context)  
      • Methods inherited from class com.broadleafcommerce.search.index.core.document.AbstractDocumentBuilder

        buildDocuments, executeContributors, executePreProcessors, getContributorsForIndexableType, getDefaultContributors, getDefaultJsonPathConfiguration, getIndexableTypeContributors, getJsonPathConfiguration, getPreProcessors, getSearchFieldService, shouldIndex
      • Methods inherited from interface com.broadleafcommerce.search.index.core.document.DocumentBuilder

        buildDocuments
    • Constructor Detail

      • DefaultSolrDocumentBuilder

        public DefaultSolrDocumentBuilder​(com.broadleafcommerce.search.index.core.service.IndexerSearchService<com.broadleafcommerce.search.api.domain.FieldDefinition> searchFieldService,
                                          List<com.broadleafcommerce.search.index.core.document.DocumentBuilderContributor<org.apache.solr.common.SolrInputDocument>> contributors,
                                          List<com.broadleafcommerce.search.index.core.document.DocumentBuilderPreProcessor> preProcessors,
                                          com.broadleafcommerce.search.provider.solr.SolrFieldService solrFieldService,
                                          com.broadleafcommerce.search.index.core.document.helper.DocumentBuilderHelper documentBuilderHelper)
    • Method Detail

      • createDocument

        protected org.apache.solr.common.SolrInputDocument createDocument​(com.broadleafcommerce.search.api.domain.Indexable<?> indexable)
        Creates an empty SolrInputDocument, except for the IndexableType and ID fields, which are required and which will be populated. The default behavior is to use the context ID as part of the ID field. The other part of the ID field will be a unique representation of its context.
        Specified by:
        createDocument in class com.broadleafcommerce.search.index.core.document.AbstractDocumentBuilder<org.apache.solr.common.SolrInputDocument>
        Parameters:
        indexable - The indexable to create a document for
        Returns:
        SolrInputDocument with id, indexable type, and contextId
      • buildId

        protected String buildId​(com.broadleafcommerce.search.api.domain.Indexable<?> indexable)
        Build an ID value which routes documents based on context ID and is a unique representation of its context.

        Indexables with the same context ID, catalog, sandbox, and sandbox owner context should produce the same ID.

        Specified by:
        buildId in class com.broadleafcommerce.search.index.core.document.AbstractDocumentBuilder<org.apache.solr.common.SolrInputDocument>
        Parameters:
        indexable - The indexable to create an ID for
        Returns:
        an ID unique by indexable context id, catalog, sandbox, and sandbox owner
      • getCatalogId

        protected String getCatalogId​(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState)
        Retrieve the catalog ID from this ContextState. Takes into account catalog overrides.
        Parameters:
        contextState - The context state of a CatalogTrackable indexable
        Returns:
        The catalog ID for this catalog trackable.
      • idMapEntryToString

        protected String idMapEntryToString​(Map.Entry<String,​Object> entry)
        Convert an ID map entry into a String format for concatenation into a compound ID.
        Parameters:
        entry - entry in ID map
        Returns:
        entry in format "key=value" to be added to a compound ID
      • populateDocument

        protected void populateDocument​(com.broadleafcommerce.search.api.domain.Indexable<?> indexable,
                                        org.apache.solr.common.SolrInputDocument solrInputDocument,
                                        List<com.broadleafcommerce.search.api.domain.FieldDefinition> fields,
                                        com.jayway.jsonpath.DocumentContext context)
        Specified by:
        populateDocument in class com.broadleafcommerce.search.index.core.document.AbstractDocumentBuilder<org.apache.solr.common.SolrInputDocument>
      • isEmptyOrNull

        protected boolean isEmptyOrNull​(@Nullable
                                        Object value)
      • getSolrFieldService

        protected com.broadleafcommerce.search.provider.solr.SolrFieldService getSolrFieldService()
      • getDocumentBuilderHelper

        protected com.broadleafcommerce.search.index.core.document.helper.DocumentBuilderHelper getDocumentBuilderHelper()