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 TypeMethodDescriptionvoidaddArtifactsToIndex(Collection<ArtifactContext> acs, IndexingContext context) Deprecated.voidaddArtifactToIndex(ArtifactContext ac, IndexingContext context) Deprecated.addIndexingContext(String id, String repositoryId, File repository, File indexDirectory, String repositoryUrl, String indexUpdateUrl, List<? extends IndexCreator> indexers) Deprecated.UseIndexerinstead.addIndexingContext(String id, String repositoryId, File repository, org.apache.lucene.store.Directory directory, String repositoryUrl, String indexUpdateUrl, List<? extends IndexCreator> indexers) Deprecated.UseIndexerinstead.voidaddIndexingContext(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.UseIndexerinstead.addIndexingContextForced(String id, String repositoryId, File repository, org.apache.lucene.store.Directory directory, String repositoryUrl, String indexUpdateUrl, List<? extends IndexCreator> indexers) Deprecated.UseIndexerinstead.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.voidartifactDiscovered(ArtifactContext ac, IndexingContext context) Deprecated.org.apache.lucene.search.QueryconstructQuery(Field field, String query, SearchType type) Deprecated.UseIndexerinstead.org.apache.lucene.search.QueryconstructQuery(Field field, SearchExpression expression) Deprecated.UseIndexerinstead.voiddeleteArtifactFromIndex(ArtifactContext ac, IndexingContext context) Deprecated.voiddeleteArtifactsFromIndex(Collection<ArtifactContext> acs, IndexingContext context) Deprecated.Deprecated.UseIndexerinstead.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.voidremoveIndexingContext(IndexingContext context, boolean deleteFiles) Deprecated.UseIndexerinstead.voidscan(IndexingContext context) Deprecated.UseIndexerinstead.voidscan(IndexingContext context, boolean update) Deprecated.UseIndexerinstead.voidscan(IndexingContext context, String fromPath, ArtifactScanningListener listener, boolean update) Deprecated.UseIndexerinstead.voidscan(IndexingContext context, ArtifactScanningListener listener) Deprecated.UseIndexerinstead.voidscan(IndexingContext context, ArtifactScanningListener listener, boolean update) Deprecated.UseIndexerinstead.searchFlat(FlatSearchRequest request) Deprecated.UseIndexerinstead.searchGrouped(GroupedSearchRequest request) Deprecated.UseIndexerinstead.searchIterator(IteratorSearchRequest request) Deprecated.UseIndexerinstead.
-
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.UseIndexerinstead.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.UseIndexerinstead.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.UseIndexerinstead.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.UseIndexerinstead.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.UseIndexerinstead.Removes the indexing context from Nexus indexer, closes it and deletes (if specified) the index files.- Parameters:
context-deleteFiles-- Throws:
IOException
-
getIndexingContexts
Deprecated.UseIndexerinstead.Returns the map of indexing contexts keyed by their ID. -
scan
Deprecated.UseIndexerinstead.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.UseIndexerinstead.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.UseIndexerinstead.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.UseIndexerinstead.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.UseIndexerinstead.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.UseIndexerinstead.Searches according the request parameters.- Parameters:
request-- Returns:
- Throws:
IOException
-
searchIterator
Deprecated.UseIndexerinstead.Searches according to request parameters.- Parameters:
request-- Returns:
- Throws:
IOException
-
searchGrouped
Deprecated.UseIndexerinstead.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.UseIndexerinstead.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.UseIndexerinstead.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:
IllegalArgumentExceptionIOException
-
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
-
Indexerinstead.