You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by kl...@apache.org on 2007/11/15 03:03:50 UTC

svn commit: r595184 - in /lucene/solr/trunk/src: java/org/apache/solr/handler/ java/org/apache/solr/util/ test/org/apache/solr/handler/

Author: klaas
Date: Wed Nov 14 18:03:49 2007
New Revision: 595184

URL: http://svn.apache.org/viewvc?rev=595184&view=rev
Log:
rename HiFrequencyDictionary to HighFrequencyDictionary, and add numDocs to spellcheck 
handler response so that docfreqs can be converted from counts to frequencies, should the 
client be so inclined.

Added:
    lucene/solr/trunk/src/java/org/apache/solr/util/HighFrequencyDictionary.java
      - copied, changed from r595180, lucene/solr/trunk/src/java/org/apache/solr/util/HiFrequencyDictionary.java
Removed:
    lucene/solr/trunk/src/java/org/apache/solr/util/HiFrequencyDictionary.java
Modified:
    lucene/solr/trunk/src/java/org/apache/solr/handler/SpellCheckerRequestHandler.java
    lucene/solr/trunk/src/test/org/apache/solr/handler/SpellCheckerRequestHandlerTest.java

Modified: lucene/solr/trunk/src/java/org/apache/solr/handler/SpellCheckerRequestHandler.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/handler/SpellCheckerRequestHandler.java?rev=595184&r1=595183&r2=595184&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/handler/SpellCheckerRequestHandler.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/handler/SpellCheckerRequestHandler.java Wed Nov 14 18:03:49 2007
@@ -33,7 +33,7 @@
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.common.util.SimpleOrderedMap;
 import org.apache.solr.core.SolrCore;
-import org.apache.solr.util.HiFrequencyDictionary;
+import org.apache.solr.util.HighFrequencyDictionary;
 
 import java.io.File;
 import java.io.IOException;
@@ -305,7 +305,7 @@
       throw new RuntimeException("'Extended results' must be a valid boolean", e);
     }
 
-   // when searching for more popular, a non null index-reader and
+    // when searching for more popular, a non null index-reader and
     // restricted-field are required
     if (onlyMorePopular || extendedResults) {
       indexReader = req.getSearcher().getReader();
@@ -314,6 +314,8 @@
 
     if (extendedResults) {
 
+      rsp.add("numDocs", indexReader.numDocs());
+
       SimpleOrderedMap<Object> results = new SimpleOrderedMap<Object>();
       String[] wordz = words.split(" ");
       for (String word : wordz)
@@ -371,7 +373,7 @@
     }
 
     IndexReader indexReader = req.getSearcher().getReader();
-    Dictionary dictionary = new HiFrequencyDictionary(indexReader, termSourceField, threshold);
+    Dictionary dictionary = new HighFrequencyDictionary(indexReader, termSourceField, threshold);
     spellChecker.clearIndex();
     spellChecker.indexDictionary(dictionary);
     reopen();

Copied: lucene/solr/trunk/src/java/org/apache/solr/util/HighFrequencyDictionary.java (from r595180, lucene/solr/trunk/src/java/org/apache/solr/util/HiFrequencyDictionary.java)
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/util/HighFrequencyDictionary.java?p2=lucene/solr/trunk/src/java/org/apache/solr/util/HighFrequencyDictionary.java&p1=lucene/solr/trunk/src/java/org/apache/solr/util/HiFrequencyDictionary.java&r1=595180&r2=595184&rev=595184&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/util/HiFrequencyDictionary.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/util/HighFrequencyDictionary.java Wed Nov 14 18:03:49 2007
@@ -42,29 +42,29 @@
  * @author Nicolas Maisonneuve
  * @author Christian Mallwitz
  */
-public class HiFrequencyDictionary implements Dictionary {
+public class HighFrequencyDictionary implements Dictionary {
   private IndexReader reader;
   private String field;
   private float thresh;
 
-  public HiFrequencyDictionary(IndexReader reader, String field, float thresh) {
+  public HighFrequencyDictionary(IndexReader reader, String field, float thresh) {
     this.reader = reader;
     this.field = field.intern();
     this.thresh = thresh;
   }
 
   public final Iterator getWordsIterator() {
-    return new HiFrequencyIterator();
+    return new HighFrequencyIterator();
   }
 
 
-  final class HiFrequencyIterator implements Iterator {
+  final class HighFrequencyIterator implements Iterator {
     private TermEnum termEnum;
     private Term actualTerm;
     private boolean hasNextCalled;
     private int minNumDocs;
 
-    HiFrequencyIterator() {
+    HighFrequencyIterator() {
       try {
         termEnum = reader.terms(new Term(field, ""));
         minNumDocs = (int)(thresh * (float)reader.numDocs());

Modified: lucene/solr/trunk/src/test/org/apache/solr/handler/SpellCheckerRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/handler/SpellCheckerRequestHandlerTest.java?rev=595184&r1=595183&r2=595184&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/handler/SpellCheckerRequestHandlerTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/handler/SpellCheckerRequestHandlerTest.java Wed Nov 14 18:03:49 2007
@@ -228,6 +228,7 @@
     
     assertQ("Failed to spell check",
             req("cat")
+            ,"//int[@name='numDocs'][.=10]"
             ,"//lst[@name='cat']"
             ,"//lst[@name='cat']/int[@name='frequency'][.>0]"
             ,"//lst[@name='cat']/lst[@name='suggestions' and count(lst)=0]"
@@ -256,6 +257,7 @@
     lrf.args.put("sp.query.accuracy",".2");
     assertQ("Failed to spell check",
             req("cat")
+            ,"//int[@name='numDocs'][.=10]"
             ,"//lst[@name='cat']"
             ,"//lst[@name='cat']/int[@name='frequency'][.>0]"
             ,"//lst[@name='cat']/lst[@name='suggestions']/lst[@name='cart']/int[@name='frequency'][.>0]"
@@ -277,6 +279,7 @@
     /* The following is the generated XML response for the next query with three words:
       <response>
         <responseHeader><status>0</status><QTime>0</QTime></responseHeader>
+        <int name="numDocs">10</int>
         <lst name="result">
           <lst name="cat">
             <int name="frequency">1</int>
@@ -351,6 +354,7 @@
     
     assertQ("Failed to spell check",
             req("coat")
+            ,"//int[@name='numDocs'][.=10]"
             ,"//lst[@name='coat']"
             ,"//lst[@name='coat']/int[@name='frequency'][.=0]"
             ,"//lst[@name='coat']/lst[@name='suggestions' and count(lst)=0]"
@@ -383,6 +387,7 @@
     lrf.args.put("sp.query.accuracy",".2");
     assertQ("Failed to spell check",
         req("cet cert corp")
+        ,"//int[@name='numDocs'][.=10]"
         ,"//lst[@name='cet']"
         ,"//lst[@name='cet']/int[@name='frequency'][.=0]"
         ,"//lst[@name='cet']/lst[@name='suggestions']/lst[1]"