Package org.apache.maven.index
Interface NexusIndexer
- All Known Implementing Classes:
DefaultNexusIndexer
Deprecated.
The Nexus indexer is a statefull facade that maintains state of indexing contexts.
The following code snippet shows how to register indexing context, which should be done once on the application startup and Nexus indexer instance should be reused after that.
NexusIndexer indexer; IndexingContext context = indexer.addIndexingContext( indexId, // index id (usually the same as repository id) repositoryId, // repository id directory, // Lucene directory where index is stored repositoryDir, // local repository dir or null for remote repo repositoryUrl, // repository url, used by index updater indexUpdateUrl, // index update url or null if derived from repositoryUrl false, false );An indexing context could be populated using one of
scan(IndexingContext)
,
addArtifactToIndex(ArtifactContext, IndexingContext)
or
deleteArtifactFromIndex(ArtifactContext, IndexingContext)
methods.
An IndexUpdater
could be used to fetch indexes from remote repositories.
These indexers could be created using the Indexer CLI command line tool or
IndexPacker
API.
Once index is populated you can perform search queries using field names declared in the ArtifactInfo
:
// run search query BooleanQuery q = new BooleanQuery.Builder() .add(indexer.constructQuery(ArtifactInfo.GROUP_ID, term), Occur.SHOULD) .add(indexer.constructQuery(ArtifactInfo.ARTIFACT_ID, term), Occur.SHOULD) .add(new PrefixQuery(new Term(ArtifactInfo.SHA1, term)), Occur.SHOULD) .build(); FlatSearchRequest request = new FlatSearchRequest(q); FlatSearchResponse response = indexer.searchFlat(request); ...Query could be also constructed using a convenience
constructQuery(Field, SearchExpression)
method that handles creation of the wildcard queries. Also see DefaultQueryCreator
for more details on
supported queries.- Author:
- Jason van Zyl, Tamas Cservenak, Eugene Kuleshov
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addArtifactsToIndex
(Collection<ArtifactContext> acs, IndexingContext context) Deprecated.void
addArtifactToIndex
(ArtifactContext ac, IndexingContext context) Deprecated.addIndexingContext
(String id, String repositoryId, File repository, File indexDirectory, String repositoryUrl, String indexUpdateUrl, List<? extends IndexCreator> indexers) Deprecated.UseIndexer
instead.addIndexingContext
(String id, String repositoryId, File repository, org.apache.lucene.store.Directory directory, String repositoryUrl, String indexUpdateUrl, List<? extends IndexCreator> indexers) Deprecated.UseIndexer
instead.void
addIndexingContext
(IndexingContext context) Deprecated.Adds an indexing context to Nexus indexer.addIndexingContextForced
(String id, String repositoryId, File repository, File indexDirectory, String repositoryUrl, String indexUpdateUrl, List<? extends IndexCreator> indexers) Deprecated.UseIndexer
instead.addIndexingContextForced
(String id, String repositoryId, File repository, org.apache.lucene.store.Directory directory, String repositoryUrl, String indexUpdateUrl, List<? extends IndexCreator> indexers) Deprecated.UseIndexer
instead.addMergedIndexingContext
(String id, String repositoryId, File repository, File indexDirectory, boolean searchable, Collection<IndexingContext> contexts) Deprecated.addMergedIndexingContext
(String id, String repositoryId, File repository, File indexDirectory, boolean searchable, ContextMemberProvider membersProvider) Deprecated.addMergedIndexingContext
(String id, String repositoryId, File repository, org.apache.lucene.store.Directory indexDirectory, boolean searchable, Collection<IndexingContext> contexts) Deprecated.addMergedIndexingContext
(String id, String repositoryId, File repository, org.apache.lucene.store.Directory indexDirectory, boolean searchable, ContextMemberProvider membersProvider) Deprecated.void
artifactDiscovered
(ArtifactContext ac, IndexingContext context) Deprecated.org.apache.lucene.search.Query
constructQuery
(Field field, String query, SearchType type) Deprecated.UseIndexer
instead.org.apache.lucene.search.Query
constructQuery
(Field field, SearchExpression expression) Deprecated.UseIndexer
instead.void
deleteArtifactFromIndex
(ArtifactContext ac, IndexingContext context) Deprecated.void
deleteArtifactsFromIndex
(Collection<ArtifactContext> acs, IndexingContext context) Deprecated.Deprecated.UseIndexer
instead.Deprecated.identify
(File artifact, Collection<IndexingContext> contexts) Deprecated.identify
(org.apache.lucene.search.Query query) Deprecated.identify
(org.apache.lucene.search.Query query, Collection<IndexingContext> contexts) Deprecated.Deprecated.void
removeIndexingContext
(IndexingContext context, boolean deleteFiles) Deprecated.UseIndexer
instead.void
scan
(IndexingContext context) Deprecated.UseIndexer
instead.void
scan
(IndexingContext context, boolean update) Deprecated.UseIndexer
instead.void
scan
(IndexingContext context, String fromPath, ArtifactScanningListener listener, boolean update) Deprecated.UseIndexer
instead.void
scan
(IndexingContext context, ArtifactScanningListener listener) Deprecated.UseIndexer
instead.void
scan
(IndexingContext context, ArtifactScanningListener listener, boolean update) Deprecated.UseIndexer
instead.searchFlat
(FlatSearchRequest request) Deprecated.UseIndexer
instead.searchGrouped
(GroupedSearchRequest request) Deprecated.UseIndexer
instead.searchIterator
(IteratorSearchRequest request) Deprecated.UseIndexer
instead.
-
Method Details
-
addIndexingContext
Deprecated.Adds an indexing context to Nexus indexer.- Since:
- 5.1.0
-
addIndexingContext
@Deprecated IndexingContext addIndexingContext(String id, String repositoryId, File repository, File indexDirectory, String repositoryUrl, String indexUpdateUrl, List<? extends IndexCreator> indexers) throws IOException, UnsupportedExistingLuceneIndexException Deprecated.UseIndexer
instead.Adds an indexing context to Nexus indexer.- Parameters:
id
- the ID of the context.repositoryId
- the ID of the repository that this context represents.repository
- the location of the repository.indexDirectory
- the location of the Lucene indexes.repositoryUrl
- the location of the remote repository.indexUpdateUrl
- the alternate location of the remote repository indexes (if they are not in default place).indexers
- the set of indexers to apply to this context.- Returns:
- Throws:
IOException
- in case of some serious IO problem.UnsupportedExistingLuceneIndexException
- if a Lucene index already exists where location is specified, but it has no Nexus descriptor record or it has, but the embedded repoId differs from the repoId specified from the supplied one.IllegalArgumentException
- in case the supplied list of IndexCreators are not satisfiable
-
addIndexingContextForced
@Deprecated IndexingContext addIndexingContextForced(String id, String repositoryId, File repository, File indexDirectory, String repositoryUrl, String indexUpdateUrl, List<? extends IndexCreator> indexers) throws IOException Deprecated.UseIndexer
instead.Adds an indexing context to Nexus indexer. It "forces" this operation, thus no UnsupportedExistingLuceneIndexException is thrown. If it founds an existing lucene index, it will simply stomp-over and rewrite (or add) the Nexus index descriptor.- Parameters:
id
- the ID of the context.repositoryId
- the ID of the repository that this context represents.repository
- the location of the repository.indexDirectory
- the location of the Lucene indexes.repositoryUrl
- the location of the remote repository.indexUpdateUrl
- the alternate location of the remote repository indexes (if they are not in default place).indexers
- the set of indexers to apply to this context.- Returns:
- Throws:
IOException
- in case of some serious IO problem.IllegalArgumentException
- in case the supplied list of IndexCreators are not satisfiable
-
addIndexingContext
@Deprecated IndexingContext addIndexingContext(String id, String repositoryId, File repository, org.apache.lucene.store.Directory directory, String repositoryUrl, String indexUpdateUrl, List<? extends IndexCreator> indexers) throws IOException, UnsupportedExistingLuceneIndexException Deprecated.UseIndexer
instead.Adds an indexing context to Nexus indexer.- Parameters:
id
- the ID of the context.repositoryId
- the ID of the repository that this context represents.repository
- the location of the repository.directory
- the location of the Lucene indexes.repositoryUrl
- the location of the remote repository.indexUpdateUrl
- the alternate location of the remote repository indexes (if they are not in default place).indexers
- the set of indexers to apply to this context.- Returns:
- Throws:
IOException
- in case of some serious IO problem.UnsupportedExistingLuceneIndexException
- if a Lucene index already exists where location is specified, but it has no Nexus descriptor record or it has, but the embedded repoId differs from the repoId specified from the supplied one.IllegalArgumentException
- in case the supplied list of IndexCreators are not satisfiable
-
addIndexingContextForced
@Deprecated IndexingContext addIndexingContextForced(String id, String repositoryId, File repository, org.apache.lucene.store.Directory directory, String repositoryUrl, String indexUpdateUrl, List<? extends IndexCreator> indexers) throws IOException Deprecated.UseIndexer
instead.Adds an indexing context to Nexus indexer. It "forces" this operation, thus no UnsupportedExistingLuceneIndexException is thrown. If it founds an existing lucene index, it will simply stomp-over and rewrite (or add) the Nexus index descriptor.- Parameters:
id
- the ID of the context.repositoryId
- the ID of the repository that this context represents.repository
- the location of the repository.directory
- the location of the Lucene indexes.repositoryUrl
- the location of the remote repository.indexUpdateUrl
- the alternate location of the remote repository indexes (if they are not in default place).indexers
- the set of indexers to apply to this context.- Returns:
- Throws:
IOException
- in case of some serious IO problem.IllegalArgumentException
- in case the supplied list of IndexCreators are not satisfiable
-
addMergedIndexingContext
@Deprecated IndexingContext addMergedIndexingContext(String id, String repositoryId, File repository, File indexDirectory, boolean searchable, Collection<IndexingContext> contexts) throws IOException Deprecated.- Throws:
IOException
-
addMergedIndexingContext
@Deprecated IndexingContext addMergedIndexingContext(String id, String repositoryId, File repository, File indexDirectory, boolean searchable, ContextMemberProvider membersProvider) throws IOException Deprecated.- Throws:
IOException
-
addMergedIndexingContext
@Deprecated IndexingContext addMergedIndexingContext(String id, String repositoryId, File repository, org.apache.lucene.store.Directory indexDirectory, boolean searchable, Collection<IndexingContext> contexts) throws IOException Deprecated.- Throws:
IOException
-
addMergedIndexingContext
@Deprecated IndexingContext addMergedIndexingContext(String id, String repositoryId, File repository, org.apache.lucene.store.Directory indexDirectory, boolean searchable, ContextMemberProvider membersProvider) throws IOException Deprecated.- Throws:
IOException
-
removeIndexingContext
@Deprecated void removeIndexingContext(IndexingContext context, boolean deleteFiles) throws IOException Deprecated.UseIndexer
instead.Removes the indexing context from Nexus indexer, closes it and deletes (if specified) the index files.- Parameters:
context
-deleteFiles
-- Throws:
IOException
-
getIndexingContexts
Deprecated.UseIndexer
instead.Returns the map of indexing contexts keyed by their ID. -
scan
Deprecated.UseIndexer
instead.Performs full scan (reindex) for the local repository belonging to supplied context.- Parameters:
context
-- Throws:
IOException
-
scan
@Deprecated void scan(IndexingContext context, ArtifactScanningListener listener) throws IOException Deprecated.UseIndexer
instead.Performs full scan (reindex) for the local repository belonging to supplied context. ArtifactListener is used during that process.- Parameters:
context
-listener
-- Throws:
IOException
-
scan
Deprecated.UseIndexer
instead.Performs optionally incremental scan (reindex/full reindex) for the local repository belonging to the supplied context.- Parameters:
context
-update
- if incremental reindex wanted, set true, otherwise false and full reindex will happen- Throws:
IOException
-
scan
@Deprecated void scan(IndexingContext context, ArtifactScanningListener listener, boolean update) throws IOException Deprecated.UseIndexer
instead.Performs optionally incremental scan (reindex) for the local repository, with listener.- Parameters:
context
-listener
-update
- if incremental reindex wanted, set true, otherwise false and full reindex will happen- Throws:
IOException
-
scan
@Deprecated void scan(IndexingContext context, String fromPath, ArtifactScanningListener listener, boolean update) throws IOException Deprecated.UseIndexer
instead.Performs optionally incremental scan (reindex) for the local repository.- Parameters:
context
-fromPath
- a path segment if you want "sub-path" reindexing (ie. reindex just a given subfolder of a repository, ot whole repository from root.listener
-update
- if incremental reindex wanted, set true, otherwise false and full reindex will happen- Throws:
IOException
-
artifactDiscovered
Deprecated.- Throws:
IOException
-
addArtifactToIndex
Deprecated.- Throws:
IOException
-
addArtifactsToIndex
@Deprecated void addArtifactsToIndex(Collection<ArtifactContext> acs, IndexingContext context) throws IOException Deprecated.- Throws:
IOException
-
deleteArtifactFromIndex
@Deprecated void deleteArtifactFromIndex(ArtifactContext ac, IndexingContext context) throws IOException Deprecated.- Throws:
IOException
-
deleteArtifactsFromIndex
@Deprecated void deleteArtifactsFromIndex(Collection<ArtifactContext> acs, IndexingContext context) throws IOException Deprecated.- Throws:
IOException
-
searchFlat
Deprecated.UseIndexer
instead.Searches according the request parameters.- Parameters:
request
-- Returns:
- Throws:
IOException
-
searchIterator
Deprecated.UseIndexer
instead.Searches according to request parameters.- Parameters:
request
-- Returns:
- Throws:
IOException
-
searchGrouped
Deprecated.UseIndexer
instead.Searches according the request parameters.- Parameters:
request
-- Returns:
- Throws:
IOException
-
constructQuery
@Deprecated org.apache.lucene.search.Query constructQuery(Field field, String query, SearchType type) throws IllegalArgumentException Deprecated.UseIndexer
instead.Helper method to construct Lucene query for given field without need for knowledge (on caller side) HOW is a field indexed, and WHAT query is needed to achieve that.- Parameters:
field
-query
-type
-- Returns:
- Throws:
IllegalArgumentException
-
constructQuery
@Deprecated org.apache.lucene.search.Query constructQuery(Field field, SearchExpression expression) throws IllegalArgumentException Deprecated.UseIndexer
instead.Helper method to construct Lucene query for given field without need for knowledge (on caller side) HOW is a field indexed, and WHAT query is needed to achieve that.- Parameters:
field
-expression
-- Returns:
- Throws:
IllegalArgumentException
-
identify
@Deprecated Collection<ArtifactInfo> identify(Field field, String query) throws IllegalArgumentException, IOException Deprecated.- Throws:
IllegalArgumentException
IOException
-
identify
Deprecated.- Throws:
IOException
-
identify
@Deprecated Collection<ArtifactInfo> identify(File artifact, Collection<IndexingContext> contexts) throws IOException Deprecated.- Throws:
IOException
-
identify
@Deprecated Collection<ArtifactInfo> identify(org.apache.lucene.search.Query query) throws IOException Deprecated.- Throws:
IOException
-
identify
@Deprecated Collection<ArtifactInfo> identify(org.apache.lucene.search.Query query, Collection<IndexingContext> contexts) throws IOException Deprecated.- Throws:
IOException
-
Indexer
instead.