diff options
author | Maria Odea B. Ching <oching@apache.org> | 2008-07-10 07:47:38 +0000 |
---|---|---|
committer | Maria Odea B. Ching <oching@apache.org> | 2008-07-10 07:47:38 +0000 |
commit | 59313f36c3d3c4fc52b6f2b89a776a3c3b6b2c7a (patch) | |
tree | ed8241a1b46c16e36efc0036c1ec9d2624b97b51 /archiva-modules | |
parent | 2b2e21c61390fc0691f8ee0fa1296528d3f57aa2 (diff) | |
download | archiva-59313f36c3d3c4fc52b6f2b89a776a3c3b6b2c7a.tar.gz archiva-59313f36c3d3c4fc52b6f2b89a776a3c3b6b2c7a.zip |
[MRM-861]
-fix search results hits count
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@675469 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules')
4 files changed, 14 insertions, 7 deletions
diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/filecontent/FileContentRecord.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/filecontent/FileContentRecord.java index 7b1365b23..af039c8c7 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/filecontent/FileContentRecord.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/filecontent/FileContentRecord.java @@ -64,7 +64,7 @@ public class FileContentRecord public String getPrimaryKey() { - return filename; + return repositoryId + ":" + filename; } public int hashCode() diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearch.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearch.java index 3ff954795..469ff679b 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearch.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearch.java @@ -199,7 +199,7 @@ public class DefaultCrossRepositorySearch if ( offset < hitCount ) { // 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. if ( offset + i >= hitCount ) diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java index 3c7f5056d..d797c072c 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java @@ -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.SearchResultLimits; 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.PrincipalNotFoundException; +import org.apache.maven.archiva.security.UserRepositories; import org.codehaus.plexus.xwork.action.PlexusActionSupport; /** @@ -45,7 +48,7 @@ import org.codehaus.plexus.xwork.action.PlexusActionSupport; */ public class SearchAction extends PlexusActionSupport -{ +{ /** * Query string. */ @@ -101,7 +104,7 @@ public class SearchAction } results = crossRepoSearch.searchForTerm( getPrincipal(), selectedRepos, q, limits ); - + if ( results.isEmpty() ) { addActionError( "No results found" ); @@ -110,6 +113,10 @@ public class SearchAction 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?) /* I don't think that we should, as I expect us to utilize the 'score' system in lucene in diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/results.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/results.jsp index 3bda27b14..b2f984da3 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/results.jsp +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/results.jsp @@ -49,8 +49,8 @@ <%-- search was made from the indices --%> <c:when test="${databaseResults == null}"> - <c:set var="hitsNum">${fn:length(results.hits) + (currentPage * 31)}</c:set> - <p>Hits: ${hitsNum - 30} to ${hitsNum} of ${results.totalHits}</p> + <c:set var="hitsNum">${fn:length(results.hits) + (currentPage * results.limits.pageSize)}</c:set> + <p>Hits: ${(hitsNum - results.limits.pageSize) + 1} to ${hitsNum} of ${results.totalHits}</p> <c:choose> <c:when test="${empty results.hits}"> |