Class DelegatingSearchIndexAccessor
- java.lang.Object
-
- com.atlassian.confluence.search.v2.DelegatingSearchIndexAccessor
-
- All Implemented Interfaces:
SearchIndexAccessor
- Direct Known Subclasses:
EdgeSearchIndexAccessor
public abstract class DelegatingSearchIndexAccessor extends Object implements SearchIndexAccessor
An abstract delegatingSearchIndexAccessorthat can be extended by a custom accessor.- Since:
- 7.17
-
-
Constructor Summary
Constructors Constructor Description DelegatingSearchIndexAccessor(CustomSearchIndexRegistry customSearchIndexRegistry, String indexName, String relativeIndexPath, ScoringStrategy scoringStrategy, AnalyzerDescriptorProvider analyzerDescriptorProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute(SearchIndexAction action)Executes a SearchIndexAction on the underlying search index.intnumDocs()Get the total number of index documents for the underlying search indexvoidoptimize()Manually optimize the index for search by merging segments.voidreset(Runnable replaceIndex)Execute a method after the index has been closed and before the index has been reopenedlongscan(SearchQuery searchQuery, Set<String> requestedFields, Consumer<ScannedDocument> consumer, float defaultScore)Scans the index for documents that match the provided searchQuery.longscan(SearchQuery searchQuery, Set<String> requestedFields, Consumer<Map<String,String[]>> consumer)Scans the index for documents that match the provided searchQuery.SearchResultssearch(ISearch search, Set<String> requestedFields)Perform a search with a given criteria, the returns searchResults only have the fields requested in the projection filled out, no other fields are valid in the searchResult.voidsnapshot(File destinationDirectory)Take a snapshot of the current index and store it into the destination directoryvoidwithBatchUpdate(BatchUpdateAction batchUpdateAction)Execute the update action in a batch
-
-
-
Constructor Detail
-
DelegatingSearchIndexAccessor
public DelegatingSearchIndexAccessor(CustomSearchIndexRegistry customSearchIndexRegistry, String indexName, String relativeIndexPath, ScoringStrategy scoringStrategy, AnalyzerDescriptorProvider analyzerDescriptorProvider)
-
-
Method Detail
-
search
public SearchResults search(ISearch search, Set<String> requestedFields) throws InvalidSearchException
Description copied from interface:SearchIndexAccessorPerform a search with a given criteria, the returns searchResults only have the fields requested in the projection filled out, no other fields are valid in the searchResult. SearchResults will throw anFieldNotRequestedExceptionif an attempt is made to access a field value that has not had it's key included in the projection Set.Will throw an InvalidSearchException if some error occurred converting the search object into a search that could be performed in the back-end. Usually this is a sign that some plugin that was used to create the search is no longer available.
- Specified by:
searchin interfaceSearchIndexAccessor- Parameters:
search- the search to performrequestedFields- requested fields. Passingnullwill request all fields, and passing empty set will request none.- Returns:
- a
SearchResultsinstance - Throws:
InvalidSearchException
-
scan
public long scan(SearchQuery searchQuery, Set<String> requestedFields, Consumer<Map<String,String[]>> consumer)
Description copied from interface:SearchIndexAccessorScans 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.
- Specified by:
scanin interfaceSearchIndexAccessor- 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[] When providing an empty set, the consumer will only get empty maps to consume.consumer- Consumer that handles each found document.- Returns:
- the number of documents that matched the searchQuery.
-
scan
public long scan(SearchQuery searchQuery, Set<String> requestedFields, Consumer<ScannedDocument> consumer, float defaultScore)
Description copied from interface:SearchIndexAccessorScans 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 intoScannedDocument, 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.
- Specified by:
scanin interfaceSearchIndexAccessor- 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[] When providing an empty set, the consumer will only get empty maps to consume.consumer- Consumer that handles each found document.defaultScore- a default score to be included in theScannedDocumentif it is not possible to retrieve the score for the document.- Returns:
- the number of documents that matched the searchQuery.
-
execute
public void execute(SearchIndexAction action)
Description copied from interface:SearchIndexAccessorExecutes a SearchIndexAction on the underlying search index.- Specified by:
executein interfaceSearchIndexAccessor- Parameters:
action- SearchIndexAction
-
numDocs
public int numDocs()
Description copied from interface:SearchIndexAccessorGet the total number of index documents for the underlying search index- Specified by:
numDocsin interfaceSearchIndexAccessor- Returns:
- the total number of index documents
-
withBatchUpdate
public void withBatchUpdate(BatchUpdateAction batchUpdateAction)
Description copied from interface:SearchIndexAccessorExecute the update action in a batch- Specified by:
withBatchUpdatein interfaceSearchIndexAccessor- Parameters:
batchUpdateAction- the batch update action
-
snapshot
public void snapshot(File destinationDirectory) throws SearchIndexAccessException
Description copied from interface:SearchIndexAccessorTake a snapshot of the current index and store it into the destination directory- Specified by:
snapshotin interfaceSearchIndexAccessor- Parameters:
destinationDirectory- the destination directory- Throws:
SearchIndexAccessException- if the snapshot could not be taken
-
reset
public void reset(Runnable replaceIndex)
Description copied from interface:SearchIndexAccessorExecute a method after the index has been closed and before the index has been reopened- Specified by:
resetin interfaceSearchIndexAccessor- Parameters:
replaceIndex- the method that needs to be executed
-
optimize
public void optimize()
Description copied from interface:SearchIndexAccessorManually optimize the index for search by merging segments. Is generally horribly inefficient and rarely justified. Added for the usage-tracking-plugin index as it was using optimize before the Lucene Upgrade to prevent file handles from running out with a quickly ever-growing index which never has deletions. Please carefully consider whether to use this at all, it has the potential, especially on large instances to lock index usage for a long period of time. Per-segment search performance improvements and default merge policies should make this no longer needed. If you need it, the index was probably poorly designed.- Specified by:
optimizein interfaceSearchIndexAccessor
-
-