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.
    See Also:
    IndexingContext, IndexUpdater, DefaultQueryCreator
    • Field Detail

      • ROLE

        static final java.lang.String ROLE
        Deprecated.
    • Method Detail

      • addIndexingContext

        void addIndexingContext​(IndexingContext context)
        Deprecated.
        Adds an indexing context to Nexus indexer.
        Since:
        5.1.0
      • addIndexingContext

        @Deprecated
        IndexingContext addIndexingContext​(java.lang.String id,
                                           java.lang.String repositoryId,
                                           java.io.File repository,
                                           java.io.File indexDirectory,
                                           java.lang.String repositoryUrl,
                                           java.lang.String indexUpdateUrl,
                                           java.util.List<? extends IndexCreator> indexers)
                                    throws java.io.IOException,
                                           UnsupportedExistingLuceneIndexException
        Deprecated.
        Use Indexer 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:
        java.io.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.
        java.lang.IllegalArgumentException - in case the supplied list of IndexCreators are not satisfiable
      • addIndexingContextForced

        @Deprecated
        IndexingContext addIndexingContextForced​(java.lang.String id,
                                                 java.lang.String repositoryId,
                                                 java.io.File repository,
                                                 java.io.File indexDirectory,
                                                 java.lang.String repositoryUrl,
                                                 java.lang.String indexUpdateUrl,
                                                 java.util.List<? extends IndexCreator> indexers)
                                          throws java.io.IOException
        Deprecated.
        Use Indexer 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:
        java.io.IOException - in case of some serious IO problem.
        java.lang.IllegalArgumentException - in case the supplied list of IndexCreators are not satisfiable
      • addIndexingContext

        @Deprecated
        IndexingContext addIndexingContext​(java.lang.String id,
                                           java.lang.String repositoryId,
                                           java.io.File repository,
                                           org.apache.lucene.store.Directory directory,
                                           java.lang.String repositoryUrl,
                                           java.lang.String indexUpdateUrl,
                                           java.util.List<? extends IndexCreator> indexers)
                                    throws java.io.IOException,
                                           UnsupportedExistingLuceneIndexException
        Deprecated.
        Use Indexer 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:
        java.io.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.
        java.lang.IllegalArgumentException - in case the supplied list of IndexCreators are not satisfiable
      • addIndexingContextForced

        @Deprecated
        IndexingContext addIndexingContextForced​(java.lang.String id,
                                                 java.lang.String repositoryId,
                                                 java.io.File repository,
                                                 org.apache.lucene.store.Directory directory,
                                                 java.lang.String repositoryUrl,
                                                 java.lang.String indexUpdateUrl,
                                                 java.util.List<? extends IndexCreator> indexers)
                                          throws java.io.IOException
        Deprecated.
        Use Indexer 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:
        java.io.IOException - in case of some serious IO problem.
        java.lang.IllegalArgumentException - in case the supplied list of IndexCreators are not satisfiable
      • addMergedIndexingContext

        @Deprecated
        IndexingContext addMergedIndexingContext​(java.lang.String id,
                                                 java.lang.String repositoryId,
                                                 java.io.File repository,
                                                 java.io.File indexDirectory,
                                                 boolean searchable,
                                                 java.util.Collection<IndexingContext> contexts)
                                          throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • addMergedIndexingContext

        @Deprecated
        IndexingContext addMergedIndexingContext​(java.lang.String id,
                                                 java.lang.String repositoryId,
                                                 java.io.File repository,
                                                 java.io.File indexDirectory,
                                                 boolean searchable,
                                                 ContextMemberProvider membersProvider)
                                          throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • addMergedIndexingContext

        @Deprecated
        IndexingContext addMergedIndexingContext​(java.lang.String id,
                                                 java.lang.String repositoryId,
                                                 java.io.File repository,
                                                 org.apache.lucene.store.Directory indexDirectory,
                                                 boolean searchable,
                                                 java.util.Collection<IndexingContext> contexts)
                                          throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • addMergedIndexingContext

        @Deprecated
        IndexingContext addMergedIndexingContext​(java.lang.String id,
                                                 java.lang.String repositoryId,
                                                 java.io.File repository,
                                                 org.apache.lucene.store.Directory indexDirectory,
                                                 boolean searchable,
                                                 ContextMemberProvider membersProvider)
                                          throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • removeIndexingContext

        @Deprecated
        void removeIndexingContext​(IndexingContext context,
                                   boolean deleteFiles)
                            throws java.io.IOException
        Deprecated.
        Use Indexer instead.
        Removes the indexing context from Nexus indexer, closes it and deletes (if specified) the index files.
        Parameters:
        context -
        deleteFiles -
        Throws:
        java.io.IOException
      • getIndexingContexts

        @Deprecated
        java.util.Map<java.lang.String,​IndexingContext> getIndexingContexts()
        Deprecated.
        Use Indexer instead.
        Returns the map of indexing contexts keyed by their ID.
      • scan

        @Deprecated
        void scan​(IndexingContext context)
           throws java.io.IOException
        Deprecated.
        Use Indexer instead.
        Performs full scan (reindex) for the local repository belonging to supplied context.
        Parameters:
        context -
        Throws:
        java.io.IOException
      • scan

        @Deprecated
        void scan​(IndexingContext context,
                  ArtifactScanningListener listener)
           throws java.io.IOException
        Deprecated.
        Use Indexer instead.
        Performs full scan (reindex) for the local repository belonging to supplied context. ArtifactListener is used during that process.
        Parameters:
        context -
        listener -
        Throws:
        java.io.IOException
      • scan

        @Deprecated
        void scan​(IndexingContext context,
                  boolean update)
           throws java.io.IOException
        Deprecated.
        Use Indexer 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:
        java.io.IOException
      • scan

        @Deprecated
        void scan​(IndexingContext context,
                  ArtifactScanningListener listener,
                  boolean update)
           throws java.io.IOException
        Deprecated.
        Use Indexer 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:
        java.io.IOException
      • scan

        @Deprecated
        void scan​(IndexingContext context,
                  java.lang.String fromPath,
                  ArtifactScanningListener listener,
                  boolean update)
           throws java.io.IOException
        Deprecated.
        Use Indexer 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:
        java.io.IOException
      • artifactDiscovered

        @Deprecated
        void artifactDiscovered​(ArtifactContext ac,
                                IndexingContext context)
                         throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • addArtifactToIndex

        @Deprecated
        void addArtifactToIndex​(ArtifactContext ac,
                                IndexingContext context)
                         throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • addArtifactsToIndex

        @Deprecated
        void addArtifactsToIndex​(java.util.Collection<ArtifactContext> acs,
                                 IndexingContext context)
                          throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • deleteArtifactFromIndex

        @Deprecated
        void deleteArtifactFromIndex​(ArtifactContext ac,
                                     IndexingContext context)
                              throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • deleteArtifactsFromIndex

        @Deprecated
        void deleteArtifactsFromIndex​(java.util.Collection<ArtifactContext> acs,
                                      IndexingContext context)
                               throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • searchFlat

        @Deprecated
        FlatSearchResponse searchFlat​(FlatSearchRequest request)
                               throws java.io.IOException
        Deprecated.
        Use Indexer instead.
        Searches according the request parameters.
        Parameters:
        request -
        Returns:
        Throws:
        java.io.IOException
      • searchIterator

        @Deprecated
        IteratorSearchResponse searchIterator​(IteratorSearchRequest request)
                                       throws java.io.IOException
        Deprecated.
        Use Indexer instead.
        Searches according to request parameters.
        Parameters:
        request -
        Returns:
        Throws:
        java.io.IOException
      • searchGrouped

        @Deprecated
        GroupedSearchResponse searchGrouped​(GroupedSearchRequest request)
                                     throws java.io.IOException
        Deprecated.
        Use Indexer instead.
        Searches according the request parameters.
        Parameters:
        request -
        Returns:
        Throws:
        java.io.IOException
      • constructQuery

        @Deprecated
        org.apache.lucene.search.Query constructQuery​(Field field,
                                                      java.lang.String query,
                                                      SearchType type)
                                               throws java.lang.IllegalArgumentException
        Deprecated.
        Use Indexer 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:
        java.lang.IllegalArgumentException
      • constructQuery

        @Deprecated
        org.apache.lucene.search.Query constructQuery​(Field field,
                                                      SearchExpression expression)
                                               throws java.lang.IllegalArgumentException
        Deprecated.
        Use Indexer 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:
        java.lang.IllegalArgumentException
      • identify

        @Deprecated
        java.util.Collection<ArtifactInfo> identify​(Field field,
                                                    java.lang.String query)
                                             throws java.lang.IllegalArgumentException,
                                                    java.io.IOException
        Deprecated.
        Throws:
        java.lang.IllegalArgumentException
        java.io.IOException
      • identify

        @Deprecated
        java.util.Collection<ArtifactInfo> identify​(java.io.File artifact)
                                             throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • identify

        @Deprecated
        java.util.Collection<ArtifactInfo> identify​(java.io.File artifact,
                                                    java.util.Collection<IndexingContext> contexts)
                                             throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • identify

        @Deprecated
        java.util.Collection<ArtifactInfo> identify​(org.apache.lucene.search.Query query)
                                             throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • identify

        @Deprecated
        java.util.Collection<ArtifactInfo> identify​(org.apache.lucene.search.Query query,
                                                    java.util.Collection<IndexingContext> contexts)
                                             throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException