@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> 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); }
@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); }
@Deprecated public FlatSearchResponse searchArtifactClassFlat(String term, String repositoryId, Integer from, Integer count, Integer hitLimit) throws NoSuchRepositoryException { if (term.endsWith(".class")) { 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 ); // } return searchFlat(repositoryId, req); }
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; }
@Deprecated public FlatSearchResponse searchArtifactFlat(String term, String repositoryId, Integer from, Integer count, Integer hitLimit) throws NoSuchRepositoryException { Query q1 = mavenIndexer.constructQuery(MAVEN.GROUP_ID, term, SearchType.SCORED); Query q2 = mavenIndexer.constructQuery(MAVEN.ARTIFACT_ID, term, SearchType.SCORED); BooleanQuery bq = new BooleanQuery(); 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 ); // } return searchFlat(repositoryId, req); }
FlatSearchRequest request = new FlatSearchRequest( q );
FlatSearchRequest request = new FlatSearchRequest( q );
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; }