Interface NexusIndexer

All Known Implementing Classes:
DefaultNexusIndexer

@Deprecated public interface NexusIndexer
Deprecated.
Use Indexer instead.
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: