[MRM-861]

-fix search results hits count


git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@675469 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Maria Odea B. Ching 2008-07-10 07:47:38 +00:00
parent 2b2e21c613
commit 59313f36c3
4 changed files with 14 additions and 7 deletions

View File

@ -64,7 +64,7 @@ public class FileContentRecord
public String getPrimaryKey() public String getPrimaryKey()
{ {
return filename; return repositoryId + ":" + filename;
} }
public int hashCode() public int hashCode()

View File

@ -199,7 +199,7 @@ public class DefaultCrossRepositorySearch
if ( offset < hitCount ) if ( offset < hitCount )
{ {
// only process if the offset is within the hit count. // only process if the offset is within the hit count.
for ( int i = 0; i <= fetchCount; i++ ) for ( int i = 0; i < fetchCount; i++ )
{ {
// Stop fetching if we are past the total # of available hits. // Stop fetching if we are past the total # of available hits.
if ( offset + i >= hitCount ) if ( offset + i >= hitCount )

View File

@ -34,8 +34,11 @@ import org.apache.maven.archiva.indexer.RepositoryIndexSearchException;
import org.apache.maven.archiva.indexer.search.CrossRepositorySearch; import org.apache.maven.archiva.indexer.search.CrossRepositorySearch;
import org.apache.maven.archiva.indexer.search.SearchResultLimits; import org.apache.maven.archiva.indexer.search.SearchResultLimits;
import org.apache.maven.archiva.indexer.search.SearchResults; import org.apache.maven.archiva.indexer.search.SearchResults;
import org.apache.maven.archiva.security.*; import org.apache.maven.archiva.security.AccessDeniedException;
import org.apache.maven.archiva.security.ArchivaSecurityException;
import org.apache.maven.archiva.security.ArchivaXworkUser; import org.apache.maven.archiva.security.ArchivaXworkUser;
import org.apache.maven.archiva.security.PrincipalNotFoundException;
import org.apache.maven.archiva.security.UserRepositories;
import org.codehaus.plexus.xwork.action.PlexusActionSupport; import org.codehaus.plexus.xwork.action.PlexusActionSupport;
/** /**
@ -45,7 +48,7 @@ import org.codehaus.plexus.xwork.action.PlexusActionSupport;
*/ */
public class SearchAction public class SearchAction
extends PlexusActionSupport extends PlexusActionSupport
{ {
/** /**
* Query string. * Query string.
*/ */
@ -101,7 +104,7 @@ public class SearchAction
} }
results = crossRepoSearch.searchForTerm( getPrincipal(), selectedRepos, q, limits ); results = crossRepoSearch.searchForTerm( getPrincipal(), selectedRepos, q, limits );
if ( results.isEmpty() ) if ( results.isEmpty() )
{ {
addActionError( "No results found" ); addActionError( "No results found" );
@ -110,6 +113,10 @@ public class SearchAction
totalPages = results.getTotalHits() / limits.getPageSize(); totalPages = results.getTotalHits() / limits.getPageSize();
if( (results.getTotalHits() % limits.getPageSize()) != 0 )
{
totalPages = totalPages + 1;
}
// TODO: filter / combine the artifacts by version? (is that even possible with non-artifact hits?) // TODO: filter / combine the artifacts by version? (is that even possible with non-artifact hits?)
/* I don't think that we should, as I expect us to utilize the 'score' system in lucene in /* I don't think that we should, as I expect us to utilize the 'score' system in lucene in

View File

@ -49,8 +49,8 @@
<%-- search was made from the indices --%> <%-- search was made from the indices --%>
<c:when test="${databaseResults == null}"> <c:when test="${databaseResults == null}">
<c:set var="hitsNum">${fn:length(results.hits) + (currentPage * 31)}</c:set> <c:set var="hitsNum">${fn:length(results.hits) + (currentPage * results.limits.pageSize)}</c:set>
<p>Hits: ${hitsNum - 30} to ${hitsNum} of ${results.totalHits}</p> <p>Hits: ${(hitsNum - results.limits.pageSize) + 1} to ${hitsNum} of ${results.totalHits}</p>
<c:choose> <c:choose>
<c:when test="${empty results.hits}"> <c:when test="${empty results.hits}">