Package org.apache.maven.index
Class DefaultIndexer
java.lang.Object
org.apache.maven.index.DefaultIndexer
- All Implemented Interfaces:
- Indexer
A default 
Indexer implementation.- Author:
- Tamas Cservenak
- 
Constructor SummaryConstructorsConstructorDescriptionDefaultIndexer(SearchEngine searcher, IndexerEngine indexerEngine, QueryCreator queryCreator) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddArtifactsToIndex(Collection<ArtifactContext> ac, IndexingContext context) Adds the passed in artifact contexts to passed in indexing context.voidaddArtifactToIndex(ArtifactContext ac, IndexingContext context) Adds the passed in artifact contexts to passed in indexing context.voidcloseIndexingContext(IndexingContext context, boolean deleteFiles) Closes the indexing context: closes it and deletes (if specified) the index files.org.apache.lucene.search.QueryconstructQuery(Field field, String expression, SearchType searchType) 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.org.apache.lucene.search.QueryconstructQuery(Field field, SearchExpression expression) 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.createIndexingContext(String id, String repositoryId, File repository, File indexDirectory, String repositoryUrl, String indexUpdateUrl, boolean searchable, boolean reclaim, List<? extends IndexCreator> indexers) Creates an indexing context.createMergedIndexingContext(String id, String repositoryId, File repository, File indexDirectory, boolean searchable, ContextMemberProvider membersProvider) Creates a merged indexing context.voiddeleteArtifactsFromIndex(Collection<ArtifactContext> ac, IndexingContext context) Removes the passed in artifacts contexts from passed in indexing context.identify(File artifact, Collection<IndexingContext> contexts) Performs an "identity" search.identify(org.apache.lucene.search.Query query, Collection<IndexingContext> contexts) Performs an "identity" search.searchFlat(FlatSearchRequest request) Searches according the request parameters.searchGrouped(GroupedSearchRequest request) Searches according the request parameters.searchIterator(IteratorSearchRequest request) Searches according to request parameters.
- 
Constructor Details- 
DefaultIndexer@Inject public DefaultIndexer(SearchEngine searcher, IndexerEngine indexerEngine, QueryCreator queryCreator) 
 
- 
- 
Method Details- 
createIndexingContextpublic 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 Description copied from interface:IndexerCreates an indexing context.- Specified by:
- createIndexingContextin interface- Indexer
- 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- nullif 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- nullif 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- reclaimis- 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.
 
- 
createMergedIndexingContextpublic IndexingContext createMergedIndexingContext(String id, String repositoryId, File repository, File indexDirectory, boolean searchable, ContextMemberProvider membersProvider) throws IOException Description copied from interface:IndexerCreates a merged indexing context.- Specified by:
- createMergedIndexingContextin interface- Indexer
- 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.
 
- 
closeIndexingContextDescription copied from interface:IndexerCloses the indexing context: closes it and deletes (if specified) the index files.- Specified by:
- closeIndexingContextin interface- Indexer
- Parameters:
- context- the one needed to be closed, never- null.
- deleteFiles-- trueif all indexer related files (including Lucene index!) needs to be deleted,- falseotherwise.
- Throws:
- IOException
 
- 
addArtifactToIndexDescription copied from interface:IndexerAdds the passed in artifact contexts to passed in indexing context.- Specified by:
- addArtifactToIndexin interface- Indexer
- Parameters:
- ac-
- context-
- Throws:
- IOException
 
- 
addArtifactsToIndexpublic void addArtifactsToIndex(Collection<ArtifactContext> ac, IndexingContext context) throws IOException Description copied from interface:IndexerAdds the passed in artifact contexts to passed in indexing context.- Specified by:
- addArtifactsToIndexin interface- Indexer
- Parameters:
- ac-
- context-
- Throws:
- IOException
 
- 
deleteArtifactsFromIndexpublic void deleteArtifactsFromIndex(Collection<ArtifactContext> ac, IndexingContext context) throws IOException Description copied from interface:IndexerRemoves the passed in artifacts contexts from passed in indexing context.- Specified by:
- deleteArtifactsFromIndexin interface- Indexer
- Parameters:
- ac-
- context-
- Throws:
- IOException
 
- 
searchFlatDescription copied from interface:IndexerSearches according the request parameters.- Specified by:
- searchFlatin interface- Indexer
- Parameters:
- request-
- Returns:
- search response
- Throws:
- IOException
 
- 
searchIteratorDescription copied from interface:IndexerSearches according to request parameters.- Specified by:
- searchIteratorin interface- Indexer
- Parameters:
- request-
- Returns:
- search response
- Throws:
- IOException
 
- 
searchGroupedDescription copied from interface:IndexerSearches according the request parameters.- Specified by:
- searchGroupedin interface- Indexer
- Parameters:
- request-
- Returns:
- search response
- Throws:
- IOException
 
- 
identifypublic Collection<ArtifactInfo> identify(File artifact, Collection<IndexingContext> contexts) throws IOException Description copied from interface:IndexerPerforms an "identity" search. Passed inFilewill have SHA1 hash calculated, and anIndexer.identify(Query, Collection)method will be invoked searching with calculated hash theMAVEN.SHA1field. This is just a shorthand method, as these calls are simply calculating hex encoded SHA1 of the file, and invoking theIndexer.constructQuery(Field, SearchExpression)andIndexer.identify(Query, Collection)methods.- Specified by:
- identifyin interface- Indexer
- Parameters:
- artifact- the file
- contexts- in which to perform the action
- Returns:
- collection of identified matches.
- Throws:
- IOException
 
- 
identifypublic Collection<ArtifactInfo> identify(org.apache.lucene.search.Query query, Collection<IndexingContext> contexts) throws IOException Description copied from interface:IndexerPerforms an "identity" search. Those are usually simple key-value queries, involving "unique" fields likeMAVEN.SHA1or such.- Specified by:
- identifyin interface- Indexer
- Parameters:
- query-
- contexts-
- Returns:
- collection of identified matches.
- Throws:
- IOException
 
- 
constructQuerypublic org.apache.lucene.search.Query constructQuery(Field field, SearchExpression expression) throws IllegalArgumentException Description copied from interface:IndexerHelper 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.- Specified by:
- constructQueryin interface- Indexer
- Parameters:
- field-
- expression-
- Returns:
- the query to be used for search.
- Throws:
- IllegalArgumentException
- See Also:
 
- 
constructQuerypublic org.apache.lucene.search.Query constructQuery(Field field, String expression, SearchType searchType) throws IllegalArgumentException Description copied from interface:IndexerHelper 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.- Specified by:
- constructQueryin interface- Indexer
- Parameters:
- field-
- expression-
- searchType-
- Returns:
- Throws:
- IllegalArgumentException
 
 
-