Interface Indexer

All Known Implementing Classes:
DefaultIndexer

public interface Indexer
Indexer component. It is the main component of Maven Indexer, offering IndexingContext creation and close methods, context maintenance (scan, add, remove) and search methods. Supersedes the NexusIndexer component, making it less cludged, and focusing on main use cases. This component does not hold any reference to contexts it creates or uses, and caller of every method (except the createIndexingContext naturally) is obliged to explicitly supply IndexingContext to work with (perform searches or such).
Since:
5.1.0
Author:
cstamas
  • Method Details

    • createIndexingContext

      IndexingContext createIndexingContext(String id, String repositoryId, File repository, File indexDirectory, String repositoryUrl, String indexUpdateUrl, boolean searchable, boolean reclaim, List<? extends IndexCreator> indexers) throws IOException, ExistingLuceneIndexMismatchException, IllegalArgumentException
      Creates an indexing context.
      Parameters:
      id - the ID of the context.
      repositoryId - the ID of the repository that this context represents. You might have several contexts indexing same repository ID, but on separate locations.
      repository - the location of the repository on FS.
      indexDirectory - the location of the Lucene indexes on FS.
      repositoryUrl - the location of the remote repository or null if this indexing context does not need remote updates (is not a proxy).
      indexUpdateUrl - the alternate location of the remote repository indexes (if they are not in default place) or null if defaults are applicable.
      searchable - if context should be searched in non-targeted mode.
      reclaim - if indexDirectory is known to contain (or should contain) valid Maven Indexer lucene index, and no checks needed to be performed, or, if we want to "stomp" over existing index (unsafe to do!).
      indexers - the set of indexers to apply to this context.
      Returns:
      the context created.
      Throws:
      IOException - in case of some serious IO problem.
      ExistingLuceneIndexMismatchException - 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. Never thrown if reclaim is true, as in that case, if Lucene index exists but any of those criteria above are not met, the existing index is overwritten, and equipped with proper descriptor silently.
      IllegalArgumentException - in case the supplied list of IndexCreators are having non-satisfiable dependencies.
    • createMergedIndexingContext

      IndexingContext createMergedIndexingContext(String id, String repositoryId, File repository, File indexDirectory, boolean searchable, ContextMemberProvider membersProvider) throws IOException
      Creates a merged indexing context.
      Parameters:
      id - the ID of the context.
      repositoryId - the ID of the repository that this context represents. You might have several contexts indexing same repository ID, but on separate locations.
      repository - the location of the repository on FS.
      indexDirectory - the location of the Lucene indexes on FS.
      searchable - if context should be searched in non-targeted mode.
      membersProvider - the ContextMemberProvider, never null.
      Returns:
      the context created.
      Throws:
      IOException - in case of some serious IO problem.
    • closeIndexingContext

      void closeIndexingContext(IndexingContext context, boolean deleteFiles) throws IOException
      Closes the indexing context: closes it and deletes (if specified) the index files.
      Parameters:
      context - the one needed to be closed, never null.
      deleteFiles - true if all indexer related files (including Lucene index!) needs to be deleted, false otherwise.
      Throws:
      IOException
    • addArtifactToIndex

      void addArtifactToIndex(ArtifactContext ac, IndexingContext context) throws IOException
      Adds the passed in artifact contexts to passed in indexing context.
      Parameters:
      ac -
      context -
      Throws:
      IOException
    • addArtifactsToIndex

      void addArtifactsToIndex(Collection<ArtifactContext> acs, IndexingContext context) throws IOException
      Adds the passed in artifact contexts to passed in indexing context.
      Parameters:
      acs -
      context -
      Throws:
      IOException
    • deleteArtifactsFromIndex

      void deleteArtifactsFromIndex(Collection<ArtifactContext> acs, IndexingContext context) throws IOException
      Removes the passed in artifacts contexts from passed in indexing context.
      Parameters:
      acs -
      context -
      Throws:
      IOException
    • searchFlat

      FlatSearchResponse searchFlat(FlatSearchRequest request) throws IOException
      Searches according the request parameters.
      Parameters:
      request -
      Returns:
      search response
      Throws:
      IOException
    • searchIterator

      Searches according to request parameters.
      Parameters:
      request -
      Returns:
      search response
      Throws:
      IOException
    • searchGrouped

      Searches according the request parameters.
      Parameters:
      request -
      Returns:
      search response
      Throws:
      IOException
    • identify

      Collection<ArtifactInfo> identify(File artifact, Collection<IndexingContext> contexts) throws IOException
      Performs an "identity" search. Passed in File will have SHA1 hash calculated, and an identify(Query, Collection) method will be invoked searching with calculated hash the MAVEN.SHA1 field. This is just a shorthand method, as these calls are simply calculating hex encoded SHA1 of the file, and invoking the constructQuery(Field, SearchExpression) and identify(Query, Collection) methods.
      Parameters:
      artifact - the file
      contexts - in which to perform the action
      Returns:
      collection of identified matches.
      Throws:
      IOException
    • identify

      Collection<ArtifactInfo> identify(org.apache.lucene.search.Query query, Collection<IndexingContext> contexts) throws IOException
      Performs an "identity" search. Those are usually simple key-value queries, involving "unique" fields like MAVEN.SHA1 or such.
      Parameters:
      query -
      contexts -
      Returns:
      collection of identified matches.
      Throws:
      IOException
    • constructQuery

      org.apache.lucene.search.Query constructQuery(Field field, SearchExpression expression) throws IllegalArgumentException
      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 search.
      Parameters:
      field -
      expression -
      Returns:
      the query to be used for search.
      Throws:
      IllegalArgumentException
      See Also:
    • constructQuery

      org.apache.lucene.search.Query constructQuery(Field field, String expression, SearchType searchType) throws IllegalArgumentException
      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 search.
      Parameters:
      field -
      expression -
      searchType -
      Returns:
      Throws:
      IllegalArgumentException