@Deprecated public Set<ArtifactInfo> searchFlat( Comparator<ArtifactInfo> artifactInfoComparator, IndexingContext indexingContext, Query query ) throws IOException { return searchFlatPaged( new FlatSearchRequest( query, artifactInfoComparator, indexingContext ), Arrays.asList( indexingContext ), true ).getResults(); }
@Deprecated public Set<ArtifactInfo> searchFlat( Comparator<ArtifactInfo> artifactInfoComparator, IndexingContext indexingContext, Query query ) throws IOException { return searchFlatPaged( new FlatSearchRequest( query, artifactInfoComparator, indexingContext ), Arrays.asList( indexingContext ), true ).getResults(); }
@Deprecated public Set<ArtifactInfo> searchFlat( Comparator<ArtifactInfo> artifactInfoComparator, IndexingContext indexingContext, Query query ) throws IOException { return searchFlatPaged( new FlatSearchRequest( query, artifactInfoComparator, indexingContext ), Arrays.asList( indexingContext ), true ).getResults(); }
@Deprecated public Set<ArtifactInfo> searchFlat( Comparator<ArtifactInfo> artifactInfoComparator, Collection<IndexingContext> indexingContexts, Query query ) throws IOException { return searchFlatPaged( new FlatSearchRequest( query, artifactInfoComparator ), indexingContexts ).getResults(); }
@Deprecated public Set<ArtifactInfo> searchFlat( Comparator<ArtifactInfo> artifactInfoComparator, Collection<IndexingContext> indexingContexts, Query query ) throws IOException { return searchFlatPaged( new FlatSearchRequest( query, artifactInfoComparator ), indexingContexts ).getResults(); }
@Deprecated public Set<ArtifactInfo> searchFlat( Comparator<ArtifactInfo> artifactInfoComparator, Collection<IndexingContext> indexingContexts, Query query ) throws IOException { return searchFlatPaged( new FlatSearchRequest( query, artifactInfoComparator ), indexingContexts ).getResults(); }
public void searchAndDump( Indexer nexusIndexer, String descr, Query q ) throws IOException { System.out.println( "Searching for " + descr ); FlatSearchResponse response = nexusIndexer.searchFlat( new FlatSearchRequest( q, centralContext ) ); for ( ArtifactInfo ai : response.getResults() ) { System.out.println( ai.toString() ); } System.out.println( "------" ); System.out.println( "Total: " + response.getTotalHitsCount() ); System.out.println(); }
public List<ArtifactDTO> searchFlat(BooleanQuery q) throws IOException { List<ArtifactDTO> answer = new ArrayList<ArtifactDTO>(); FlatSearchResponse response = indexer.searchFlat(new FlatSearchRequest(q, mergedContext)); int index = 0; for (ArtifactInfo ai : response.getResults()) { ArtifactDTO dto = createArtifactDTO(ai); answer.add(dto); if (++index > SEARCH_LIMIT) { break; } } return answer; }
@Override public List<String> groupIdComplete(String groupId, String packaging, String classifier) throws IOException { BooleanQuery bq = createQuery(endWithStarIfNotBlank(groupId), null, null, packaging, classifier, null); Set<String> set = new TreeSet<String>(); FlatSearchResponse response = indexer.searchFlat(new FlatSearchRequest(bq, mergedContext)); int index = 0; for (ArtifactInfo ai : response.getResults()) { set.add(ai.groupId); if (++index > SEARCH_LIMIT) { break; } } return new ArrayList<String>(set); }
@Override public List<String> artifactIdComplete(String groupId, String artifactId, String packaging, String classifier) throws IOException { BooleanQuery bq = createQuery(groupId, endWithStarIfNotBlank(artifactId), null, packaging, classifier, null); Set<String> set = new TreeSet<String>(); FlatSearchResponse response = indexer.searchFlat(new FlatSearchRequest(bq, mergedContext)); int index = 0; for (ArtifactInfo ai : response.getResults()) { set.add(ai.artifactId); if (++index > SEARCH_LIMIT) { break; } } return new ArrayList<String>(set); }
@Override public List<String> versionComplete(String groupId, String artifactId, String version, String packaging, String classifier) throws IOException { BooleanQuery bq = createQuery(groupId, artifactId, endWithStarIfNotBlank(version), packaging, classifier, null); Set<String> set = new TreeSet<String>(); int index = 0; FlatSearchResponse response = indexer.searchFlat(new FlatSearchRequest(bq, mergedContext)); for (ArtifactInfo ai : response.getResults()) { set.add(ai.version); if (++index > SEARCH_LIMIT) { break; } } return new ArrayList<String>(set); }
private FlatSearchResponse searchFlat(String repositoryId, FlatSearchRequest req) throws NoSuchRepositoryException { LockedIndexingContexts lockedContexts = lockSearchTargetIndexingContexts(repositoryId); if (lockedContexts == null) { return new FlatSearchResponse(req.getQuery(), 0, Collections.<ArtifactInfo>emptySet()); } try { req.getContexts().addAll(lockedContexts.contexts.values()); FlatSearchResponse result = mavenIndexer.searchFlat(req); postprocessResults(result.getResults()); return result; } catch (BooleanQuery.TooManyClauses e) { if (log.isDebugEnabled()) { log.debug("Too many clauses exception caught:", e); } // XXX: a hack, I am sending too many results by setting the totalHits value to -1! return new FlatSearchResponse(req.getQuery(), -1, new HashSet<ArtifactInfo>()); } catch (IOException e) { log.error("Got I/O exception while searching for query \"" + req.getQuery() + "\"", e); return new FlatSearchResponse(req.getQuery(), 0, new HashSet<ArtifactInfo>()); } finally { lockedContexts.lock.unlock(); } }
public Set<ArtifactInfo> search( final String queryText ) throws ParseException, IOException { final Query query = new MultiFieldQueryParser( LUCENE_FIELDS, LUCENE_ANALYZER ).parse( queryText ); LOGGER.debug( "Executing search query: {}; ctx id: {}; idx dir: {}", new String[]{ query.toString(), indexingContext.getId(), indexingContext.getIndexDirectory().toString() } ); final FlatSearchResponse response = getIndexer().searchFlat( new FlatSearchRequest( query, indexingContext ) ); final Set<ArtifactInfo> results = response.getResults(); if ( LOGGER.isDebugEnabled() ) { LOGGER.debug( "Hit count: {}", response.getReturnedHitsCount() ); for ( final ArtifactInfo result : results ) { LOGGER.debug( "Found artifact: {}; uinfo: {}", result.toString(), result.getUinfo() ); } } return results; }
public Set<ArtifactInfo> searchBySHA1( final String checksum ) throws IOException { final BooleanQuery query = new BooleanQuery(); query.add( getIndexer().constructQuery( MAVEN.SHA1, new SourcedSearchExpression( checksum ) ), MUST ); LOGGER.debug( "Executing search query: {}; ctx id: {}; idx dir: {}", new String[]{ query.toString(), indexingContext.getId(), indexingContext.getIndexDirectory().toString() } ); final FlatSearchResponse response = getIndexer().searchFlat( new FlatSearchRequest( query, indexingContext ) ); LOGGER.info( "Hit count: {}", response.getReturnedHitsCount() ); final Set<ArtifactInfo> results = response.getResults(); if ( LOGGER.isDebugEnabled() ) { for ( final ArtifactInfo result : results ) { LOGGER.debug( "Found artifact: {}", result.toString() ); } } return results; }
public ArchetypeCatalog getArchetypeCatalog( final Properties properties ) throws ArchetypeDataSourceException { final ArchetypeCatalog catalog = new ArchetypeCatalog(); try { final Map<String, String> repositories = getRepositoryMap(); final Query pq = indexer.constructQuery( MAVEN.PACKAGING, new SourcedSearchExpression( "maven-archetype" ) ); final FlatSearchRequest searchRequest = new FlatSearchRequest( pq ); searchRequest.setContexts( getIndexingContexts() ); final FlatSearchResponse searchResponse = indexer.searchFlat( searchRequest ); for ( ArtifactInfo info : searchResponse.getResults() ) { Archetype archetype = new Archetype(); archetype.setGroupId( info.getGroupId() ); archetype.setArtifactId( info.getArtifactId() ); archetype.setVersion( info.getVersion() ); archetype.setDescription( info.getDescription() ); archetype.setRepository( repositories.get( info.getRepository() ) ); catalog.addArchetype( archetype ); } } catch ( Exception ex ) { getLogger().error( "Unable to retrieve archetypes", ex ); } return catalog; }
public ArchetypeCatalog getArchetypeCatalog( final Properties properties ) { final ArchetypeCatalog catalog = new ArchetypeCatalog(); try { final Map<String, String> repositories = getRepositoryMap(); final Query pq = indexer.constructQuery( MAVEN.PACKAGING, new SourcedSearchExpression( "maven-archetype" ) ); final FlatSearchRequest searchRequest = new FlatSearchRequest( pq ); searchRequest.setContexts( getIndexingContexts() ); final FlatSearchResponse searchResponse = indexer.searchFlat( searchRequest ); for ( ArtifactInfo info : searchResponse.getResults() ) { Archetype archetype = new Archetype(); archetype.setGroupId( info.getGroupId() ); archetype.setArtifactId( info.getArtifactId() ); archetype.setVersion( info.getVersion() ); archetype.setDescription( info.getDescription() ); archetype.setRepository( repositories.get( info.getRepository() ) ); catalog.addArchetype( archetype ); } } catch ( Exception ex ) { getLogger().error( "Unable to retrieve archetypes", ex ); } return catalog; }
public ArchetypeCatalog getArchetypeCatalog( final Properties properties ) { final ArchetypeCatalog catalog = new ArchetypeCatalog(); try { final Map<String, String> repositories = getRepositoryMap(); final Query pq = indexer.constructQuery( MAVEN.PACKAGING, new SourcedSearchExpression( "maven-archetype" ) ); final FlatSearchRequest searchRequest = new FlatSearchRequest( pq ); searchRequest.setContexts( getIndexingContexts() ); final FlatSearchResponse searchResponse = indexer.searchFlat( searchRequest ); for ( ArtifactInfo info : searchResponse.getResults() ) { Archetype archetype = new Archetype(); archetype.setGroupId( info.getGroupId() ); archetype.setArtifactId( info.getArtifactId() ); archetype.setVersion( info.getVersion() ); archetype.setDescription( info.getDescription() ); archetype.setRepository( repositories.get( info.getRepository() ) ); catalog.addArchetype( archetype ); } } catch ( Exception ex ) { getLogger().error( "Unable to retrieve archetypes", ex ); } return catalog; }
final Set<ArtifactInfo> results = response.getResults(); if ( LOGGER.isDebugEnabled() )
Set<ArtifactInfo> artifactInfos = response.getResults();
Set<ArtifactInfo> artifactInfos = response.getResults();