Package org.apache.maven.index

Examples of org.apache.maven.index.IteratorSearchRequest


    {
        NexusIndexer indexer = prepare();

        Query q = indexer.constructQuery( MAVEN.GROUP_ID, "qdox", SearchType.SCORED );

        IteratorSearchRequest request = new IteratorSearchRequest( q );

        IteratorSearchResponse response = indexer.searchIterator( request );

        assertEquals( 2, response.getTotalHits() );
View Full Code Here


        UniqueArtifactFilterPostprocessor filter = new UniqueArtifactFilterPostprocessor();
        filter.addField( MAVEN.GROUP_ID );
        filter.addField( MAVEN.ARTIFACT_ID );

        IteratorSearchRequest request = new IteratorSearchRequest( q, filter );

        IteratorSearchResponse response = indexer.searchIterator( request );

        assertEquals( "15 total hits (before filtering!)", 15, response.getTotalHits() );
View Full Code Here

        if ( versionQ != null )
        {
            q.add( new BooleanClause( versionQ, BooleanClause.Occur.MUST ) );
        }

        IteratorSearchRequest searchRequest = new IteratorSearchRequest( q, request.getArtifactInfoFilter() );

        searchRequest.getContexts().add( request.getIndexingContext() );

        IteratorSearchResponse result = getIndexer().searchIterator( searchRequest );

        return result;
    }
View Full Code Here

    protected void searchFor( String groupId, int expected, IndexingContext context )
        throws IOException, Exception
    {
        Query q = indexer.constructQuery( MAVEN.GROUP_ID, groupId, SearchType.EXACT );

        IteratorSearchRequest req;

        if ( context != null )
        {
            req = new IteratorSearchRequest( q, context );
        }
        else
        {
            req = new IteratorSearchRequest( q );
        }

        IteratorSearchResponse response = indexer.searchIterator( req );

        ArrayList<ArtifactInfo> ais = new ArrayList<ArtifactInfo>( response.getTotalHits() );
View Full Code Here

    protected IteratorSearchRequest createHighlightedRequest( Field field, String text, SearchType type )
        throws ParseException
    {
        Query q = nexusIndexer.constructQuery( field, text, type );

        IteratorSearchRequest request = new IteratorSearchRequest( q );

        request.getMatchHighlightRequests().add( new MatchHighlightRequest( field, q, MatchHighlightMode.HTML ) );

        return request;
    }
View Full Code Here

    }

    public void testClassnameSearchNgWithHighlighting()
        throws Exception
    {
        IteratorSearchRequest request = createHighlightedRequest( MAVEN.CLASSNAMES, "Logger", SearchType.SCORED );

        IteratorSearchResponse response = nexusIndexer.searchIterator( request );

        for ( ArtifactInfo ai : response )
        {
View Full Code Here

    }

    public void testGAVSearchNgWithHighlighting()
        throws Exception
    {
        IteratorSearchRequest request = createHighlightedRequest( MAVEN.GROUP_ID, "commons", SearchType.SCORED );

        IteratorSearchResponse response = nexusIndexer.searchIterator( request );

        for ( ArtifactInfo ai : response )
        {
View Full Code Here

    NexusIndexer indexer = data.getIndexer();
    IndexingContext indexingContext = data.getIndexingContext();

        Query pq = indexer.constructQuery(MAVEN.PACKAGING, "deb", SearchType.EXACT);

        IteratorSearchRequest sreq = new IteratorSearchRequest(pq, indexingContext);
        IteratorSearchResponse hits = indexer.searchIterator(sreq);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        OutputStreamWriter w = new OutputStreamWriter(baos);
View Full Code Here

  // == NG stuff

  protected IteratorSearchRequest createRequest(Query bq, Integer from, Integer count, Integer hitLimit,
                                                boolean uniqueRGA, List<ArtifactInfoFilter> extraFilters)
  {
    IteratorSearchRequest req = new IteratorSearchRequest(bq);

    List<ArtifactInfoFilter> filters = new ArrayList<ArtifactInfoFilter>();

    // security filter
    filters.add(new ArtifactInfoFilter()
    {
      public boolean accepts(IndexingContext ctx, ArtifactInfo ai) {
        return indexArtifactFilter.filterArtifactInfo(ai);
      }
    });

    if (extraFilters != null && extraFilters.size() > 0) {
      filters.addAll(extraFilters);
    }

    req.setArtifactInfoFilter(new AndMultiArtifactInfoFilter(filters));

    if (uniqueRGA) {
      req.setArtifactInfoPostprocessor(new ArtifactInfoPostprocessor()
      {
        public void postprocess(IndexingContext ctx, ArtifactInfo ai) {
          ai.context = "Aggregated";
          ai.repository = null;
        }
      });
    }
    else {
      // we may do this only when !uniqueRGA, otherwise UniqueGAArtifactFilterPostprocessor nullifies
      // ai.repository and ai.context
      req.setArtifactInfoPostprocessor(new ArtifactInfoPostprocessor()
      {
        public void postprocess(IndexingContext ctx, ArtifactInfo ai) {
          String result = ai.context;

          try {
            Repository sourceRepository = repositoryRegistry.getRepository(ai.repository);

            result = sourceRepository.getName();
          }
          catch (NoSuchRepositoryException e) {
            // nothing
          }

          ai.context = result;
        }
      });
    }

    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);
    }

    return req;
  }
View Full Code Here

  public IteratorSearchResponse searchQueryIterator(Query query, String repositoryId, Integer from, Integer count,
                                                    Integer hitLimit, boolean uniqueRGA,
                                                    List<ArtifactInfoFilter> filters)
      throws NoSuchRepositoryException
  {
    IteratorSearchRequest req = createRequest(query, from, count, hitLimit, uniqueRGA, filters);

    return searchIterator(repositoryId, req);
  }
View Full Code Here

TOP

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

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.