@Internal public class LuceneSearchIndexAccessor extends Object implements SearchIndexAccessor
| Constructor and Description |
|---|
LuceneSearchIndexAccessor(com.atlassian.bonnie.LuceneConnection luceneConnection,
LuceneFieldVisitor luceneFieldVisitor,
LuceneSearchMapper luceneSearchMapper) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
execute(SearchIndexAction action)
Executes a SearchIndexAction on the underlying search index.
|
int |
numDocs()
Get the total number of index documents for the underlying search index
|
void |
optimize()
Manually optimize the index for search by merging segments.
|
void |
reset(Runnable replaceIndex)
Execute a method after the index has been closed and before the index has been reopened
|
long |
scan(SearchQuery searchQuery,
Set<String> requestedFields,
Consumer<Map<String,String[]>> consumer)
Scans the index for documents that match the provided searchQuery.
|
long |
scan(SearchQuery searchQuery,
Set<String> requestedFields,
Consumer<ScannedDocument> consumer,
float defaultSCore)
Scans the index for documents that match the provided searchQuery.
|
SearchResults |
search(ISearch search,
Set<String> requestedFields)
Perform a
search, the returned SearchResults only have the fields requested in the
projection filled out, no other fields are valid in the searchResult. |
void |
snapshot(File destinationDirectory)
Take a snapshot of the current index and store it into the destination directory
|
void |
withBatchUpdate(BatchUpdateAction batchUpdateAction)
Execute the update action in a batch.
|
public LuceneSearchIndexAccessor(com.atlassian.bonnie.LuceneConnection luceneConnection,
LuceneFieldVisitor luceneFieldVisitor,
LuceneSearchMapper luceneSearchMapper)
public SearchResults search(ISearch search, Set<String> requestedFields) throws InvalidSearchException
SearchIndexAccessorsearch, the returned SearchResults only have the fields requested in the
projection filled out, no other fields are valid in the searchResult.
SearchResults will throw an
FieldNotRequestedException if an attempt is made to access a field value that has not
had it's key included in the projection Set.
NOTE: the search limit will be capped at SearchConstants.MAX_LIMIT and the startOffset will be capped at SearchConstants.MAX_START_OFFSET for more efficient heap usage.
See SearchResults.getNextPageSearch() for pagination.
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.
search in interface SearchIndexAccessorsearch - the search to perform.requestedFields - requested fields. Passing null will request all fields, and passing empty set will request none.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.ISearch,
SiteSearchPermissionsQueryFactory,
SearchConstants.MAX_LIMIT,
SearchConstants.MAX_START_OFFSET,
SearchResults.getNextPageSearch(),
PredefinedSearchBuilderpublic long scan(SearchQuery searchQuery, Set<String> requestedFields, Consumer<Map<String,String[]>> consumer)
SearchIndexAccessorNote 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.
scan in interface SearchIndexAccessorsearchQuery - 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.SiteSearchPermissionsQueryFactory,
PredefinedSearchBuilderpublic long scan(SearchQuery searchQuery, Set<String> requestedFields, Consumer<ScannedDocument> consumer, float defaultSCore)
SearchIndexAccessorScannedDocument, 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.
scan in interface SearchIndexAccessorsearchQuery - 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 the ScannedDocument if it is not possible
to retrieve the score for the document.SiteSearchPermissionsQueryFactory,
PredefinedSearchBuilderpublic void execute(SearchIndexAction action)
SearchIndexAccessorexecute in interface SearchIndexAccessoraction - SearchIndexActionpublic int numDocs()
SearchIndexAccessornumDocs in interface SearchIndexAccessorpublic void withBatchUpdate(BatchUpdateAction batchUpdateAction)
SearchIndexAccessorwithBatchUpdate in interface SearchIndexAccessorbatchUpdateAction - the batch update actionpublic void snapshot(File destinationDirectory) throws SearchIndexAccessException
SearchIndexAccessorsnapshot in interface SearchIndexAccessordestinationDirectory - the destination directorySearchIndexAccessException - if the snapshot could not be takenpublic void reset(Runnable replaceIndex)
SearchIndexAccessorreset in interface SearchIndexAccessorreplaceIndex - the method that needs to be executedpublic void optimize()
SearchIndexAccessoroptimize in interface SearchIndexAccessorpublic void close()
Copyright © 2003–2022 Atlassian. All rights reserved.