}
StringVersion version = new StringVersion(ai.version, ai.getArtifactVersion());
NexusNGArtifact versionHit = gaholder.getVersionHit(version);
if (versionHit == null) {
versionHit = new NexusNGArtifact();
versionHit.setGroupId(ai.groupId);
versionHit.setArtifactId(ai.artifactId);
versionHit.setVersion(ai.version);
versionHit.setHighlightedFragment(getMatchHighlightHtmlSnippet(ai));
gaholder.putVersionHit(version, versionHit);
gavcount++;
}
NexusNGArtifactHit repositoryHit = getRepositoryHit(versionHit, ai.repository);
if (repositoryHit == null) {
repositoryHit = new NexusNGArtifactHit();
repositoryHit.setRepositoryId(ai.repository);
versionHit.addArtifactHit(repositoryHit);
// we are adding the POM link "blindly", unless packaging is POM,
// since the it will be added below the "usual" way
if (!"pom".equals(ai.packaging)) {
repositoryHit.addArtifactLink(createNexusNGArtifactLink(request, ai.repository, ai.groupId,
ai.artifactId, ai.version, "pom", null));
}
}
repositoryHit.addArtifactLink(createNexusNGArtifactLink(request, ai.repository, ai.groupId,
ai.artifactId, ai.version, ai.fextension, ai.classifier));
tooManyResults = false;
}
// summary:
getSearchDiagnosticLogger().debug(
"Query terms \"" + terms + "\" (LQL \"" + iterator.getQuery() + "\") matched total of "
+ iterator.getTotalHitsCount() + " records, " + iterator.getTotalProcessedArtifactInfoCount()
+ " records were processed out of those, resulting in " + gahits.size()
+ " unique GA records. Lucene scored documents first=" + firstDocumentScore + ", last="
+ lastDocumentScore + ". Main processing loop took " + (System.currentTimeMillis() - startedAtMillis)
+ " ms.");
// expand if explicitly requested or if number of unique GAV matches is less than threshold
boolean expand = forceExpand || gavcount <= COLLAPSE_OVERRIDE_TRESHOLD;
SearchNGResponse response = new SearchNGResponse();
response.setTooManyResults(tooManyResults || iterator.getTotalHitsCount() + 1 >= LUCENE_HIT_LIMIT);
response.setCollapsed(!expand);
List<NexusNGArtifact> responseData = new ArrayList<NexusNGArtifact>();
LinkedHashSet<String> repositoryIds = new LinkedHashSet<String>();
for (GAHolder gahit : gahits.values()) {
if (expand) {
// expand, i.e. include all versions
for (NexusNGArtifact artifact : gahit.getOrderedVersionHits()) {
responseData.add(artifact);
setLatest(artifact, gahit.getLatestRelease(), gahit.getLatestSnapshot());
addRepositoryIds(repositoryIds, artifact);
}
}
else {
// collapse, i.e. only include latest version in each GA
NexusNGArtifact artifact = gahit.getLatestVersionHit();
setLatest(artifact, gahit.getLatestRelease(), gahit.getLatestSnapshot());
responseData.add(artifact);
addRepositoryIds(repositoryIds, artifact);
}
}