1 package org.apache.archiva.indexer.maven.search;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.admin.model.RepositoryAdminException;
23 import org.apache.archiva.admin.model.beans.ProxyConnector;
24 import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin;
25 import org.apache.archiva.indexer.UnsupportedBaseContextException;
26 import org.apache.archiva.indexer.search.ArtifactInfoFilter;
27 import org.apache.archiva.indexer.search.NoClassifierArtifactInfoFilter;
28 import org.apache.archiva.indexer.search.RepositorySearch;
29 import org.apache.archiva.indexer.search.RepositorySearchException;
30 import org.apache.archiva.indexer.search.SearchFields;
31 import org.apache.archiva.indexer.search.SearchResultHit;
32 import org.apache.archiva.indexer.search.SearchResultLimits;
33 import org.apache.archiva.indexer.search.SearchResults;
34 import org.apache.archiva.indexer.util.SearchUtil;
35 import org.apache.archiva.model.ArchivaArtifactModel;
36 import org.apache.archiva.repository.RemoteRepository;
37 import org.apache.archiva.repository.Repository;
38 import org.apache.archiva.repository.RepositoryRegistry;
39 import org.apache.archiva.repository.RepositoryType;
40 import org.apache.commons.lang.StringUtils;
41 import org.apache.maven.index.ArtifactInfo;
42 import org.apache.maven.index.FlatSearchRequest;
43 import org.apache.maven.index.FlatSearchResponse;
44 import org.apache.maven.index.Indexer;
45 import org.apache.maven.index.MAVEN;
46 import org.apache.maven.index.OSGI;
47 import org.apache.maven.index.QueryCreator;
48 import org.apache.maven.index.SearchType;
49 import org.apache.maven.index.context.IndexingContext;
50 import org.apache.maven.index.expr.SearchExpression;
51 import org.apache.maven.index.expr.SearchTyped;
52 import org.apache.maven.index.expr.SourcedSearchExpression;
53 import org.apache.maven.index.expr.UserInputSearchExpression;
54 import org.apache.maven.index_shaded.lucene.search.BooleanClause;
55 import org.apache.maven.index_shaded.lucene.search.BooleanClause.Occur;
56 import org.apache.maven.index_shaded.lucene.search.BooleanQuery;
57 import org.slf4j.Logger;
58 import org.slf4j.LoggerFactory;
59 import org.springframework.stereotype.Service;
61 import javax.inject.Inject;
62 import java.io.IOException;
63 import java.util.ArrayList;
64 import java.util.Collection;
65 import java.util.Collections;
66 import java.util.HashSet;
67 import java.util.List;
72 * RepositorySearch implementation which uses the Maven Indexer for searching.
74 @Service( "repositorySearch#maven" )
75 public class MavenRepositorySearch
76 implements RepositorySearch
78 private Logger log = LoggerFactory.getLogger( getClass() );
80 private Indexer indexer;
82 private QueryCreator queryCreator;
85 RepositoryRegistry repositoryRegistry;
87 private ProxyConnectorAdmin proxyConnectorAdmin;
89 protected MavenRepositorySearch()
95 public MavenRepositorySearch( Indexer nexusIndexer, RepositoryRegistry repositoryRegistry,
97 ProxyConnectorAdmin proxyConnectorAdmin, QueryCreator queryCreator )
99 this.indexer = nexusIndexer;
100 this.queryCreator = queryCreator;
101 this.repositoryRegistry = repositoryRegistry;
102 this.proxyConnectorAdmin = proxyConnectorAdmin;
106 * @see RepositorySearch#search(String, List, String, SearchResultLimits, List)
109 public SearchResults search(String principal, List<String> selectedRepos, String term, SearchResultLimits limits,
110 List<String> previousSearchTerms )
111 throws RepositorySearchException
113 List<String> indexingContextIds = addIndexingContexts( selectedRepos );
115 // since upgrade to nexus 2.0.0, query has changed from g:[QUERIED TERM]* to g:*[QUERIED TERM]*
116 // resulting to more wildcard searches so we need to increase max clause count
117 BooleanQuery.setMaxClauseCount( Integer.MAX_VALUE );
118 BooleanQuery.Builder qb = new BooleanQuery.Builder();
120 if ( previousSearchTerms == null || previousSearchTerms.isEmpty() )
122 constructQuery( term, qb );
126 for ( String previousTerm : previousSearchTerms )
128 BooleanQuery.Builder iQuery = new BooleanQuery.Builder();
129 constructQuery( previousTerm, iQuery );
131 qb.add( iQuery.build(), BooleanClause.Occur.MUST );
134 BooleanQuery.Builder iQuery = new BooleanQuery.Builder();
135 constructQuery( term, iQuery );
136 qb.add( iQuery.build(), BooleanClause.Occur.MUST );
139 // we retun only artifacts without classifier in quick search, olamy cannot find a way to say with this field empty
140 // FIXME cannot find a way currently to setup this in constructQuery !!!
141 return search( limits, qb.build(), indexingContextIds, NoClassifierArtifactInfoFilter.LIST, selectedRepos, true );
146 * @see RepositorySearch#search(String, SearchFields, SearchResultLimits)
149 public SearchResults search( String principal, SearchFields searchFields, SearchResultLimits limits )
150 throws RepositorySearchException
152 if ( searchFields.getRepositories() == null )
154 throw new RepositorySearchException( "Repositories cannot be null." );
157 List<String> indexingContextIds = addIndexingContexts( searchFields.getRepositories() );
159 // if no index found in the specified ones return an empty search result instead of doing a search on all index
160 // olamy: IMHO doesn't make sense
161 if ( !searchFields.getRepositories().isEmpty() && ( indexingContextIds == null
162 || indexingContextIds.isEmpty() ) )
164 return new SearchResults();
167 BooleanQuery.Builder qb = new BooleanQuery.Builder();
168 if ( StringUtils.isNotBlank( searchFields.getGroupId() ) )
170 qb.add( indexer.constructQuery( MAVEN.GROUP_ID, searchFields.isExactSearch() ? new SourcedSearchExpression(
171 searchFields.getGroupId() ) : new UserInputSearchExpression( searchFields.getGroupId() ) ),
172 BooleanClause.Occur.MUST );
175 if ( StringUtils.isNotBlank( searchFields.getArtifactId() ) )
177 qb.add( indexer.constructQuery( MAVEN.ARTIFACT_ID,
178 searchFields.isExactSearch()
179 ? new SourcedSearchExpression( searchFields.getArtifactId() )
180 : new UserInputSearchExpression( searchFields.getArtifactId() ) ),
181 BooleanClause.Occur.MUST );
184 if ( StringUtils.isNotBlank( searchFields.getVersion() ) )
186 qb.add( indexer.constructQuery( MAVEN.VERSION, searchFields.isExactSearch() ? new SourcedSearchExpression(
187 searchFields.getVersion() ) : new SourcedSearchExpression( searchFields.getVersion() ) ),
188 BooleanClause.Occur.MUST );
191 if ( StringUtils.isNotBlank( searchFields.getPackaging() ) )
193 qb.add( indexer.constructQuery( MAVEN.PACKAGING, searchFields.isExactSearch() ? new SourcedSearchExpression(
194 searchFields.getPackaging() ) : new UserInputSearchExpression( searchFields.getPackaging() ) ),
195 BooleanClause.Occur.MUST );
198 if ( StringUtils.isNotBlank( searchFields.getClassName() ) )
200 qb.add( indexer.constructQuery( MAVEN.CLASSNAMES,
201 new UserInputSearchExpression( searchFields.getClassName() ) ),
202 BooleanClause.Occur.MUST );
205 if ( StringUtils.isNotBlank( searchFields.getBundleSymbolicName() ) )
207 qb.add( indexer.constructQuery( OSGI.SYMBOLIC_NAME,
208 new UserInputSearchExpression( searchFields.getBundleSymbolicName() ) ),
209 BooleanClause.Occur.MUST );
212 if ( StringUtils.isNotBlank( searchFields.getBundleVersion() ) )
214 qb.add( indexer.constructQuery( OSGI.VERSION,
215 new UserInputSearchExpression( searchFields.getBundleVersion() ) ),
216 BooleanClause.Occur.MUST );
219 if ( StringUtils.isNotBlank( searchFields.getBundleExportPackage() ) )
221 qb.add( indexer.constructQuery( OSGI.EXPORT_PACKAGE,
222 new UserInputSearchExpression( searchFields.getBundleExportPackage() ) ),
226 if ( StringUtils.isNotBlank( searchFields.getBundleExportService() ) )
228 qb.add( indexer.constructQuery( OSGI.EXPORT_SERVICE,
229 new UserInputSearchExpression( searchFields.getBundleExportService() ) ),
233 if ( StringUtils.isNotBlank( searchFields.getBundleImportPackage() ) )
235 qb.add( indexer.constructQuery( OSGI.IMPORT_PACKAGE,
236 new UserInputSearchExpression( searchFields.getBundleImportPackage() ) ),
240 if ( StringUtils.isNotBlank( searchFields.getBundleName() ) )
242 qb.add( indexer.constructQuery( OSGI.NAME, new UserInputSearchExpression( searchFields.getBundleName() ) ),
246 if ( StringUtils.isNotBlank( searchFields.getBundleImportPackage() ) )
248 qb.add( indexer.constructQuery( OSGI.IMPORT_PACKAGE,
249 new UserInputSearchExpression( searchFields.getBundleImportPackage() ) ),
253 if ( StringUtils.isNotBlank( searchFields.getBundleRequireBundle() ) )
255 qb.add( indexer.constructQuery( OSGI.REQUIRE_BUNDLE,
256 new UserInputSearchExpression( searchFields.getBundleRequireBundle() ) ),
260 if ( StringUtils.isNotBlank( searchFields.getClassifier() ) )
262 qb.add( indexer.constructQuery( MAVEN.CLASSIFIER, searchFields.isExactSearch() ? new SourcedSearchExpression(
263 searchFields.getClassifier() ) : new UserInputSearchExpression( searchFields.getClassifier() ) ),
266 else if ( searchFields.isExactSearch() )
268 //TODO improvement in case of exact search and no classifier we must query for classifier with null value
269 // currently it's done in DefaultSearchService with some filtering
272 BooleanQuery qu = qb.build();
273 if ( qu.clauses() == null || qu.clauses().size() <= 0 )
275 throw new RepositorySearchException( "No search fields set." );
277 if (qu.clauses()!=null) {
278 log.debug("CLAUSES ", qu.clauses());
279 for (BooleanClause cl : qu.clauses()) {
280 log.debug("Clause ",cl);
284 return search( limits, qu, indexingContextIds, Collections.<ArtifactInfoFilter>emptyList(),
285 searchFields.getRepositories(), searchFields.isIncludePomArtifacts() );
288 private static class NullSearch
289 implements SearchTyped, SearchExpression
291 private static final NullSearch INSTANCE = new NullSearch();
294 public String getStringValue()
296 return "[[NULL_VALUE]]";
300 public SearchType getSearchType()
302 return SearchType.EXACT;
306 private SearchResults search( SearchResultLimits limits, BooleanQuery q, List<String> indexingContextIds,
307 List<? extends ArtifactInfoFilter> filters, List<String> selectedRepos,
308 boolean includePoms )
309 throws RepositorySearchException
314 FlatSearchRequest request = new FlatSearchRequest( q );
316 request.setContexts( getIndexingContexts( indexingContextIds ) );
317 if ( limits != null )
319 // we apply limits only when first page asked
320 if ( limits.getSelectedPage() == 0 )
322 request.setCount( limits.getPageSize() * ( Math.max( 1, limits.getSelectedPage() ) ) );
326 FlatSearchResponse response = indexer.searchFlat( request );
328 if ( response == null || response.getTotalHits() == 0 )
330 SearchResults results = new SearchResults();
331 results.setLimits( limits );
335 return convertToSearchResults( response, limits, filters, selectedRepos, includePoms );
337 catch ( IOException e )
339 throw new RepositorySearchException( e.getMessage(), e );
341 catch ( RepositoryAdminException e )
343 throw new RepositorySearchException( e.getMessage(), e );
348 private IndexingContext getIndexingContext(String id) {
350 if (StringUtils.startsWith(id, "remote-")) {
351 repoId = StringUtils.substringAfter(id, "remote-");
355 Repository repo = repositoryRegistry.getRepository(repoId);
359 if (repo.getIndexingContext()!=null) {
361 return repo.getIndexingContext().getBaseContext(IndexingContext.class);
362 } catch (UnsupportedBaseContextException e) {
371 private List<IndexingContext> getIndexingContexts( List<String> ids )
373 List<IndexingContext> contexts = new ArrayList<>( ids.size() );
375 for ( String id : ids )
377 IndexingContext context = getIndexingContext(id);
378 if ( context != null )
380 contexts.add( context );
384 log.warn( "context with id {} not exists", id );
391 private void constructQuery( String term, BooleanQuery.Builder q )
393 q.add( indexer.constructQuery( MAVEN.GROUP_ID, new UserInputSearchExpression( term ) ), Occur.SHOULD );
394 q.add( indexer.constructQuery( MAVEN.ARTIFACT_ID, new UserInputSearchExpression( term ) ), Occur.SHOULD );
395 q.add( indexer.constructQuery( MAVEN.VERSION, new UserInputSearchExpression( term ) ), Occur.SHOULD );
396 q.add( indexer.constructQuery( MAVEN.PACKAGING, new UserInputSearchExpression( term ) ), Occur.SHOULD );
397 q.add( indexer.constructQuery( MAVEN.CLASSNAMES, new UserInputSearchExpression( term ) ), Occur.SHOULD );
400 // new WildcardQuery( new Term( MAVEN.CLASSNAMES.getFieldName(), "*" ) );
401 //q.add( query, Occur.MUST_NOT );
402 // olamy IMHO we could set this option as at least one must match
403 //q.setMinimumNumberShouldMatch( 1 );
408 * @param selectedRepos
409 * @return indexing contextId used
411 private List<String> addIndexingContexts( List<String> selectedRepos )
413 Set<String> indexingContextIds = new HashSet<>();
414 for ( String repo : selectedRepos )
418 Repository rRepo = repositoryRegistry.getRepository(repo);
423 if (rRepo.getType().equals(RepositoryType.MAVEN)) {
424 assert rRepo.getIndexingContext() != null;
425 IndexingContext context = rRepo.getIndexingContext().getBaseContext(IndexingContext.class);
426 if (context.isSearchable()) {
427 indexingContextIds.addAll(getRemoteIndexingContextIds(repo));
428 indexingContextIds.add(context.getId());
430 log.warn("indexingContext with id {} not searchable", rRepo.getId());
437 log.warn( "Repository '{}' not found in configuration.", repo );
440 catch ( RepositorySearchException e )
442 log.warn( "RepositorySearchException occured while accessing index of repository '{}' : {}", repo,
445 } catch (UnsupportedBaseContextException e) {
446 log.error("Fatal situation: Maven repository without IndexingContext found.");
451 return new ArrayList<>( indexingContextIds );
456 public Set<String> getRemoteIndexingContextIds( String managedRepoId )
457 throws RepositorySearchException
459 Set<String> ids = new HashSet<>();
461 List<ProxyConnector> proxyConnectors = null;
464 proxyConnectors = proxyConnectorAdmin.getProxyConnectorAsMap().get( managedRepoId );
466 catch ( RepositoryAdminException e )
468 throw new RepositorySearchException( e.getMessage(), e );
471 if ( proxyConnectors == null || proxyConnectors.isEmpty() )
476 for ( ProxyConnector proxyConnector : proxyConnectors )
478 String remoteId = "remote-" + proxyConnector.getTargetRepoId();
479 RemoteRepository repo = repositoryRegistry.getRemoteRepository(proxyConnector.getTargetRepoId());
480 if (repo.getType()==RepositoryType.MAVEN) {
482 IndexingContext context = repo.getIndexingContext() != null ? repo.getIndexingContext().getBaseContext(IndexingContext.class) : null;
483 if (context!=null && context.isSearchable()) {
486 } catch (UnsupportedBaseContextException e) {
496 public Collection<String> getAllGroupIds( String principal, List<String> selectedRepos )
497 throws RepositorySearchException
499 List<IndexingContext> indexContexts = getIndexingContexts( selectedRepos );
501 if ( indexContexts == null || indexContexts.isEmpty() )
503 return Collections.emptyList();
508 Set<String> allGroupIds = new HashSet<>();
509 for ( IndexingContext indexingContext : indexContexts )
511 allGroupIds.addAll( indexingContext.getAllGroups() );
515 catch ( IOException e )
517 throw new RepositorySearchException( e.getMessage(), e );
522 private SearchResults convertToSearchResults( FlatSearchResponse response, SearchResultLimits limits,
523 List<? extends ArtifactInfoFilter> artifactInfoFilters,
524 List<String> selectedRepos, boolean includePoms )
525 throws RepositoryAdminException
527 SearchResults results = new SearchResults();
528 Set<ArtifactInfo> artifactInfos = response.getResults();
530 for ( ArtifactInfo artifactInfo : artifactInfos )
532 if ( StringUtils.equalsIgnoreCase( "pom", artifactInfo.getFileExtension() ) && !includePoms )
536 String id = SearchUtil.getHitId( artifactInfo.getGroupId(), //
537 artifactInfo.getArtifactId(), //
538 artifactInfo.getClassifier(), //
539 artifactInfo.getPackaging() );
540 Map<String, SearchResultHit> hitsMap = results.getHitsMap();
543 if ( !applyArtifactInfoFilters( artifactInfo, artifactInfoFilters, hitsMap ) )
548 SearchResultHit hit = hitsMap.get( id );
551 if ( !hit.getVersions().contains( artifactInfo.getVersion() ) )
553 hit.addVersion( artifactInfo.getVersion() );
558 hit = new SearchResultHit();
559 hit.setArtifactId( artifactInfo.getArtifactId() );
560 hit.setGroupId( artifactInfo.getGroupId() );
561 hit.setRepositoryId( artifactInfo.getRepository() );
562 hit.addVersion( artifactInfo.getVersion() );
563 hit.setBundleExportPackage( artifactInfo.getBundleExportPackage() );
564 hit.setBundleExportService( artifactInfo.getBundleExportService() );
565 hit.setBundleSymbolicName( artifactInfo.getBundleSymbolicName() );
566 hit.setBundleVersion( artifactInfo.getBundleVersion() );
567 hit.setBundleDescription( artifactInfo.getBundleDescription() );
568 hit.setBundleDocUrl( artifactInfo.getBundleDocUrl() );
569 hit.setBundleRequireBundle( artifactInfo.getBundleRequireBundle() );
570 hit.setBundleImportPackage( artifactInfo.getBundleImportPackage() );
571 hit.setBundleLicense( artifactInfo.getBundleLicense() );
572 hit.setBundleName( artifactInfo.getBundleName() );
573 hit.setContext( artifactInfo.getContext() );
574 hit.setGoals( artifactInfo.getGoals() );
575 hit.setPrefix( artifactInfo.getPrefix() );
576 hit.setPackaging( artifactInfo.getPackaging() );
577 hit.setClassifier( artifactInfo.getClassifier() );
578 hit.setFileExtension( artifactInfo.getFileExtension() );
579 hit.setUrl( getBaseUrl( artifactInfo, selectedRepos ) );
582 results.addHit( id, hit );
585 results.setTotalHits( response.getTotalHitsCount() );
586 results.setTotalHitsMapSize( results.getHitsMap().values().size() );
587 results.setReturnedHitsCount( response.getReturnedHitsCount() );
588 results.setLimits( limits );
590 if ( limits == null || limits.getSelectedPage() == SearchResultLimits.ALL_PAGES )
596 return paginate( results );
601 * calculate baseUrl without the context and base Archiva Url
603 * @param artifactInfo
606 protected String getBaseUrl( ArtifactInfo artifactInfo, List<String> selectedRepos )
607 throws RepositoryAdminException
609 StringBuilder sb = new StringBuilder();
610 if ( StringUtils.startsWith( artifactInfo.getContext(), "remote-" ) )
612 // it's a remote index result we search a managed which proxying this remote and on which
613 // current user has read karma
614 String managedRepoId =
615 getManagedRepoId( StringUtils.substringAfter( artifactInfo.getContext(), "remote-" ), selectedRepos );
616 if ( managedRepoId != null )
618 sb.append( '/' ).append( managedRepoId );
619 artifactInfo.setContext( managedRepoId );
624 sb.append( '/' ).append( artifactInfo.getContext() );
627 sb.append( '/' ).append( StringUtils.replaceChars( artifactInfo.getGroupId(), '.', '/' ) );
628 sb.append( '/' ).append( artifactInfo.getArtifactId() );
629 sb.append( '/' ).append( artifactInfo.getVersion() );
630 sb.append( '/' ).append( artifactInfo.getArtifactId() );
631 sb.append( '-' ).append( artifactInfo.getVersion() );
632 if ( StringUtils.isNotBlank( artifactInfo.getClassifier() ) )
634 sb.append( '-' ).append( artifactInfo.getClassifier() );
636 // maven-plugin packaging is a jar
637 if ( StringUtils.equals( "maven-plugin", artifactInfo.getPackaging() ) )
643 sb.append( '.' ).append( artifactInfo.getPackaging() );
646 return sb.toString();
650 * return a managed repo for a remote result
653 * @param selectedRepos
655 * @throws RepositoryAdminException
657 private String getManagedRepoId( String remoteRepo, List<String> selectedRepos )
658 throws RepositoryAdminException
660 Map<String, List<ProxyConnector>> proxyConnectorMap = proxyConnectorAdmin.getProxyConnectorAsMap();
661 if ( proxyConnectorMap == null || proxyConnectorMap.isEmpty() )
665 if ( selectedRepos != null && !selectedRepos.isEmpty() )
667 for ( Map.Entry<String, List<ProxyConnector>> entry : proxyConnectorMap.entrySet() )
669 if ( selectedRepos.contains( entry.getKey() ) )
671 for ( ProxyConnector proxyConnector : entry.getValue() )
673 if ( StringUtils.equals( remoteRepo, proxyConnector.getTargetRepoId() ) )
675 return proxyConnector.getSourceRepoId();
682 // we don't find in search selected repos so return the first one
683 for ( Map.Entry<String, List<ProxyConnector>> entry : proxyConnectorMap.entrySet() )
686 for ( ProxyConnector proxyConnector : entry.getValue() )
688 if ( StringUtils.equals( remoteRepo, proxyConnector.getTargetRepoId() ) )
690 return proxyConnector.getSourceRepoId();
698 private boolean applyArtifactInfoFilters( ArtifactInfo artifactInfo,
699 List<? extends ArtifactInfoFilter> artifactInfoFilters,
700 Map<String, SearchResultHit> currentResult )
702 if ( artifactInfoFilters == null || artifactInfoFilters.isEmpty() )
707 ArchivaArtifactModel artifact = new ArchivaArtifactModel();
708 artifact.setArtifactId( artifactInfo.getArtifactId() );
709 artifact.setClassifier( artifactInfo.getClassifier() );
710 artifact.setGroupId( artifactInfo.getGroupId() );
711 artifact.setRepositoryId( artifactInfo.getRepository() );
712 artifact.setVersion( artifactInfo.getVersion() );
713 artifact.setChecksumMD5( artifactInfo.getMd5() );
714 artifact.setChecksumSHA1( artifactInfo.getSha1() );
715 for ( ArtifactInfoFilter filter : artifactInfoFilters )
717 if ( !filter.addArtifactInResult( artifact, currentResult ) )
725 protected SearchResults paginate( SearchResults results )
727 SearchResultLimits limits = results.getLimits();
728 SearchResults paginated = new SearchResults();
730 // ( limits.getPageSize() * ( Math.max( 1, limits.getSelectedPage() ) ) );
732 int fetchCount = limits.getPageSize();
733 int offset = ( limits.getSelectedPage() * limits.getPageSize() );
735 if ( fetchCount > results.getTotalHits() )
737 fetchCount = results.getTotalHits();
741 if ( offset < results.getTotalHits() )
743 // only process if the offset is within the hit count.
744 for ( int i = 0; i < fetchCount; i++ )
746 // Stop fetching if we are past the total # of available hits.
747 if ( offset + i >= results.getHits().size() )
752 SearchResultHit hit = results.getHits().get( ( offset + i ) );
755 String id = SearchUtil.getHitId( hit.getGroupId(), hit.getArtifactId(), hit.getClassifier(),
756 hit.getPackaging() );
757 paginated.addHit( id, hit );
765 paginated.setTotalHits( results.getTotalHits() );
766 paginated.setReturnedHitsCount( paginated.getHits().size() );
767 paginated.setTotalHitsMapSize( results.getTotalHitsMapSize() );
768 paginated.setLimits( limits );