org.apache.maven.index.Indexer Java Examples
The following examples show how to use
org.apache.maven.index.Indexer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IndexQuerier.java From sling-whiteboard with Apache License 2.0 | 6 votes |
private void searchAndDump(Indexer nexusIndexer, String descr, Query q) throws IOException { logger.info("Searching for {}", descr); GroupedSearchResponse response = nexusIndexer .searchGrouped(new GroupedSearchRequest(q, new GAGrouping(), centralContext)); try (FileOutputStream fos = new FileOutputStream(new File(OUT_DIR, "results.csv")); BufferedOutputStream bos = new BufferedOutputStream(fos); OutputStreamWriter w = new OutputStreamWriter(bos)) { response.getResults().values() .stream() .map(IndexQuerier::extract) .filter(Objects::nonNull) .forEach(ai -> writeLine(w, ai)); logger.info("Total hits: {}", response.getTotalHitsCount()); } logger.info("Data written under {}", OUT_DIR); }
Example #2
Source File: ClassDependencyIndexCreator.java From netbeans with Apache License 2.0 | 5 votes |
static void search(String className, Indexer indexer, Collection<IndexingContext> contexts, List<? super ClassUsage> results) throws IOException { String searchString = crc32base64(className.replace('.', '/')); Query refClassQuery = indexer.constructQuery(ClassDependencyIndexCreator.FLD_NB_DEPENDENCY_CLASS.getOntology(), new StringSearchExpression(searchString)); TopScoreDocCollector collector = TopScoreDocCollector.create(NexusRepositoryIndexerImpl.MAX_RESULT_COUNT, null); for (IndexingContext context : contexts) { IndexSearcher searcher = context.acquireIndexSearcher(); try { searcher.search(refClassQuery, collector); ScoreDoc[] hits = collector.topDocs().scoreDocs; LOG.log(Level.FINER, "for {0} ~ {1} found {2} hits", new Object[] {className, searchString, hits.length}); for (ScoreDoc hit : hits) { int docId = hit.doc; Document d = searcher.doc(docId); String fldValue = d.get(ClassDependencyIndexCreator.NB_DEPENDENCY_CLASSES); LOG.log(Level.FINER, "{0} uses: {1}", new Object[] {className, fldValue}); Set<String> refClasses = parseField(searchString, fldValue, d.get(ArtifactInfo.NAMES)); if (!refClasses.isEmpty()) { ArtifactInfo ai = IndexUtils.constructArtifactInfo(d, context); if (ai != null) { ai.setRepository(context.getRepositoryId()); List<NBVersionInfo> version = NexusRepositoryIndexerImpl.convertToNBVersionInfo(Collections.singleton(ai)); if (!version.isEmpty()) { results.add(new ClassUsage(version.get(0), refClasses)); } } } } } finally { context.releaseIndexSearcher(searcher); } } }
Example #3
Source File: IndexQuerier.java From sling-whiteboard with Apache License 2.0 | 5 votes |
public IndexQuerier() throws PlexusContainerException, ComponentLookupException { DefaultContainerConfiguration config = new DefaultContainerConfiguration(); config.setClassPathScanning(PlexusConstants.SCANNING_INDEX); this.plexusContainer = new DefaultPlexusContainer(config); // lookup the indexer components from plexus this.indexer = plexusContainer.lookup(Indexer.class); this.indexUpdater = plexusContainer.lookup(IndexUpdater.class); // lookup wagon used to remotely fetch index this.httpWagon = plexusContainer.lookup(Wagon.class, "https"); }
Example #4
Source File: MavenRepositorySearch.java From archiva with Apache License 2.0 | 5 votes |
@Inject public MavenRepositorySearch( Indexer nexusIndexer, RepositoryRegistry repositoryRegistry, ProxyRegistry proxyRegistry, QueryCreator queryCreator ) { this.indexer = nexusIndexer; this.queryCreator = queryCreator; this.repositoryRegistry = repositoryRegistry; this.proxyRegistry = proxyRegistry; }