Class SolrPageIndexer

    • Method Detail

      • indexPage

        public void indexPage​(String pageId,
                              boolean indexRecursively,
                              boolean indexAttachments)
                       throws Exception
        Index a page and eventually its children, recursively, in all workspaces and commit
        By default, children pages will be actually indexed if indexRecursively is true and if those pages are not already indexed.
        Parameters:
        pageId - the page to be indexed.
        indexRecursively - to also process children pages.
        indexAttachments - to index page attachments
        Throws:
        Exception - if an error occurs during indexation.
      • indexPage

        public void indexPage​(String pageId,
                              String workspaceName,
                              boolean indexRecursively,
                              boolean indexAttachments)
                       throws IndexingException
        Index a page and eventually its children, recursively.
        By default, children pages will be actually indexed if indexRecursively is true and if those pages are not already indexed.
        Parameters:
        pageId - the page to be indexed.
        workspaceName - the workspace where to index
        indexRecursively - to also process children pages.
        indexAttachments - to index page attachments
        Throws:
        IndexingException - if an error occurs during indexation.
      • indexPage

        public void indexPage​(String pageId,
                              String workspaceName,
                              boolean indexRecursively,
                              boolean indexAttachments,
                              org.apache.solr.client.solrj.SolrClient solrClient)
                       throws IndexingException
        Index a page and eventually its children, recursively.
        By default, children pages will be actually indexed if indexRecursively is true and if those pages are not already indexed.
        Parameters:
        pageId - the page to be indexed.
        workspaceName - the workspace where to index
        indexRecursively - to also process children pages.
        indexAttachments - to index page attachments
        solrClient - The solr client to use
        Throws:
        IndexingException - if an error occurs during indexation.
      • _populatePageDocument

        protected void _populatePageDocument​(Page page,
                                             org.apache.solr.common.SolrInputDocument document)
                                      throws Exception
        Populate the solr input document by adding fields to index.
        Parameters:
        page - the page to index.
        document - the solr input document
        Throws:
        Exception - if something goes wrong when processing the indexation of the page
      • _populateDatesOfPage

        protected void _populateDatesOfPage​(Page page,
                                            org.apache.solr.common.SolrInputDocument document)
        Populate the solr input document with dates from the page
        Parameters:
        page - The page
        document - The Solr document
      • _getTagsWithAncestors

        protected Set<String_getTagsWithAncestors​(Page page)
        Get all the page tags with their ancestors.
        Parameters:
        page - The page.
        Returns:
        All the page tags with their ancestors.
      • _populatePageContentsDocument

        protected void _populatePageContentsDocument​(Page page,
                                                     org.apache.solr.common.SolrInputDocument document)
                                              throws Exception
        Index the content of the page.

        Parameters:
        page - the page to index.
        document - the document to populate.
        Throws:
        Exception - if an error occurs.
      • _indexFacetableField

        protected void _indexFacetableField​(Content content,
                                            org.apache.solr.common.SolrInputDocument document)
        Index the facetable fields of a content into the page solr document
        Parameters:
        content - The content
        document - The main page solr document.
      • _findAndIndexFacetableField

        protected void _findAndIndexFacetableField​(String[] pathSegments,
                                                   String lang,
                                                   CompositeMetadata metadata,
                                                   MetadataDefinition definition,
                                                   IndexingField field,
                                                   org.apache.solr.common.SolrInputDocument pageDocument)
        Index the facetable fields of a content into the page solr document
        Parameters:
        pathSegments - The path of metadata
        lang - The language
        metadata - The parent composite metadata
        definition - The metadata definition
        field - The indexing field
        pageDocument - The Solr page document
      • _getLastModificationDate

        protected Date _getLastModificationDate​(Page page)
        Computes the last modification date of a page.
        Parameters:
        page - the page.
        Returns:
        the last modification date or null.
      • _getFirstValidationDate

        protected Date _getFirstValidationDate​(Page page)
        Computes the first validation date of a page.
        Parameters:
        page - the page.
        Returns:
        the first validation date or null.
      • _getLastValidationDate

        protected Date _getLastValidationDate​(Page page)
        Computes the last validation date of a page.
        Parameters:
        page - the page.
        Returns:
        the last validation date or null.
      • _getLastMajorValidationDate

        protected Date _getLastMajorValidationDate​(Page page)
        Computes the last major validation date of a page.
        Parameters:
        page - the page.
        Returns:
        the last major validation date or null.
      • _getLastDate

        protected Date _getLastDate​(Page page,
                                    Function<Content,​Date> dateRetriever)
        Computes a "last date" of a page, using the simple and naive following algorithm:
        From all the dates from each of its contents, keep the greatest of them.
        Parameters:
        page - the page.
        dateRetriever - The function to retrieve a Date from a Content of the Page
        Returns:
        the "last date" or null.
      • _getFirstDate

        protected Date _getFirstDate​(Page page,
                                     Function<Content,​Date> dateRetriever)
        Computes a "first date" of a page, using the simple and naive following algorithm:
        From all the dates from each of its contents, keep the lowest of them.
        Parameters:
        page - the page.
        dateRetriever - The function to retrieve a Date from a Content of the Page
        Returns:
        the "first date" or null.
      • _populateAdditionalProperties

        protected void _populateAdditionalProperties​(Page page,
                                                     org.apache.solr.common.SolrInputDocument document)
                                              throws Exception
        Populate the solr input document by adding fields to index.
        Parameters:
        page - the page to index.
        document - the solr input document
        Throws:
        Exception - if something goes wrong when processing the indexation of the page
      • indexPageAttachments

        public void indexPageAttachments​(ResourceCollection collection,
                                         Page page)
                                  throws Exception
        Index page attachments as new entries in the index.
        Parameters:
        collection - the collection of attachments
        page - the page whose attachments will be indexed
        Throws:
        Exception - if something goes wrong when indexing the attachments of the page
      • indexPageAttachment

        public void indexPageAttachment​(Resource resource,
                                        Page page)
                                 throws Exception
        Index a page attachment
        Parameters:
        resource - the page attachment as a Resource
        page - the page whose attachment is going to be indexed
        Throws:
        Exception - if something goes wrong when processing the indexation of the page attachment
      • _indexPageDocument

        protected void _indexPageDocument​(Page page,
                                          org.apache.solr.common.SolrInputDocument document,
                                          String workspaceName,
                                          org.apache.solr.client.solrj.SolrClient solrClient)
                                   throws org.apache.solr.client.solrj.SolrServerException,
                                          IOException
        Index a populated solr input document of type Page.
        Parameters:
        page - the page from which the input document is created
        document - the input document to add to the solr index
        workspaceName - The workspace name
        solrClient - The solr client to use
        Throws:
        org.apache.solr.client.solrj.SolrServerException - if there is an error on the Solr server
        IOException - if there is a communication error with the server
      • _indexResourceDocument

        protected void _indexResourceDocument​(Resource resource,
                                              org.apache.solr.common.SolrInputDocument document,
                                              org.apache.solr.client.solrj.SolrClient solrClient)
                                       throws org.apache.solr.client.solrj.SolrServerException,
                                              IOException
        Index a populated solr input document of type Resource.
        Parameters:
        resource - the resource from which the input document is created
        document - the input document
        solrClient - The solr client to use
        Throws:
        org.apache.solr.client.solrj.SolrServerException - if there is an error on the server
        IOException - if there is a communication error with the server
      • unindexPage

        public void unindexPage​(String pageId,
                                boolean unindexRecursively,
                                boolean unindexAttachments)
                         throws Exception
        Un-index a page by its ID for all workspaces and commit
        Parameters:
        pageId - The page ID.
        unindexRecursively - also unindex child pages if requested.
        unindexAttachments - also unindex page attachments
        Throws:
        Exception - if an error occurs during index update.
      • unindexPage

        public void unindexPage​(String pageId,
                                String workspaceName,
                                boolean unindexRecursively,
                                boolean unindexAttachments)
                         throws Exception
        De-index a page (and optionally its children pages).
        Parameters:
        pageId - the page to be de-indexed.
        workspaceName - The workspace where to work in
        unindexRecursively - also unindex child pages if requested.
        unindexAttachments - also unindex page attachments
        Throws:
        Exception - if an error occurs during index update.
      • _unindexPageDocument

        protected void _unindexPageDocument​(String pageId,
                                            String workspaceName,
                                            boolean unindexRecursively,
                                            boolean unindexAttachments)
                                     throws org.apache.solr.client.solrj.SolrServerException,
                                            IOException,
                                            QuerySyntaxException
        Deindex a document of type Page. Also deindex attachments of a page
        Parameters:
        pageId - the id of the page to deindex
        workspaceName - The workspace name
        unindexRecursively - also unindex child pages if requested.
        unindexAttachments - also unindex page attachments
        Throws:
        org.apache.solr.client.solrj.SolrServerException - if there is an error on the server
        IOException - if there is a communication error with the server
        QuerySyntaxException - if the uri query can't be built because of a syntax error.
      • reindexPage

        public void reindexPage​(String pageId,
                                boolean reindexRecursively,
                                boolean reindexAttachments)
                         throws Exception
        Reindex a page by its ID for all workspaces and commit
        Parameters:
        pageId - The page ID.
        reindexRecursively - also reindex child pages if requested.
        reindexAttachments - also reindex page attachments
        Throws:
        Exception - if an error occurs during index update.
      • reindexPage

        public void reindexPage​(String pageId,
                                String workspaceName,
                                boolean reindexRecursively,
                                boolean reindexAttachments)
                         throws IndexingException
        Reindex a page by its ID.
        Parameters:
        pageId - The page ID.
        workspaceName - The workspace where to work in
        reindexRecursively - also reindex child pages if requested.
        reindexAttachments - also reindex page attachments
        Throws:
        IndexingException - if an error occurs during index update.