Search in sources :

Example 6 with FlatSearchRequest

use of org.apache.maven.index.FlatSearchRequest in project archiva by apache.

the class DownloadRemoteIndexTaskTest method downloadAndMergeRemoteIndexInEmptyIndex.

@Test
public void downloadAndMergeRemoteIndexInEmptyIndex() throws Exception {
    RemoteRepository remoteRepository = getRemoteRepository();
    remoteRepositoryAdmin.addRemoteRepository(remoteRepository, null);
    downloadRemoteIndexScheduler.startup();
    downloadRemoteIndexScheduler.scheduleDownloadRemote("test-repo-re", true, true);
    ((ThreadPoolTaskScheduler) downloadRemoteIndexScheduler.getTaskScheduler()).getScheduledExecutor().awaitTermination(10, TimeUnit.SECONDS);
    remoteRepositoryAdmin.deleteRemoteRepository("test-repo-re", null);
    // search
    BooleanQuery.Builder iQuery = new BooleanQuery.Builder();
    iQuery.add(indexer.constructQuery(MAVEN.GROUP_ID, new StringSearchExpression("commons-logging")), BooleanClause.Occur.SHOULD);
    remoteRepositoryAdmin.addRemoteRepository(remoteRepository, null);
    FlatSearchRequest rq = new FlatSearchRequest(iQuery.build());
    rq.setContexts(Arrays.asList(repositoryRegistry.getRemoteRepository(remoteRepository.getId()).getIndexingContext().getBaseContext(IndexingContext.class)));
    FlatSearchResponse response = indexer.searchFlat(rq);
    log.info("returned hit count:{}", response.getReturnedHitsCount());
    assertThat(response.getReturnedHitsCount()).isEqualTo(8);
}
Also used : BooleanQuery(org.apache.maven.index_shaded.lucene.search.BooleanQuery) FlatSearchResponse(org.apache.maven.index.FlatSearchResponse) RemoteRepository(org.apache.archiva.admin.model.beans.RemoteRepository) FlatSearchRequest(org.apache.maven.index.FlatSearchRequest) StringSearchExpression(org.apache.maven.index.expr.StringSearchExpression) Test(org.junit.Test)

Aggregations

FlatSearchRequest (org.apache.maven.index.FlatSearchRequest)6 FlatSearchResponse (org.apache.maven.index.FlatSearchResponse)6 BooleanQuery (org.apache.maven.index_shaded.lucene.search.BooleanQuery)5 Path (java.nio.file.Path)4 IOException (java.io.IOException)3 ArchivaIndexingContext (org.apache.archiva.indexer.ArchivaIndexingContext)3 IndexingContext (org.apache.maven.index.context.IndexingContext)3 SourcedSearchExpression (org.apache.maven.index.expr.SourcedSearchExpression)3 StringSearchExpression (org.apache.maven.index.expr.StringSearchExpression)3 Test (org.junit.Test)3 Inject (javax.inject.Inject)2 UnsupportedBaseContextException (org.apache.archiva.indexer.UnsupportedBaseContextException)2 ManagedRepository (org.apache.archiva.repository.ManagedRepository)2 IndexCreationFeature (org.apache.archiva.repository.features.IndexCreationFeature)2 ArtifactInfo (org.apache.maven.index.ArtifactInfo)2 Indexer (org.apache.maven.index.Indexer)2 MAVEN (org.apache.maven.index.MAVEN)2 BooleanClause (org.apache.maven.index_shaded.lucene.search.BooleanClause)2 Files (java.nio.file.Files)1 Paths (java.nio.file.Paths)1