Class DelegatingSearchIndexAccessor

    • Method Detail

      • scan

        public long scan​(SearchQuery searchQuery,
                         Set<String> requestedFields,
                         Consumer<Map<String,​String[]>> consumer)
        Description copied from interface: SearchIndexAccessor
        Scans the index for documents that match the provided searchQuery. The requestedFields set is used to specify which values need to be returned. The consumer will collect all the results found by the scan.

        Note that it is possible for a document to match the query, but not have any of the requested fields. This will result in an empty String[] for those fields that don't exist on the document. If you don't want to return those documents, you should specify a consumer that filters these out.

        WARNING: there is no default permissions checking behaviour provided. You MUST provide a search which specifies permissions checking. See SiteSearchPermissionsQueryFactory to add one yourself. See PredefinedSearchBuilder to build a pre-defined search which contains permission checking.

        Specified by:
        scan in interface SearchIndexAccessor
        Parameters:
        searchQuery - SearchQuery to scan the index for.
        requestedFields - Set of field names that are requested from the index. Any fields provided here that is not on the document will return an empty String[] Passing null will request all fields, and passing empty set will request none.
        consumer - Consumer that handles each found document.
        Returns:
        the number of documents that matched the searchQuery.
        See Also:
        SiteSearchPermissionsQueryFactory, PredefinedSearchBuilder
      • scan

        public long scan​(SearchQuery searchQuery,
                         Set<String> requestedFields,
                         Consumer<ScannedDocument> consumer,
                         float defaultScore)
        Description copied from interface: SearchIndexAccessor
        Scans the index for documents that match the provided searchQuery. The requestedFields set is used to specify which values need to be returned. The consumer will collect all the results found by the scan and convert them into ScannedDocument, which contains a score (if scoreIncluded is true) and a field-value map of the requested fields.

        Note that it is possible for a document to match the query, but not have any of the requested fields as the other scan method.

        This will result in an empty String[] for those fields that don't exist on the document. If you don't want to return those documents, you should specify a consumer that filters these out.

        WARNING: there is no default permissions checking behaviour provided. You MUST provide a search which specifies permissions checking. See SiteSearchPermissionsQueryFactory to add one yourself. See PredefinedSearchBuilder to build a pre-defined search which contains permission checking.

        Specified by:
        scan in interface SearchIndexAccessor
        Parameters:
        searchQuery - SearchQuery to scan the index for.
        requestedFields - Set of field names that are requested from the index. Any fields provided here that is not on the document will return an empty String[] Passing null will request all fields, and passing empty set will request none.
        consumer - Consumer that handles each found document.
        defaultScore - a default score to be included in the ScannedDocument if it is not possible to retrieve the score for the document.
        Returns:
        the number of documents that matched the searchQuery.
        See Also:
        SiteSearchPermissionsQueryFactory, PredefinedSearchBuilder
      • withBatchUpdate

        public void withBatchUpdate​(BatchUpdateAction batchUpdateAction)
        Description copied from interface: SearchIndexAccessor
        Execute the update action in a batch. Executions are transactional, reads can't see any writes made and the index will be locked for updating by other threads. Currently, there is no rollback when the transaction fails for any reason. This is a bug which will be investigated in future.
        Specified by:
        withBatchUpdate in interface SearchIndexAccessor
        Parameters:
        batchUpdateAction - the batch update action
      • reset

        public void reset​(Runnable replaceIndex)
        Description copied from interface: SearchIndexAccessor
        Execute a method after the index has been closed and before the index has been reopened
        Specified by:
        reset in interface SearchIndexAccessor
        Parameters:
        replaceIndex - the method that needs to be executed