clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r1090260 - /incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/GraphIndexer.scala
Date Fri, 08 Apr 2011 14:18:40 GMT
Author: reto
Date: Fri Apr  8 14:18:40 2011
New Revision: 1090260

URL: http://svn.apache.org/viewvc?rev=1090260&view=rev
Log:
CLEREZZA-388: returning up to 200 matches

Modified:
    incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/GraphIndexer.scala

Modified: incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/GraphIndexer.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/GraphIndexer.scala?rev=1090260&r1=1090259&r2=1090260&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/GraphIndexer.scala
(original)
+++ incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/GraphIndexer.scala
Fri Apr  8 14:18:40 2011
@@ -60,6 +60,8 @@ class GraphIndexer(definitionGraph: Trip
 						baseGraph: TripleCollection, index: Directory, createNewIndex: Boolean)
 						extends ResourceFinder {
 
+	val maxHitsPerPage = 200;
+
   /**
    * Creates an in-memory index
    */
@@ -301,7 +303,15 @@ class GraphIndexer(definitionGraph: Trip
 			booleanQuery.add(c.query, BooleanClause.Occur.MUST)
 		}
 		val searcher = new IndexSearcher(index, true);
-		val hitsPerPage = 10
+		val testCollector = TopScoreDocCollector.create(1, true);
+		searcher.search(booleanQuery, testCollector)
+		val totalHits = testCollector.topDocs().totalHits;
+
+		val hitsPerPage = if (totalHits > maxHitsPerPage) {
+			maxHitsPerPage
+		} else {
+			totalHits
+		}
 		val collector = TopScoreDocCollector.create(hitsPerPage, true);
 		searcher.search(booleanQuery, collector)
 		val hits = collector.topDocs().scoreDocs;



Mime
View raw message