Package org.apache.maven.index

Examples of org.apache.maven.index.FlatSearchRequest


               Occur.SHOULD );
        //q.add(
        //    indexer.constructQuery( MAVEN.ARTIFACT_ID, new SourcedSearchExpression( "archiva-index-methods-jar-test" ) ),
        //    Occur.SHOULD );

        FlatSearchRequest flatSearchRequest =
            new FlatSearchRequest( q, indexer.getIndexingContexts().get( repositoryConfig.getId() ) );

        FlatSearchResponse response = indexer.searchFlat( flatSearchRequest );

        assertTrue( new File( repositoryConfig.getLocation(), ".indexer" ).exists() );
        assertFalse( new File( repositoryConfig.getLocation(), ".index" ).exists() );

        // should return 1 hit
        assertEquals( 1, response.getTotalHitsCount() );

        // remove added artifact from index
        task = new ArtifactIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.DELETE,
                                         getIndexingContext() );
        indexingExecutor.executeTask( task );

        task = new ArtifactIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.FINISH,
                                         getIndexingContext() );
        indexingExecutor.executeTask( task );

        q = new BooleanQuery();
        q.add( indexer.constructQuery( MAVEN.GROUP_ID, new SourcedSearchExpression( "org.apache.archiva" ) ),
               Occur.SHOULD );
        q.add( indexer.constructQuery( MAVEN.ARTIFACT_ID,
                                       new SourcedSearchExpression( "archiva-index-methods-jar-test" ) ),
               Occur.SHOULD );

        assertTrue( new File( repositoryConfig.getLocation(), ".indexer" ).exists() );
        assertFalse( new File( repositoryConfig.getLocation(), ".index" ).exists() );

        flatSearchRequest = new FlatSearchRequest( q, getIndexingContext() );

        response = indexer.searchFlat( flatSearchRequest );
        // artifact should have been removed from the index!
        assertEquals( 0, response.getTotalHitsCount() );//.totalHits );
View Full Code Here


               Occur.SHOULD );
        q.add(
            indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( "archiva-index-methods-jar-test" ) ),
            Occur.SHOULD );

        FlatSearchRequest request = new FlatSearchRequest( q, getIndexingContext() );
        FlatSearchResponse response = indexer.searchFlat( request );

        Set<ArtifactInfo> results = response.getResults();

        ArtifactInfo artifactInfo = results.iterator().next();
View Full Code Here

                            if ( ac.getArtifactInfo().packaging != null )
                            {
                                q.add( nexusIndexer.constructQuery( MAVEN.PACKAGING, new SourcedSearchExpression(
                                    ac.getArtifactInfo().packaging ) ), BooleanClause.Occur.MUST );
                            }
                            FlatSearchRequest flatSearchRequest = new FlatSearchRequest( q, context );
                            FlatSearchResponse flatSearchResponse = nexusIndexer.searchFlat( flatSearchRequest );
                            if ( flatSearchResponse.getResults().isEmpty() )
                            {
                                log.debug( "Adding artifact '{}' to index..", ac.getArtifactInfo() );
                                nexusIndexer.addArtifactToIndex( ac, context );
View Full Code Here

                            if ( ac.getArtifactInfo().packaging != null )
                            {
                                q.add( nexusIndexer.constructQuery( MAVEN.PACKAGING, new SourcedSearchExpression(
                                    ac.getArtifactInfo().packaging ) ), BooleanClause.Occur.MUST );
                            }
                            FlatSearchRequest flatSearchRequest = new FlatSearchRequest( q, context );
                            FlatSearchResponse flatSearchResponse = nexusIndexer.searchFlat( flatSearchRequest );
                            if ( flatSearchResponse.getResults().isEmpty() )
                            {
                                log.debug( "Adding artifact '{}' to index..", ac.getArtifactInfo() );
                                nexusIndexer.addArtifactToIndex( ac, context );
View Full Code Here

    bq.add(q1, BooleanClause.Occur.SHOULD);

    bq.add(q2, BooleanClause.Occur.SHOULD);

    FlatSearchRequest req = new FlatSearchRequest(bq, ArtifactInfo.REPOSITORY_VERSION_COMPARATOR);

    // if ( from != null )
    // {
    // req.setStart( from );
    // }

    // MINDEXER-14: no hit limit anymore. But to make change least obtrusive, we set hitLimit as count 1st, and if
    // user set count, it will override it anyway
    if (hitLimit != null) {
      req.setCount(hitLimit);
    }

    if (count != null) {
      req.setCount(count);
    }

    // if ( hitLimit != null )
    // {
    // req._setResultHitLimit( hitLimit );
View Full Code Here

      term = term.substring(0, term.length() - 6);
    }

    Query q = mavenIndexer.constructQuery(MAVEN.CLASSNAMES, term, SearchType.SCORED);

    FlatSearchRequest req = new FlatSearchRequest(q, ArtifactInfo.REPOSITORY_VERSION_COMPARATOR);

    // if ( from != null )
    // {
    // req.setStart( from );
    // }

    // MINDEXER-14: no hit limit anymore. But to make change least obtrusive, we set hitLimit as count 1st, and if
    // user set count, it will override it anyway
    if (hitLimit != null) {
      req.setCount(hitLimit);
    }

    if (count != null) {
      req.setCount(count);
    }

    // if ( hitLimit != null )
    // {
    // req._setResultHitLimit( hitLimit );
View Full Code Here

    if (cTerm != null) {
      bq.add(constructQuery(MAVEN.CLASSIFIER, cTerm, SearchType.SCORED), BooleanClause.Occur.MUST);
    }

    FlatSearchRequest req = new FlatSearchRequest(bq, ArtifactInfo.REPOSITORY_VERSION_COMPARATOR);

    // if ( from != null )
    // {
    // req.setStart( from );
    // }

    // MINDEXER-14: no hit limit anymore. But to make change least obtrusive, we set hitLimit as count 1st, and if
    // user set count, it will override it anyway
    if (hitLimit != null) {
      req.setCount(hitLimit);
    }

    if (count != null) {
      req.setCount(count);
    }

    // if ( hitLimit != null )
    // {
    // req._setResultHitLimit( hitLimit );
View Full Code Here

        throws RepositorySearchException
    {

        try
        {
            FlatSearchRequest request = new FlatSearchRequest( q );
            request.setContexts( getIndexingContexts( indexingContextIds ) );

            FlatSearchResponse response = indexer.searchFlat( request );

            if ( response == null || response.getTotalHits() == 0 )
            {
View Full Code Here

                            if ( ac.getArtifactInfo().packaging != null )
                            {
                                q.add( nexusIndexer.constructQuery( MAVEN.PACKAGING, new SourcedSearchExpression(
                                    ac.getArtifactInfo().packaging ) ), BooleanClause.Occur.MUST );
                            }
                            FlatSearchRequest flatSearchRequest = new FlatSearchRequest( q, context );
                            FlatSearchResponse flatSearchResponse = nexusIndexer.searchFlat( flatSearchRequest );
                            if ( flatSearchResponse.getResults().isEmpty() )
                            {
                                log.debug( "Adding artifact '{}' to index..", ac.getArtifactInfo() );
                                nexusIndexer.addArtifactToIndex( ac, context );
View Full Code Here

        // search
        BooleanQuery iQuery = new BooleanQuery();
        iQuery.add( nexusIndexer.constructQuery( MAVEN.GROUP_ID, new StringSearchExpression( "commons-logging" ) ),
                    BooleanClause.Occur.SHOULD );

        FlatSearchRequest rq = new FlatSearchRequest( iQuery );
        rq.setContexts(
            Arrays.asList( nexusIndexer.getIndexingContexts().get( "remote-" + getRemoteRepository().getId() ) ) );

        FlatSearchResponse response = nexusIndexer.searchFlat( rq );

        log.info( "returned hit count:" + response.getReturnedHitsCount() );
View Full Code Here

TOP

Related Classes of org.apache.maven.index.FlatSearchRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.