You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2010/12/06 01:47:28 UTC

svn commit: r1042501 [12/13] - in /lucene/dev/branches/docvalues: ./ lucene/ lucene/contrib/ lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/ lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ lucene/...

Modified: lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java (original)
+++ lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java Mon Dec  6 00:47:16 2010
@@ -314,9 +314,10 @@ public class DocBuilder {
     Iterator<Map<String, Object>> iter = deletedKeys.iterator();
     while (iter.hasNext()) {
       Map<String, Object> map = iter.next();
-      Object key = map.get(root.getPk());
+      String keyName = root.isDocRoot ? root.getPk() : root.getSchemaPk();
+      Object key = map.get(keyName);
       if(key == null) {
-        LOG.warn("no key was available for deleteted pk query");
+        LOG.warn("no key was available for deleteted pk query. keyName = " + keyName);
         continue;
       }
       writer.deleteDoc(key);
@@ -607,7 +608,8 @@ public class DocBuilder {
           if (entity.entities != null) {
             vr.addNamespace(entity.name, arow);
             for (DataConfig.Entity child : entity.entities) {
-              buildDocument(vr, doc, null, child, false, ctx);
+              buildDocument(vr, doc,
+                  child.isDocRoot ? pk : null, child, false, ctx);
             }
             vr.removeNamespace(entity.name);
           }
@@ -910,8 +912,9 @@ public class DocBuilder {
     if (entity.isDocRoot)
       deletedRows.addAll(deletedSet);
 
-    return entity.isDocRoot ? myModifiedPks : new HashSet<Map<String, Object>>(
-            parentKeyList);
+    // Do not use entity.isDocRoot here because one of descendant entities may set rootEntity="true"
+    return entity.parentEntity == null ?
+        myModifiedPks : new HashSet<Map<String, Object>>(parentKeyList);
   }
 
   private void getModifiedParentRows(VariableResolverImpl resolver,

Modified: lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta.java (original)
+++ lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta.java Mon Dec  6 00:47:16 2010
@@ -40,6 +40,23 @@ public class TestSqlEntityProcessorDelta
 
   private static final String DELETED_PK_QUERY = "select id from x where last_modified > NOW AND deleted='true'";
 
+  private static final String dataConfig_delta =
+    "<dataConfig>" +
+    "  <dataSource  type=\"MockDataSource\"/>\n" +
+    "  <document>\n" +
+    "    <entity name=\"x\" transformer=\"TemplateTransformer\"" +
+    "            query=\"" + FULLIMPORT_QUERY + "\"" +
+    "            deletedPkQuery=\"" + DELETED_PK_QUERY + "\"" +
+    "            deltaImportQuery=\"select * from x where id='${dih.delta.id}'\"" +
+    "            deltaQuery=\"" + DELTA_QUERY + "\">\n" +
+    "      <field column=\"id\" name=\"id\"/>\n" +
+    "      <entity name=\"y\" query=\"select * from y where y.A='${x.id}'\">\n" +
+    "        <field column=\"desc\" />\n" +
+    "      </entity>\n" +
+    "    </entity>\n" +
+    "  </document>\n" +
+    "</dataConfig>\n";
+
   @BeforeClass
   public static void beforeClass() throws Exception {
     initCore("dataimport-solrconfig.xml", "dataimport-schema.xml");
@@ -115,8 +132,8 @@ public class TestSqlEntityProcessorDelta
 
     List childRow = new ArrayList();
     childRow.add(createMap("desc", "hello"));
-    MockDataSource.setIterator("select * from y where y.A='1'", childRow
-        .iterator());
+    MockDataSource.setIterator("select * from y where y.A='1'",
+        childRow.iterator());
 
     runDeltaImport(dataConfig_delta);
 
@@ -270,18 +287,4 @@ public class TestSqlEntityProcessorDelta
     assertQ(req("desc:hello"), "//*[@numFound='0']");
     assertQ(req("desc:goodbye"), "//*[@numFound='1']");
   }
-
-  private static String dataConfig_delta = "<dataConfig><dataSource  type=\"MockDataSource\"/>\n"
-    + "       <document>\n"
-    + "               <entity name=\"x\" transformer=\"TemplateTransformer\""
-    + "				query=\"" + FULLIMPORT_QUERY + "\""
-    + "				deletedPkQuery=\"" + DELETED_PK_QUERY + "\""
-    + " 				deltaImportQuery=\"select * from x where id='${dataimporter.delta.id}'\""
-    + "				deltaQuery=\"" + DELTA_QUERY + "\">\n"
-    + "                       <field column=\"id\" name=\"id\"/>\n"
-    + "                       <entity name=\"y\" query=\"select * from y where y.A='${x.id}'\">\n"
-    + "                               <field column=\"desc\" />\n"
-    + "                       </entity>\n" + "               </entity>\n"
-    + "       </document>\n" + "</dataConfig>\n";
-
 }

Modified: lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta2.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta2.java (original)
+++ lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta2.java Mon Dec  6 00:47:16 2010
@@ -40,6 +40,23 @@ public class TestSqlEntityProcessorDelta
 
   private static final String DELETED_PK_QUERY = "select id from x where last_modified > NOW AND deleted='true'";
 
+  private static final String dataConfig_delta2 =
+    "<dataConfig>" +
+    "  <dataSource  type=\"MockDataSource\"/>\n" +
+    "  <document>\n" +
+    "    <entity name=\"x\" transformer=\"TemplateTransformer\"" +
+    "            query=\"" + FULLIMPORT_QUERY + "\"" +
+    "            deletedPkQuery=\"" + DELETED_PK_QUERY + "\"" +
+    "            deltaImportQuery=\"select * from x where id='${dih.delta.id}'\"" +
+    "            deltaQuery=\"" + DELTA_QUERY + "\">\n" +
+    "      <field column=\"tmpid\" template=\"prefix-${x.id}\" name=\"solr_id\"/>\n" +
+    "      <entity name=\"y\" query=\"select * from y where y.A='${x.id}'\">\n" +
+    "        <field column=\"desc\" />\n" +
+    "      </entity>\n" +
+    "    </entity>\n" +
+    "  </document>\n" +
+    "</dataConfig>\n";
+
   @BeforeClass
   public static void beforeClass() throws Exception {
     initCore("dataimport-solrconfig.xml", "dataimport-solr_id-schema.xml");
@@ -266,18 +283,4 @@ public class TestSqlEntityProcessorDelta
     assertQ(req("desc:hello"), "//*[@numFound='0']");
     assertQ(req("desc:goodbye"), "//*[@numFound='1']");
   }
-
-  private static String dataConfig_delta2 = "<dataConfig><dataSource  type=\"MockDataSource\"/>\n"
-    + "       <document>\n"
-    + "               <entity name=\"x\" transformer=\"TemplateTransformer\""
-    + "				query=\"" + FULLIMPORT_QUERY + "\""
-    + "				deletedPkQuery=\"" + DELETED_PK_QUERY + "\""
-    + " 				deltaImportQuery=\"select * from x where id='${dataimporter.delta.id}'\""
-    + "				deltaQuery=\"" + DELTA_QUERY + "\">\n"
-    + "                       <field column=\"tmpid\" template=\"prefix-${x.id}\" name=\"solr_id\"/>\n"
-    + "                       <entity name=\"y\" query=\"select * from y where y.A='${x.id}'\">\n"
-    + "                               <field column=\"desc\" />\n"
-    + "                       </entity>\n" + "               </entity>\n"
-    + "       </document>\n" + "</dataConfig>\n";
-
 }

Modified: lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/test/resources/solr/conf/contentstream-solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/test/resources/solr/conf/contentstream-solrconfig.xml?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/test/resources/solr/conf/contentstream-solrconfig.xml (original)
+++ lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/test/resources/solr/conf/contentstream-solrconfig.xml Mon Dec  6 00:47:16 2010
@@ -17,6 +17,7 @@
 -->
 
 <config>
+  <luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>
   <!-- Set this to 'false' if you want solr to continue working after it has 
        encountered an severe configuration error.  In a production environment, 
        you may want solr to keep working even if one handler is mis-configured.

Modified: lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/test/resources/solr/conf/dataimport-nodatasource-solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/test/resources/solr/conf/dataimport-nodatasource-solrconfig.xml?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/test/resources/solr/conf/dataimport-nodatasource-solrconfig.xml (original)
+++ lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/test/resources/solr/conf/dataimport-nodatasource-solrconfig.xml Mon Dec  6 00:47:16 2010
@@ -17,6 +17,7 @@
 -->
 
 <config>
+  <luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>
   <!-- Set this to 'false' if you want solr to continue working after it has 
        encountered an severe configuration error.  In a production environment, 
        you may want solr to keep working even if one handler is mis-configured.

Modified: lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/test/resources/solr/conf/dataimport-solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/test/resources/solr/conf/dataimport-solrconfig.xml?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/test/resources/solr/conf/dataimport-solrconfig.xml (original)
+++ lucene/dev/branches/docvalues/solr/contrib/dataimporthandler/src/test/resources/solr/conf/dataimport-solrconfig.xml Mon Dec  6 00:47:16 2010
@@ -17,6 +17,7 @@
 -->
 
 <config>
+  <luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>
   <!-- Set this to 'false' if you want solr to continue working after it has 
        encountered an severe configuration error.  In a production environment, 
        you may want solr to keep working even if one handler is mis-configured.

Modified: lucene/dev/branches/docvalues/solr/contrib/extraction/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/contrib/extraction/CHANGES.txt?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/contrib/extraction/CHANGES.txt (original)
+++ lucene/dev/branches/docvalues/solr/contrib/extraction/CHANGES.txt Mon Dec  6 00:47:16 2010
@@ -20,13 +20,13 @@ to your Solr Home lib directory.  See ht
  Tika Dependency
  ---------------
 
-Current Version: Tika 0.8-SNAPSHOT (rev 942725)
+Current Version: Tika 0.8 (released 11/07/2010)
 
 $Id:$
 
-================== Release 1.5-dev ==================
-
+================== Release 3.1-dev ==================
 
+* Upgraded to Tika 0.8 and changed deprecated parse call
 
 * SOLR-1756: The date.format setting causes ClassCastException when enabled and the config code that
   parses this setting does not properly use the same iterator instance. (Christoph Brill, Mark Miller)

Modified: lucene/dev/branches/docvalues/solr/contrib/extraction/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/contrib/extraction/build.xml?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/contrib/extraction/build.xml (original)
+++ lucene/dev/branches/docvalues/solr/contrib/extraction/build.xml Mon Dec  6 00:47:16 2010
@@ -117,6 +117,9 @@
       <sysproperty key="tests.multiplier" value="${tests.multiplier}"/>
       <sysproperty key="tests.iter" value="${tests.iter}"/>
       <sysproperty key="tests.seed" value="${tests.seed}"/>
+      <sysproperty key="tests.verbose" value="${tests.verbose}"/>
+      <!-- set whether or not nightly tests should run -->
+      <sysproperty key="tests.nightly" value="${tests.nightly}"/>
       <sysproperty key="jetty.testMode" value="1"/>
       <sysproperty key="tempDir" file="${tempDir}"/>
       <sysproperty key="testmethod" value="${testmethod}"/>

Modified: lucene/dev/branches/docvalues/solr/contrib/extraction/src/main/java/org/apache/solr/handler/extraction/ExtractingDocumentLoader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/contrib/extraction/src/main/java/org/apache/solr/handler/extraction/ExtractingDocumentLoader.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/contrib/extraction/src/main/java/org/apache/solr/handler/extraction/ExtractingDocumentLoader.java (original)
+++ lucene/dev/branches/docvalues/solr/contrib/extraction/src/main/java/org/apache/solr/handler/extraction/ExtractingDocumentLoader.java Mon Dec  6 00:47:16 2010
@@ -31,6 +31,7 @@ import org.apache.solr.handler.ContentSt
 import org.apache.tika.config.TikaConfig;
 import org.apache.tika.metadata.Metadata;
 import org.apache.tika.parser.AutoDetectParser;
+import org.apache.tika.parser.ParseContext;
 import org.apache.tika.parser.Parser;
 import org.apache.tika.sax.XHTMLContentHandler;
 import org.apache.tika.sax.xpath.Matcher;
@@ -190,7 +191,8 @@ public class ExtractingDocumentLoader ex
         } //else leave it as is
 
         //potentially use a wrapper handler for parsing, but we still need the SolrContentHandler for getting the document.
-        parser.parse(inputStream, parsingHandler, metadata);
+        ParseContext context = new ParseContext();//TODO: should we design a way to pass in parse context?
+        parser.parse(inputStream, parsingHandler, metadata, context);
         if (extractOnly == false) {
           addDoc(handler);
         } else {

Modified: lucene/dev/branches/docvalues/solr/contrib/extraction/src/test/java/org/apache/solr/handler/ExtractingRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/contrib/extraction/src/test/java/org/apache/solr/handler/ExtractingRequestHandlerTest.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/contrib/extraction/src/test/java/org/apache/solr/handler/ExtractingRequestHandlerTest.java (original)
+++ lucene/dev/branches/docvalues/solr/contrib/extraction/src/test/java/org/apache/solr/handler/ExtractingRequestHandlerTest.java Mon Dec  6 00:47:16 2010
@@ -58,13 +58,15 @@ public class ExtractingRequestHandlerTes
 
   @Test
   public void testExtraction() throws Exception {
-    // broken for turkish: https://issues.apache.org/jira/browse/SOLR-2088
-    String defLang = Locale.getDefault().getLanguage();
-    assumeFalse("Known bugs under Turkish locale: https://issues.apache.org/jira/browse/SOLR-2088", defLang.equals("tr") || defLang.equals("az"));
     ExtractingRequestHandler handler = (ExtractingRequestHandler) h.getCore().getRequestHandler("/update/extract");
     assertTrue("handler is null and it shouldn't be", handler != null);
-    loadLocal("solr-word.pdf", "fmap.created", "extractedDate", "fmap.producer", "extractedProducer",
+    loadLocal("solr-word.pdf",
+            "fmap.created", "extractedDate",
+            "fmap.producer", "extractedProducer",
             "fmap.creator", "extractedCreator", "fmap.Keywords", "extractedKeywords",
+            "fmap.Creation-Date", "extractedDate",
+            "fmap.AAPL:Keywords", "ignored_a",
+            "fmap.xmpTPg:NPages", "ignored_a",
             "fmap.Author", "extractedAuthor",
             "fmap.content", "extractedContent",
            "literal.id", "one",
@@ -146,6 +148,7 @@ public class ExtractingRequestHandlerTes
 
   }
 
+
   @Test
   public void testDefaultField() throws Exception {
     ExtractingRequestHandler handler = (ExtractingRequestHandler) h.getCore().getRequestHandler("/update/extract");
@@ -349,6 +352,9 @@ public class ExtractingRequestHandlerTes
 
     loadLocal("arabic.pdf", "fmap.created", "extractedDate", "fmap.producer", "extractedProducer",
         "fmap.creator", "extractedCreator", "fmap.Keywords", "extractedKeywords",
+        "fmap.Creation-Date", "extractedDate",
+        "fmap.AAPL:Keywords", "ignored_a",
+        "fmap.xmpTPg:NPages", "ignored_a",
         "fmap.Author", "extractedAuthor",
         "fmap.content", "wdf_nocase",
        "literal.id", "one",

Modified: lucene/dev/branches/docvalues/solr/contrib/extraction/src/test/resources/solr/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/contrib/extraction/src/test/resources/solr/conf/schema.xml?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/contrib/extraction/src/test/resources/solr/conf/schema.xml (original)
+++ lucene/dev/branches/docvalues/solr/contrib/extraction/src/test/resources/solr/conf/schema.xml Mon Dec  6 00:47:16 2010
@@ -117,8 +117,8 @@
       -->
     <fieldtype name="text" class="solr.TextField">
       <analyzer>
-        <tokenizer class="solr.StandardTokenizerFactory"/>
-        <filter class="solr.StandardFilterFactory"/>
+        <tokenizer class="solr.ClassicTokenizerFactory"/>
+        <filter class="solr.ClassicFilterFactory"/>
         <filter class="solr.LowerCaseFilterFactory"/>
         <filter class="solr.StopFilterFactory"/>
         <filter class="solr.PorterStemFilterFactory"/>
@@ -133,7 +133,7 @@
     <fieldtype name="teststop" class="solr.TextField">
        <analyzer>
         <tokenizer class="solr.LowerCaseTokenizerFactory"/>
-        <filter class="solr.StandardFilterFactory"/>
+        <filter class="solr.ClassicFilterFactory"/>
         <filter class="solr.StopFilterFactory" words="stopwords.txt"/>
       </analyzer>
     </fieldtype>
@@ -168,14 +168,14 @@
     </fieldtype>
     <fieldtype name="standardtokfilt" class="solr.TextField">
       <analyzer>
-        <tokenizer class="solr.StandardTokenizerFactory"/>
-        <filter class="solr.StandardFilterFactory"/>
+        <tokenizer class="solr.ClassicTokenizerFactory"/>
+        <filter class="solr.ClassicFilterFactory"/>
       </analyzer>
     </fieldtype>
     <fieldtype name="standardfilt" class="solr.TextField">
       <analyzer>
         <tokenizer class="solr.WhitespaceTokenizerFactory"/>
-        <filter class="solr.StandardFilterFactory"/>
+        <filter class="solr.ClassicFilterFactory"/>
       </analyzer>
     </fieldtype>
     <fieldtype name="lowerfilt" class="solr.TextField">

Modified: lucene/dev/branches/docvalues/solr/contrib/extraction/src/test/resources/solr/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/contrib/extraction/src/test/resources/solr/conf/solrconfig.xml?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/contrib/extraction/src/test/resources/solr/conf/solrconfig.xml (original)
+++ lucene/dev/branches/docvalues/solr/contrib/extraction/src/test/resources/solr/conf/solrconfig.xml Mon Dec  6 00:47:16 2010
@@ -23,7 +23,7 @@
   -->
 
 <config>
-
+  <luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>
   <jmx />
 
   <!-- Used to specify an alternate directory to hold all index data.

Modified: lucene/dev/branches/docvalues/solr/example/multicore/core0/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/example/multicore/core0/conf/solrconfig.xml?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/example/multicore/core0/conf/solrconfig.xml (original)
+++ lucene/dev/branches/docvalues/solr/example/multicore/core0/conf/solrconfig.xml Mon Dec  6 00:47:16 2010
@@ -21,7 +21,7 @@
  It is *not* a good example to work from. 
 -->
 <config>
-
+  <luceneMatchVersion>LUCENE_40</luceneMatchVersion>
   <!--  The DirectoryFactory to use for indexes.
         solr.StandardDirectoryFactory, the default, is filesystem based.
         solr.RAMDirectoryFactory is memory based, not persistent, and doesn't work with replication. -->

Modified: lucene/dev/branches/docvalues/solr/example/multicore/core1/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/example/multicore/core1/conf/solrconfig.xml?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/example/multicore/core1/conf/solrconfig.xml (original)
+++ lucene/dev/branches/docvalues/solr/example/multicore/core1/conf/solrconfig.xml Mon Dec  6 00:47:16 2010
@@ -21,6 +21,7 @@
  It is *not* a good example to work from. 
 -->
 <config>
+  <luceneMatchVersion>LUCENE_40</luceneMatchVersion>
   <!--  The DirectoryFactory to use for indexes.
         solr.StandardDirectoryFactory, the default, is filesystem based.
         solr.RAMDirectoryFactory is memory based, not persistent, and doesn't work with replication. -->

Modified: lucene/dev/branches/docvalues/solr/src/common/org/apache/solr/common/params/GroupParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/common/org/apache/solr/common/params/GroupParams.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/common/org/apache/solr/common/params/GroupParams.java (original)
+++ lucene/dev/branches/docvalues/solr/src/common/org/apache/solr/common/params/GroupParams.java Mon Dec  6 00:47:16 2010
@@ -32,5 +32,11 @@ public interface GroupParams {
   public static final String GROUP_LIMIT = GROUP + ".limit";
   /** the offset for the doclist of each group */
   public static final String GROUP_OFFSET = GROUP + ".offset";
+
+  /** treat the first group result as the main result.  true/false */
+  public static final String GROUP_MAIN = GROUP + ".main";
+
+  /** treat the first group result as the main result.  true/false */
+  public static final String GROUP_FORMAT = GROUP + ".format";
 }
 

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/analysis/GreekLowerCaseFilterFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/analysis/GreekLowerCaseFilterFactory.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/analysis/GreekLowerCaseFilterFactory.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/analysis/GreekLowerCaseFilterFactory.java Mon Dec  6 00:47:16 2010
@@ -41,7 +41,7 @@ public class GreekLowerCaseFilterFactory
   }
 
   public GreekLowerCaseFilter create(TokenStream in) {
-    return new GreekLowerCaseFilter(in);
+    return new GreekLowerCaseFilter(luceneMatchVersion, in);
   }
 }
 

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/core/SolrConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/core/SolrConfig.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/core/SolrConfig.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/core/SolrConfig.java Mon Dec  6 00:47:16 2010
@@ -138,7 +138,7 @@ public class SolrConfig extends Config {
     reopenReaders = getBool("mainIndex/reopenReaders", true);
     
     booleanQueryMaxClauseCount = getInt("query/maxBooleanClauses", BooleanQuery.getMaxClauseCount());
-    luceneMatchVersion = getLuceneVersion("luceneMatchVersion", Version.LUCENE_24);
+    luceneMatchVersion = getLuceneVersion("luceneMatchVersion");
     log.info("Using Lucene MatchVersion: " + luceneMatchVersion);
 
     filtOptEnabled = getBool("query/boolTofilterOptimizer/@enabled", false);

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/core/SolrDeletionPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/core/SolrDeletionPolicy.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/core/SolrDeletionPolicy.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/core/SolrDeletionPolicy.java Mon Dec  6 00:47:16 2010
@@ -81,7 +81,7 @@ public class SolrDeletionPolicy implemen
 
       if (dir instanceof FSDirectory) {
         FSDirectory fsd = (FSDirectory) dir;
-        sb.append("dir=").append(fsd.getFile());
+        sb.append("dir=").append(fsd.getDirectory());
       } else {
         sb.append("dir=").append(dir);
       }
@@ -183,7 +183,7 @@ public class SolrDeletionPolicy implemen
     // be the same, regardless of the Directory instance.
     if (dir instanceof FSDirectory) {
       FSDirectory fsd = (FSDirectory) dir;
-      File fdir = fsd.getFile();
+      File fdir = fsd.getDirectory();
       sb.append(fdir.getPath());
     } else {
       sb.append(dir);

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/handler/component/QueryComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/handler/component/QueryComponent.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/handler/component/QueryComponent.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/handler/component/QueryComponent.java Mon Dec  6 00:47:16 2010
@@ -306,6 +306,9 @@ public class QueryComponent extends Sear
         String[] funcs = params.getParams(GroupParams.GROUP_FUNC);
         String[] queries = params.getParams(GroupParams.GROUP_QUERY);
         String groupSortStr = params.get(GroupParams.GROUP_SORT);
+        boolean main = params.getBool(GroupParams.GROUP_MAIN, false);
+        String format = params.get(GroupParams.GROUP_FORMAT);
+        Grouping.Format defaultFormat = "simple".equals(format) ? Grouping.Format.Simple : Grouping.Format.Grouped; 
 
         // groupSort defaults to sort
         Sort groupSort = groupSortStr == null ? cmd.getSort() : QueryParsing.parseSort(groupSortStr, req);
@@ -344,6 +347,17 @@ public class QueryComponent extends Sear
             gc.groupOffset = groupOffsetDefault;
             gc.offset = cmd.getOffset();
             gc.sort = cmd.getSort();
+            gc.format = defaultFormat;
+
+            if (main) {
+              gc.main = true;
+              gc.format = Grouping.Format.Simple;
+              main = false;
+            }
+
+            if (gc.format == Grouping.Format.Simple) {
+              gc.groupOffset = 0;  // doesn't make sense
+            }
 
             grouping.add(gc);
           }
@@ -361,6 +375,22 @@ public class QueryComponent extends Sear
             gc.docsPerGroup = docsPerGroupDefault;
             gc.groupOffset = groupOffsetDefault;
 
+            // these two params will only be used if this is for the main result set
+            gc.offset = cmd.getOffset();
+            gc.numGroups = limitDefault;
+
+            gc.format = defaultFormat;            
+
+            if (main) {
+              gc.main = true;
+              gc.format = Grouping.Format.Simple;
+              main = false;
+            }
+            if (gc.format == Grouping.Format.Simple) {
+              gc.docsPerGroup = gc.numGroups;  // doesn't make sense to limit to one
+              gc.groupOffset = gc.offset;
+            }
+
             grouping.add(gc);
           }
         }
@@ -376,6 +406,12 @@ public class QueryComponent extends Sear
         rb.setResult( result );
         rsp.add("grouped", result.groupedResults);
         // TODO: get "hits" a different way to log
+
+        if (grouping.mainResult != null) {
+          rsp.add("response",grouping.mainResult);
+          rsp.getToLog().add("hits", grouping.mainResult.matches());
+        }
+
         return;
 
       } catch (ParseException e) {

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/handler/component/SpellCheckComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/handler/component/SpellCheckComponent.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/handler/component/SpellCheckComponent.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/handler/component/SpellCheckComponent.java Mon Dec  6 00:47:16 2010
@@ -640,7 +640,7 @@ public class SpellCheckComponent extends
         IndexSchema schema = core.getSchema();
         String fieldTypeName = (String) initParams.get("queryAnalyzerFieldType");
         FieldType fieldType = schema.getFieldTypes().get(fieldTypeName);
-        Analyzer analyzer = fieldType == null ? new WhitespaceAnalyzer()
+        Analyzer analyzer = fieldType == null ? new WhitespaceAnalyzer(core.getSolrConfig().luceneMatchVersion)
                 : fieldType.getQueryAnalyzer();
         //TODO: There's got to be a better way!  Where's Spring when you need it?
         queryConverter.setAnalyzer(analyzer);

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/response/BaseResponseWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/response/BaseResponseWriter.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/response/BaseResponseWriter.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/response/BaseResponseWriter.java Mon Dec  6 00:47:16 2010
@@ -115,7 +115,6 @@ public abstract class BaseResponseWriter
             }
             responseWriter.writeDoc(sdoc);
           }
-          responseWriter.end();
         } else {
           ArrayList<SolrDocument> list = new ArrayList<SolrDocument>(docList
               .size());

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/BinaryField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/BinaryField.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/BinaryField.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/BinaryField.java Mon Dec  6 00:47:16 2010
@@ -79,8 +79,7 @@ public class BinaryField extends FieldTy
       len = buf.length;
     }
 
-    Field f = new Field(field.getName(), buf, offset, len,
-            getFieldStore(field, null));
+    Field f = new Field(field.getName(), buf, offset, len);
     f.setBoost(boost);
     return f;
   }

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/FieldType.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/FieldType.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/FieldType.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/FieldType.java Mon Dec  6 00:47:16 2010
@@ -512,7 +512,8 @@ public abstract class FieldType extends 
    */
   @Deprecated
   public ValueSource getValueSource(SchemaField field) {
-    return new OrdFieldSource(field.name);
+    // return new OrdFieldSource(field.name);
+    return new StrFieldSource(field.name);
   }
 
   /**

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/SortableDoubleField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/SortableDoubleField.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/SortableDoubleField.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/SortableDoubleField.java Mon Dec  6 00:47:16 2010
@@ -107,6 +107,8 @@ class SortableDoubleFieldSource extends 
     final double def = defVal;
 
     return new StringIndexDocValues(this, reader, field) {
+      private final BytesRef spare = new BytesRef();
+
       protected String toTerm(String readableValue) {
         return NumberUtils.double2sortableStr(readableValue);
       }
@@ -125,7 +127,7 @@ class SortableDoubleFieldSource extends 
 
       public double doubleVal(int doc) {
         int ord=termsIndex.getOrd(doc);
-        return ord==0 ? def  : NumberUtils.SortableStr2double(termsIndex.lookup(ord, new BytesRef()));
+        return ord==0 ? def  : NumberUtils.SortableStr2double(termsIndex.lookup(ord, spare));
       }
 
       public String strVal(int doc) {
@@ -148,7 +150,14 @@ class SortableDoubleFieldSource extends 
 
           @Override
           public void fillValue(int doc) {
-            mval.value = doubleVal(doc);
+            int ord=termsIndex.getOrd(doc);
+            if (ord == 0) {
+              mval.value = def;
+              mval.exists = false;
+            } else {
+              mval.value = NumberUtils.SortableStr2double(termsIndex.lookup(ord, spare));
+              mval.exists = true;
+            }
           }
         };
       }

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/SortableFloatField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/SortableFloatField.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/SortableFloatField.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/SortableFloatField.java Mon Dec  6 00:47:16 2010
@@ -107,13 +107,15 @@ class SortableFloatFieldSource extends F
     final float def = defVal;
 
     return new StringIndexDocValues(this, reader, field) {
+      private final BytesRef spare = new BytesRef();
+
       protected String toTerm(String readableValue) {
         return NumberUtils.float2sortableStr(readableValue);
       }
 
       public float floatVal(int doc) {
         int ord=termsIndex.getOrd(doc);
-        return ord==0 ? def  : NumberUtils.SortableStr2float(termsIndex.lookup(ord, new BytesRef()));
+        return ord==0 ? def  : NumberUtils.SortableStr2float(termsIndex.lookup(ord, spare));
       }
 
       public int intVal(int doc) {
@@ -148,7 +150,14 @@ class SortableFloatFieldSource extends F
 
           @Override
           public void fillValue(int doc) {
-            mval.value = floatVal(doc);
+            int ord=termsIndex.getOrd(doc);
+            if (ord == 0) {
+              mval.value = def;
+              mval.exists = false;
+            } else {
+              mval.value = NumberUtils.SortableStr2float(termsIndex.lookup(ord, spare));
+              mval.exists = true;
+            }
           }
         };
       }

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/SortableIntField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/SortableIntField.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/SortableIntField.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/SortableIntField.java Mon Dec  6 00:47:16 2010
@@ -111,6 +111,8 @@ class SortableIntFieldSource extends Fie
     final int def = defVal;
 
     return new StringIndexDocValues(this, reader, field) {
+      private final BytesRef spare = new BytesRef();
+
       protected String toTerm(String readableValue) {
         return NumberUtils.int2sortableStr(readableValue);
       }
@@ -121,7 +123,7 @@ class SortableIntFieldSource extends Fie
 
       public int intVal(int doc) {
         int ord=termsIndex.getOrd(doc);
-        return ord==0 ? def  : NumberUtils.SortableStr2int(termsIndex.lookup(ord, new BytesRef()),0,3);
+        return ord==0 ? def  : NumberUtils.SortableStr2int(termsIndex.lookup(ord, spare),0,3);
       }
 
       public long longVal(int doc) {
@@ -152,7 +154,14 @@ class SortableIntFieldSource extends Fie
 
           @Override
           public void fillValue(int doc) {
-            mval.value = intVal(doc);
+            int ord=termsIndex.getOrd(doc);
+            if (ord == 0) {
+              mval.value = def;
+              mval.exists = false;
+            } else {
+              mval.value = NumberUtils.SortableStr2int(termsIndex.lookup(ord, spare),0,3);
+              mval.exists = true;
+            }
           }
         };
       }

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/SortableLongField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/SortableLongField.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/SortableLongField.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/SortableLongField.java Mon Dec  6 00:47:16 2010
@@ -108,6 +108,8 @@ class SortableLongFieldSource extends Fi
     final long def = defVal;
 
     return new StringIndexDocValues(this, reader, field) {
+      private final BytesRef spare = new BytesRef();
+
       protected String toTerm(String readableValue) {
         return NumberUtils.long2sortableStr(readableValue);
       }
@@ -122,7 +124,7 @@ class SortableLongFieldSource extends Fi
 
       public long longVal(int doc) {
         int ord=termsIndex.getOrd(doc);
-        return ord==0 ? def  : NumberUtils.SortableStr2long(termsIndex.lookup(ord, new BytesRef()),0,5);
+        return ord==0 ? def  : NumberUtils.SortableStr2long(termsIndex.lookup(ord, spare),0,5);
       }
 
       public double doubleVal(int doc) {
@@ -149,7 +151,14 @@ class SortableLongFieldSource extends Fi
 
           @Override
           public void fillValue(int doc) {
-            mval.value = longVal(doc);
+            int ord=termsIndex.getOrd(doc);
+            if (ord == 0) {
+              mval.value = def;
+              mval.exists = false;
+            } else {
+              mval.value = NumberUtils.SortableStr2long(termsIndex.lookup(ord, spare),0,5);
+              mval.exists = true;
+            }
           }
         };
       }

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/TrieDateField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/TrieDateField.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/TrieDateField.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/TrieDateField.java Mon Dec  6 00:47:16 2010
@@ -193,7 +193,7 @@ public class TrieDateField extends DateF
 
     Field f;
     if (stored) {
-      f = new Field(field.getName(), arr, Field.Store.YES);
+      f = new Field(field.getName(), arr);
       if (indexed) f.setTokenStream(ts);
     } else {
       f = new Field(field.getName(), ts);

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/TrieField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/TrieField.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/TrieField.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/schema/TrieField.java Mon Dec  6 00:47:16 2010
@@ -552,7 +552,7 @@ public class TrieField extends FieldType
 
     Field f;
     if (stored) {
-      f = new Field(field.getName(), arr, Field.Store.YES);
+      f = new Field(field.getName(), arr);
       if (indexed) f.setTokenStream(ts);
     } else {
       f = new Field(field.getName(), ts);

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/Grouping.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/Grouping.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/Grouping.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/Grouping.java Mon Dec  6 00:47:16 2010
@@ -33,6 +33,7 @@ import java.util.*;
 
 public class Grouping {
 
+  public enum Format {Grouped, Simple}
 
   public abstract class Command {
     public String key;       // the name to use for this group in the response
@@ -42,6 +43,8 @@ public class Grouping {
     public int groupOffset;  // the offset within each group (for paging within each group)
     public int numGroups;    // how many groups - defaults to the "rows" parameter
     public int offset;       // offset into the list of groups
+    public Format format;
+    public boolean main;     // use as the main result in simple format (grouped.main=true param)
 
 
     abstract void prepare() throws IOException;
@@ -64,7 +67,14 @@ public class Grouping {
     }
 
     DocList getDocList(TopDocsCollector collector) {
-      int docsToCollect = getMax(groupOffset, docsPerGroup, maxDoc);
+      int max = collector.getTotalHits();
+      int off = groupOffset;
+      int len = docsPerGroup;
+      if (format == Format.Simple) {
+        off = offset;
+        len = numGroups;
+      }
+      int docsToCollect = getMax(off, len, max);
 
       // TODO: implement a DocList impl that doesn't need to start at offset=0
       TopDocs topDocs = collector.topDocs(0, docsToCollect);
@@ -79,7 +89,7 @@ public class Grouping {
 
       float score = topDocs.getMaxScore();
       maxScore = Math.max(maxScore, score);
-      DocSlice docs = new DocSlice(groupOffset, Math.max(0, ids.length - groupOffset), ids, scores, topDocs.totalHits, score);
+      DocSlice docs = new DocSlice(off, Math.max(0, ids.length - off), ids, scores, topDocs.totalHits, score);
 
       if (getDocList) {
         DocIterator iter = docs.iterator();
@@ -115,8 +125,12 @@ public class Grouping {
 
     @Override
     void finish() throws IOException {
-      NamedList rsp = commonResponse();
-      addDocList(rsp, (TopDocsCollector)collector.getCollector());
+      if (main) {
+        mainResult = getDocList((TopDocsCollector)collector.getCollector());
+      } else {
+        NamedList rsp = commonResponse();
+        addDocList(rsp, (TopDocsCollector)collector.getCollector());
+      }
     }
 
     @Override
@@ -148,11 +162,15 @@ public class Grouping {
       // if we aren't going to return any groups, disregard the offset 
       if (numGroups == 0) maxGroupToFind = 0;
 
+      collector = new TopGroupCollector(groupBy, context, normalizeSort(sort), maxGroupToFind);
+
+      /*** if we need a different algorithm when sort != group.sort
       if (compareSorts(sort, groupSort)) {
         collector = new TopGroupCollector(groupBy, context, normalizeSort(sort), maxGroupToFind);
       } else {
         collector = new TopGroupSortCollector(groupBy, context, normalizeSort(sort), normalizeSort(groupSort), maxGroupToFind);
       }
+      ***/
       return collector;
     }
 
@@ -161,19 +179,33 @@ public class Grouping {
       if (numGroups == 0) return null;
 
       int docsToCollect = getMax(groupOffset, docsPerGroup, maxDoc);
+      docsToCollect = Math.max(docsToCollect, 1);
 
-      if (false && groupBy instanceof StrFieldSource) {
-        collector2 = new Phase2StringGroupCollector(collector, groupBy, context, groupSort, docsToCollect, needScores, offset);
+      // if the format is simple, don't skip groups (since we are counting docs, not groups)
+      int collectorOffset = format==Format.Simple ? 0 : offset;
+
+      if (groupBy instanceof StrFieldSource) {
+        collector2 = new Phase2StringGroupCollector(collector, groupBy, context, groupSort, docsToCollect, needScores, collectorOffset);
       } else {
-        collector2 = new Phase2GroupCollector(collector, groupBy, context, groupSort, docsToCollect, needScores, offset);
+        collector2 = new Phase2GroupCollector(collector, groupBy, context, groupSort, docsToCollect, needScores, collectorOffset);
       }
       return collector2;
     }
 
     @Override
     void finish() throws IOException {
+      if (main) {
+        mainResult = createSimpleResponse();
+        return;
+      }
+
       NamedList groupResult = commonResponse();
 
+      if (format == Format.Simple) {
+        groupResult.add("doclist", createSimpleResponse());
+        return;
+      }
+
       List groupList = new ArrayList();
       groupResult.add("groups", groupList);        // grouped={ key={ groups=[
 
@@ -182,8 +214,6 @@ public class Grouping {
 
       if (collector.orderedGroups == null) collector.buildSet();
 
-
-
       int skipCount = offset;
       for (SearchGroup group : collector.orderedGroups) {
         if (skipCount > 0) {
@@ -200,6 +230,57 @@ public class Grouping {
       }
     }
 
+    private DocList createSimpleResponse() {
+      int docCount = numGroups;
+      int docOffset = offset;    
+      int docsToGather = getMax(docOffset, docCount, maxDoc);
+
+      float maxScore = Float.NEGATIVE_INFINITY; 
+      List<TopDocs> topDocsList = new ArrayList<TopDocs>();
+      int numDocs = 0;
+      for (SearchGroup group : collector.orderedGroups) {
+        SearchGroupDocs groupDocs = collector2.groupMap.get(group.groupValue);
+        
+        TopDocsCollector collector = groupDocs.collector;
+        int hits = collector.getTotalHits();
+
+        int num = Math.min(docsPerGroup, hits - groupOffset); // how many docs are in this group
+        if (num <= 0) continue;
+
+        TopDocs topDocs = collector.topDocs(groupOffset, Math.min(docsPerGroup,docsToGather-numDocs));
+        topDocsList.add(topDocs);
+        numDocs += topDocs.scoreDocs.length;
+
+        float score = topDocs.getMaxScore();
+        maxScore = Math.max(maxScore, score);
+
+        if (numDocs >= docsToGather) break;
+      }
+      assert numDocs <= docsToGather; // make sure we didn't gather too many
+      
+      int[] ids = new int[numDocs];
+      float[] scores = needScores ? new float[numDocs] : null;
+      int pos = 0;
+
+      for (TopDocs topDocs : topDocsList) {
+        for (ScoreDoc sd : topDocs.scoreDocs) {
+          ids[pos] = sd.doc;
+          if (scores != null) scores[pos] = sd.score;
+          pos++;
+        }
+      }
+
+      DocSlice docs = new DocSlice(docOffset, Math.max(0, ids.length - docOffset), ids, scores, getMatches(), maxScore);
+
+      if (getDocList) {
+        DocIterator iter = docs.iterator();
+        while (iter.hasNext())
+          idSet.add(iter.nextDoc());
+      }
+
+      return docs;
+    }
+
     @Override
     int getMatches() {
       return collector.getMatches();
@@ -239,6 +320,8 @@ public class Grouping {
   final SolrIndexSearcher.QueryCommand cmd;
   final List<Command> commands = new ArrayList<Command>();
 
+  public DocList mainResult;  // output if one of the grouping commands should be used as the main result.
+
   public Grouping(SolrIndexSearcher searcher, SolrIndexSearcher.QueryResult qr, SolrIndexSearcher.QueryCommand cmd) {
     this.searcher = searcher;
     this.qr = qr;
@@ -337,10 +420,6 @@ class SearchGroup {
   // float topDocScore;  // currently unused
   int comparatorSlot;
 
-  // currently only used when sort != sort.group
-  FieldComparator[] sortGroupComparators;
-  int[] sortGroupReversed;
-
   /***
   @Override
   public int hashCode() {
@@ -506,6 +585,8 @@ class TopGroupCollector extends GroupCol
 
       // remove current smallest group
       SearchGroup smallest = orderedGroups.pollLast();
+      assert orderedGroups.size() == nGroups -1;
+
       groupMap.remove(smallest.groupValue);
 
       // reuse the removed SearchGroup
@@ -518,6 +599,7 @@ class TopGroupCollector extends GroupCol
 
       groupMap.put(smallest.groupValue, smallest);
       orderedGroups.add(smallest);
+      assert orderedGroups.size() == nGroups;
 
       for (FieldComparator fc : comparators)
         fc.setBottom(orderedGroups.last().comparatorSlot);
@@ -560,6 +642,7 @@ class TopGroupCollector extends GroupCol
     if (orderedGroups != null) {
       prevLast = orderedGroups.last();
       orderedGroups.remove(group);
+      assert orderedGroups.size() == nGroups-1;
     }
 
     group.topDoc = docBase + doc;
@@ -569,6 +652,7 @@ class TopGroupCollector extends GroupCol
     // re-add the changed group
     if (orderedGroups != null) {
       orderedGroups.add(group);
+      assert orderedGroups.size() == nGroups;
       SearchGroup newLast = orderedGroups.last();
       // if we changed the value of the last group, or changed which group was last, then update bottom
       if (group == newLast || prevLast != newLast) {
@@ -622,174 +706,6 @@ class TopGroupCollector extends GroupCol
 }
 
 
-/**
- * This class allows a different sort within a group than what is used between groups.
- * Sorting between groups is done by the sort value of the first (highest ranking)
- * document in that group.
- */
-class TopGroupSortCollector extends TopGroupCollector {
-
-  IndexReader reader;
-  Sort groupSort;
-
-  public TopGroupSortCollector(ValueSource groupByVS, Map vsContext, Sort sort, Sort groupSort, int nGroups) throws IOException {
-    super(groupByVS, vsContext, sort, nGroups);
-    this.groupSort = groupSort;
-  }
-
-  void constructComparators(FieldComparator[] comparators, int[] reversed, SortField[] sortFields, int size) throws IOException {
-    for (int i = 0; i < sortFields.length; i++) {
-      SortField sortField = sortFields[i];
-      reversed[i] = sortField.getReverse() ? -1 : 1;
-      comparators[i] = sortField.getComparator(size, i);
-      if (scorer != null) comparators[i].setScorer(scorer);
-      if (reader != null) comparators[i] = comparators[i].setNextReader(reader, docBase);
-    }
-  }
-
-  @Override
-  public void setScorer(Scorer scorer) throws IOException {
-    super.setScorer(scorer);
-    for (SearchGroup searchGroup : groupMap.values()) {
-      for (FieldComparator fc : searchGroup.sortGroupComparators) {
-        fc.setScorer(scorer);
-      }
-    }
-  }
-
-  @Override
-  public void collect(int doc) throws IOException {
-    matches++;
-    filler.fillValue(doc);
-    SearchGroup group = groupMap.get(mval);
-    if (group == null) {
-      int num = groupMap.size();
-      if (groupMap.size() < nGroups) {
-        SearchGroup sg = new SearchGroup();
-        SortField[] sortGroupFields = groupSort.getSort();
-        sg.sortGroupComparators = new FieldComparator[sortGroupFields.length];
-        sg.sortGroupReversed = new int[sortGroupFields.length];
-        constructComparators(sg.sortGroupComparators, sg.sortGroupReversed, sortGroupFields, 1);
-
-        sg.groupValue = mval.duplicate();
-        sg.comparatorSlot = num++;
-        sg.matches = 1;
-        sg.topDoc = docBase + doc;
-        // sg.topDocScore = scorer.score();
-        for (FieldComparator fc : comparators)
-          fc.copy(sg.comparatorSlot, doc);
-        for (FieldComparator fc : sg.sortGroupComparators) {
-          fc.copy(0, doc);
-          fc.setBottom(0);
-        }
-        groupMap.put(sg.groupValue, sg);
-        return;
-      }
-
-      if (orderedGroups == null) {
-        buildSet();
-      }
-
-      // see if this new group would be competitive if this doc was the top doc
-      for (int i = 0;; i++) {
-        final int c = reversed[i] * comparators[i].compareBottom(doc);
-        if (c < 0) {
-          // Definitely not competitive. So don't even bother to continue
-          return;
-        } else if (c > 0) {
-          // Definitely competitive.
-          break;
-        } else if (i == comparators.length - 1) {
-          // Here c=0. If we're at the last comparator, this doc is not
-          // competitive, since docs are visited in doc Id order, which means
-          // this doc cannot compete with any other document in the queue.
-          return;
-        }
-      }
-
-      // remove current smallest group
-      SearchGroup smallest = orderedGroups.pollLast();
-      groupMap.remove(smallest.groupValue);
-
-      // reuse the removed SearchGroup
-      smallest.groupValue.copy(mval);
-      smallest.matches = 1;
-      smallest.topDoc = docBase + doc;
-      // smallest.topDocScore = scorer.score();
-      for (FieldComparator fc : comparators)
-        fc.copy(smallest.comparatorSlot, doc);
-      for (FieldComparator fc : smallest.sortGroupComparators) {
-        fc.copy(0, doc);
-        fc.setBottom(0);
-      }
-
-      groupMap.put(smallest.groupValue, smallest);
-      orderedGroups.add(smallest);
-
-      int lastSlot = orderedGroups.last().comparatorSlot;
-      for (FieldComparator fc : comparators)
-        fc.setBottom(lastSlot);
-
-      return;
-    }
-
-    //
-    // update existing group
-    //
-
-    group.matches++; // TODO: these aren't valid if the group is every discarded then re-added.  keep track if there have been discards?
-
-    for (int i = 0;; i++) {
-      FieldComparator fc = group.sortGroupComparators[i];
-
-      final int c = group.sortGroupReversed[i] * fc.compareBottom(doc);
-      if (c < 0) {
-        // Definitely not competitive.
-        return;
-      } else if (c > 0) {
-        // Definitely competitive.
-        // Set remaining comparators
-        for (int j = 0; j < group.sortGroupComparators.length; j++) {
-          group.sortGroupComparators[j].copy(0, doc);
-          group.sortGroupComparators[j].setBottom(0);
-        }
-        for (FieldComparator comparator : comparators) comparator.copy(spareSlot, doc);
-        break;
-      } else if (i == group.sortGroupComparators.length - 1) {
-        // Here c=0. If we're at the last comparator, this doc is not
-        // competitive, since docs are visited in doc Id order, which means
-        // this doc cannot compete with any other document in the queue.
-        return;
-      }
-    }
-
-    // remove before updating the group since lookup is done via comparators
-    // TODO: optimize this
-    if (orderedGroups != null)
-      orderedGroups.remove(group);
-
-    group.topDoc = docBase + doc;
-    // group.topDocScore = scorer.score();
-    int tmp = spareSlot; spareSlot = group.comparatorSlot; group.comparatorSlot=tmp;  // swap slots
-
-    // re-add the changed group
-    if (orderedGroups != null)
-      orderedGroups.add(group);
-  }
-
-  @Override
-  public void setNextReader(IndexReader reader, int docBase) throws IOException {
-    super.setNextReader(reader, docBase);
-    this.reader = reader;
-    for (SearchGroup searchGroup : groupMap.values()) {
-      for (int i=0; i<searchGroup.sortGroupComparators.length; i++)
-        searchGroup.sortGroupComparators[i] = searchGroup.sortGroupComparators[i].setNextReader(reader, docBase);
-    }
-  }
-
-}
-
-
 class Phase2GroupCollector extends Collector {
   final HashMap<MutableValue, SearchGroupDocs> groupMap;
   final ValueSource vs;
@@ -870,9 +786,9 @@ class SearchGroupDocs {
 
 class Phase2StringGroupCollector extends Phase2GroupCollector {
   FieldCache.DocTermsIndex index;
-  SentinelIntSet ordSet;
-  SearchGroupDocs[] groups;
-  BytesRef spare;
+  final SentinelIntSet ordSet;
+  final SearchGroupDocs[] groups;
+  final BytesRef spare = new BytesRef();
 
   public Phase2StringGroupCollector(TopGroupCollector topGroups, ValueSource groupByVS, Map vsContext, Sort sort, int docsPerGroup, boolean getScores, int offset) throws IOException {
     super(topGroups, groupByVS, vsContext,sort,docsPerGroup,getScores,offset);
@@ -902,8 +818,12 @@ class Phase2StringGroupCollector extends
 
     ordSet.clear();
     for (SearchGroupDocs group : groupMap.values()) {
-      int ord = index.binarySearchLookup(((MutableValueStr)group.groupValue).value, spare);
-      if (ord > 0) {
+      MutableValueStr gv = (MutableValueStr)group.groupValue;
+      int ord = 0;
+      if (gv.exists) {
+        ord = index.binarySearchLookup(((MutableValueStr)group.groupValue).value, spare);
+      }
+      if (ord >= 0) {
         int slot = ordSet.put(ord);
         groups[slot] = group;
       }

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValue.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValue.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValue.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValue.java Mon Dec  6 00:47:16 2010
@@ -18,7 +18,7 @@ package org.apache.solr.search;
 
 /** @lucene.internal */
 public abstract class MutableValue implements Comparable {
-  protected boolean exists = true;
+  public boolean exists = true;
 
   public abstract void copy(MutableValue source);
   public abstract MutableValue duplicate();
@@ -47,7 +47,7 @@ public abstract class MutableValue imple
   public boolean equals(Object other) {
     Class c1 = this.getClass();
     Class c2 = other.getClass();
-    return (c1 == c2) ? this.equalsSameType(other) : false;
+    return (c1 == c2) && this.equalsSameType(other);
   }
 
   public abstract int hashCode();

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueDate.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueDate.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueDate.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueDate.java Mon Dec  6 00:47:16 2010
@@ -21,13 +21,14 @@ import java.util.Date;
 public class MutableValueDate extends MutableValueLong {
   @Override
   public Object toObject() {
-    return new Date(value);
+    return exists ? new Date(value) : null;
   }
 
   @Override
   public MutableValue duplicate() {
     MutableValueDate v = new MutableValueDate();
     v.value = this.value;
+    v.exists = this.exists;
     return v;
   }  
 }
\ No newline at end of file

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueDouble.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueDouble.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueDouble.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueDouble.java Mon Dec  6 00:47:16 2010
@@ -21,29 +21,38 @@ public class MutableValueDouble extends 
 
   @Override
   public Object toObject() {
-    return value;
+    return exists ? value : null;
   }
 
   @Override
   public void copy(MutableValue source) {
-    value = ((MutableValueDouble)source).value;
+    MutableValueDouble s = (MutableValueDouble) source;
+    value = s.value;
+    exists = s.exists;
   }
 
   @Override
   public MutableValue duplicate() {
     MutableValueDouble v = new MutableValueDouble();
     v.value = this.value;
+    v.exists = this.exists;
     return v;
   }
 
   @Override
   public boolean equalsSameType(Object other) {
-    return value == ((MutableValueDouble)other).value;
+    MutableValueDouble b = (MutableValueDouble)other;
+    return value == b.value && exists == b.exists;
   }
 
   @Override
   public int compareSameType(Object other) {
-    return Double.compare(value, ((MutableValueDouble)other).value);  // handles NaN
+    MutableValueDouble b = (MutableValueDouble)other;
+    int c = Double.compare(value, b.value);
+    if (c != 0) return c;
+    if (!exists) return -1;
+    if (!b.exists) return 1;
+    return 0;
   }
 
   @Override
@@ -51,4 +60,4 @@ public class MutableValueDouble extends 
     long x = Double.doubleToLongBits(value);
     return (int)x + (int)(x>>>32);
   }
-}
\ No newline at end of file
+}

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueFloat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueFloat.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueFloat.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueFloat.java Mon Dec  6 00:47:16 2010
@@ -21,33 +21,41 @@ public class MutableValueFloat extends M
 
   @Override
   public Object toObject() {
-    return value;
+    return exists ? value : null;
   }
 
   @Override
   public void copy(MutableValue source) {
-    value = ((MutableValueFloat)source).value;
+    MutableValueFloat s = (MutableValueFloat) source;
+    value = s.value;
+    exists = s.exists;
   }
 
   @Override
   public MutableValue duplicate() {
     MutableValueFloat v = new MutableValueFloat();
     v.value = this.value;
+    v.exists = this.exists;
     return v;
   }
 
   @Override
   public boolean equalsSameType(Object other) {
-    return value == ((MutableValueFloat)other).value;
+    MutableValueFloat b = (MutableValueFloat)other;
+    return value == b.value && exists == b.exists;
   }
 
   @Override
   public int compareSameType(Object other) {
-    return Float.compare(value, ((MutableValueFloat)other).value);  // handles NaN
+    MutableValueFloat b = (MutableValueFloat)other;
+    int c = Float.compare(value, b.value);
+    if (c != 0) return c;
+    if (exists == b.exists) return 0;
+    return exists ? 1 : -1;
   }
 
   @Override
   public int hashCode() {
     return Float.floatToIntBits(value);
   }
-}
\ No newline at end of file
+}

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueInt.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueInt.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueInt.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueInt.java Mon Dec  6 00:47:16 2010
@@ -21,38 +21,46 @@ public class MutableValueInt extends Mut
   
   @Override
   public Object toObject() {
-    return value;
+    return exists ? value : null;
   }
 
   @Override
   public void copy(MutableValue source) {
-    value = ((MutableValueInt)source).value;
+    MutableValueInt s = (MutableValueInt) source;
+    value = s.value;
+    exists = s.exists;
   }
 
   @Override
   public MutableValue duplicate() {
     MutableValueInt v = new MutableValueInt();
     v.value = this.value;
+    v.exists = this.exists;
     return v;
   }
 
   @Override
   public boolean equalsSameType(Object other) {
-    return value == ((MutableValueInt)other).value;
+    MutableValueInt b = (MutableValueInt)other;
+    return value == b.value && exists == b.exists;
   }
 
   @Override
   public int compareSameType(Object other) {
-    int a = value;
-    int b = ((MutableValueInt)other).value;
-    return (int)((((long)a) - ((long)b)) >> 32);  // any shift >= 32 should do.
-
+    MutableValueInt b = (MutableValueInt)other;
+    int ai = value;
+    int bi = b.value;
+    int c = (int)((((long)ai) - ((long)bi)) >> 32);  // any shift >= 32 should do.
+    if (c!=0) return c;
     /* is there any pattern that the compiler would recognize as a single native CMP instruction? */
     /***
     if (a<b) return -1;
     else if (a>b) return 1;
     else return 0;
     ***/
+
+    if (exists == b.exists) return 0;
+    return exists ? 1 : -1;
   }
 
 

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueLong.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueLong.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueLong.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueLong.java Mon Dec  6 00:47:16 2010
@@ -21,32 +21,38 @@ public class MutableValueLong extends Mu
 
   @Override
   public Object toObject() {
-    return value;
+    return exists ? value : null;
   }
 
   @Override
   public void copy(MutableValue source) {
-    value = ((MutableValueLong)source).value;
+    MutableValueLong s = (MutableValueLong) source;
+    exists = s.exists;
+    value = s.value;
   }
 
   @Override
   public MutableValue duplicate() {
     MutableValueLong v = new MutableValueLong();
     v.value = this.value;
+    v.exists = this.exists;
     return v;
   }
 
   @Override
   public boolean equalsSameType(Object other) {
-    return value == ((MutableValueLong)other).value;
+    MutableValueLong b = (MutableValueLong)other;
+    return value == b.value && exists == b.exists;
   }
 
   @Override
   public int compareSameType(Object other) {
-    long b = ((MutableValueLong)other).value;
-    if (value<b) return -1;
-    else if (value>b) return 1;
-    else return 0;
+    MutableValueLong b = (MutableValueLong)other;
+    long bv = b.value;
+    if (value<bv) return -1;
+    if (value>bv) return 1;
+    if (exists == b.exists) return 0;
+    return exists ? 1 : -1;
   }
 
 
@@ -54,4 +60,4 @@ public class MutableValueLong extends Mu
   public int hashCode() {
     return (int)value + (int)(value>>32);
   }
-}
\ No newline at end of file
+}

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueStr.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueStr.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueStr.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/MutableValueStr.java Mon Dec  6 00:47:16 2010
@@ -24,29 +24,37 @@ public class MutableValueStr extends Mut
 
   @Override
   public Object toObject() {
-    return ByteUtils.UTF8toUTF16(value);
+    return exists ? ByteUtils.UTF8toUTF16(value) : null;
   }
 
   @Override
   public void copy(MutableValue source) {
-    value.copy(((MutableValueStr)source).value);
+    MutableValueStr s = (MutableValueStr) source;
+    exists = s.exists;
+    value.copy(s.value);
   }
 
   @Override
   public MutableValue duplicate() {
     MutableValueStr v = new MutableValueStr();
-    v.value = new BytesRef(value);
+    v.value.copy(value);
+    v.exists = this.exists;
     return v;
   }
 
   @Override
   public boolean equalsSameType(Object other) {
-    return value.equals(((MutableValueStr)other).value);
+    MutableValueStr b = (MutableValueStr)other;
+    return value.equals(b.value) && exists == b.exists;
   }
 
   @Override
   public int compareSameType(Object other) {
-    return value.compareTo(((MutableValueStr)other).value);
+    MutableValueStr b = (MutableValueStr)other;
+    int c = value.compareTo(b.value);
+    if (c != 0) return c;
+    if (exists == b.exists) return 0;
+    return exists ? 1 : -1;
   }
 
 
@@ -54,4 +62,4 @@ public class MutableValueStr extends Mut
   public int hashCode() {
     return value.hashCode();
   }
-}
\ No newline at end of file
+}

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/SolrIndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/SolrIndexSearcher.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/SolrIndexSearcher.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/SolrIndexSearcher.java Mon Dec  6 00:47:16 2010
@@ -149,7 +149,7 @@ public class SolrIndexSearcher extends I
 
     if (r.directory() instanceof FSDirectory) {
       FSDirectory fsDirectory = (FSDirectory) r.directory();
-      indexDir = fsDirectory.getFile().getAbsolutePath();
+      indexDir = fsDirectory.getDirectory().getAbsolutePath();
     }
 
     this.closeReader = closeReader;

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/SolrQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/SolrQueryParser.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/SolrQueryParser.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/SolrQueryParser.java Mon Dec  6 00:47:16 2010
@@ -78,7 +78,7 @@ public class SolrQueryParser extends Que
    * @see IndexSchema#getDefaultSearchFieldName()
    */
   public SolrQueryParser(IndexSchema schema, String defaultField) {
-    super(schema.getSolrConfig().getLuceneVersion("luceneMatchVersion", Version.LUCENE_24), defaultField == null ? schema.getDefaultSearchFieldName() : defaultField, schema.getQueryAnalyzer());
+    super(schema.getSolrConfig().getLuceneVersion("luceneMatchVersion", Version.LUCENE_30), defaultField == null ? schema.getDefaultSearchFieldName() : defaultField, schema.getQueryAnalyzer());
     this.schema = schema;
     this.parser  = null;
     this.defaultField = defaultField;
@@ -92,7 +92,7 @@ public class SolrQueryParser extends Que
   }
 
   public SolrQueryParser(QParser parser, String defaultField, Analyzer analyzer) {
-    super(parser.getReq().getSchema().getSolrConfig().getLuceneVersion("luceneMatchVersion", Version.LUCENE_24), defaultField, analyzer);
+    super(parser.getReq().getSchema().getSolrConfig().getLuceneVersion("luceneMatchVersion", Version.LUCENE_30), defaultField, analyzer);
     this.schema = parser.getReq().getSchema();
     this.parser = parser;
     this.defaultField = defaultField;

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/DoubleFieldSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/DoubleFieldSource.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/DoubleFieldSource.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/DoubleFieldSource.java Mon Dec  6 00:47:16 2010
@@ -18,6 +18,7 @@
 package org.apache.solr.search.function;
 
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.util.Bits;
 import org.apache.lucene.search.FieldCache;
 import org.apache.lucene.search.cache.DoubleValuesCreator;
 import org.apache.lucene.search.cache.FloatValuesCreator;
@@ -50,6 +51,7 @@ public class DoubleFieldSource extends N
   public DocValues getValues(Map context, IndexReader reader) throws IOException {
     final DoubleValues vals = cache.getDoubles(reader, field, creator);
     final double[] arr = vals.values;
+	final Bits valid = vals.valid;
     
     return new DocValues() {
       public float floatVal(int doc) {
@@ -148,6 +150,7 @@ public class DoubleFieldSource extends N
           @Override
           public void fillValue(int doc) {
             mval.value = doubleArr[doc];
+            mval.exists = valid.get(doc);
           }
         };
       }

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/FloatFieldSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/FloatFieldSource.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/FloatFieldSource.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/FloatFieldSource.java Mon Dec  6 00:47:16 2010
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.util.Map;
 
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.util.Bits;
 import org.apache.lucene.search.cache.FloatValuesCreator;
 import org.apache.lucene.search.cache.CachedArray.FloatValues;
 import org.apache.solr.search.MutableValue;
@@ -47,6 +48,7 @@ public class FloatFieldSource extends Nu
   public DocValues getValues(Map context, IndexReader reader) throws IOException {
     final FloatValues vals = cache.getFloats(reader, field, creator);
     final float[] arr = vals.values;
+	final Bits valid = vals.valid;
     
     return new DocValues() {
       public float floatVal(int doc) {
@@ -87,10 +89,11 @@ public class FloatFieldSource extends Nu
           @Override
           public void fillValue(int doc) {
             mval.value = floatArr[doc];
+            mval.exists = valid.get(doc);
           }
         };
       }
 
     };
   }
-}
\ No newline at end of file
+}

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/IntFieldSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/IntFieldSource.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/IntFieldSource.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/IntFieldSource.java Mon Dec  6 00:47:16 2010
@@ -18,6 +18,7 @@
 package org.apache.solr.search.function;
 
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.util.Bits;
 import org.apache.solr.search.MutableValueInt;
 import org.apache.solr.search.MutableValue;
 import org.apache.lucene.search.FieldCache;
@@ -51,6 +52,7 @@ public class IntFieldSource extends Nume
   public DocValues getValues(Map context, IndexReader reader) throws IOException {
     final IntValues vals = cache.getInts(reader, field, creator);
     final int[] arr = vals.values;
+	final Bits valid = vals.valid;
     
     return new DocValues() {
       final MutableValueInt val = new MutableValueInt();
@@ -127,6 +129,7 @@ public class IntFieldSource extends Nume
           @Override
           public void fillValue(int doc) {
             mval.value = intArr[doc];
+            mval.exists = valid.get(doc);
           }
         };
       }

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/LongFieldSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/LongFieldSource.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/LongFieldSource.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/LongFieldSource.java Mon Dec  6 00:47:16 2010
@@ -18,6 +18,7 @@
 package org.apache.solr.search.function;
 
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.util.Bits;
 import org.apache.lucene.search.cache.LongValuesCreator;
 import org.apache.lucene.search.cache.CachedArray.LongValues;
 import org.apache.solr.search.MutableValue;
@@ -52,6 +53,7 @@ public class LongFieldSource extends Num
   public DocValues getValues(Map context, IndexReader reader) throws IOException {
     final LongValues vals = cache.getLongs(reader, field, creator);
     final long[] arr = vals.values;
+	final Bits valid = vals.valid;
     
     return new DocValues() {
       public float floatVal(int doc) {
@@ -126,6 +128,7 @@ public class LongFieldSource extends Num
           @Override
           public void fillValue(int doc) {
             mval.value = longArr[doc];
+            mval.exists = valid.get(doc);
           }
         };
       }

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/OrdFieldSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/OrdFieldSource.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/OrdFieldSource.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/OrdFieldSource.java Mon Dec  6 00:47:16 2010
@@ -18,6 +18,9 @@
 package org.apache.solr.search.function;
 
 import org.apache.lucene.index.IndexReader;
+import org.apache.solr.search.MutableValue;
+import org.apache.solr.search.MutableValueInt;
+import org.apache.solr.util.NumberUtils;
 
 import java.io.IOException;
 import java.util.Map;
@@ -90,6 +93,24 @@ public class OrdFieldSource extends Valu
       public String toString(int doc) {
         return description() + '=' + intVal(doc);
       }
+
+            @Override
+      public ValueFiller getValueFiller() {
+        return new ValueFiller() {
+          private final MutableValueInt mval = new MutableValueInt();
+
+          @Override
+          public MutableValue getValue() {
+            return mval;
+          }
+
+          @Override
+          public void fillValue(int doc) {
+            mval.value = termsIndex.getOrd(doc);
+            mval.exists = mval.value!=0;
+          }
+        };
+      }
     };
   }
 

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/StringIndexDocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/StringIndexDocValues.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/StringIndexDocValues.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/search/function/StringIndexDocValues.java Mon Dec  6 00:47:16 2010
@@ -104,7 +104,9 @@ public abstract class StringIndexDocValu
 
       @Override
       public void fillValue(int doc) {
-        mval.value = termsIndex.getTerm(doc, val.value);
+        int ord = termsIndex.getOrd(doc);
+        mval.exists = ord != 0;
+        mval.value = termsIndex.lookup(ord, mval.value);
       }
     };
   }

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java Mon Dec  6 00:47:16 2010
@@ -149,7 +149,7 @@ public abstract class AbstractLuceneSpel
     }
     if (analyzer == null)   {
       log.info("Using WhitespaceAnalzyer for dictionary: " + name);
-      analyzer = new WhitespaceAnalyzer();
+      analyzer = new WhitespaceAnalyzer(core.getSolrConfig().luceneMatchVersion);
     }
     return name;
   }

Modified: lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java?rev=1042501&r1=1042500&r2=1042501&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java (original)
+++ lucene/dev/branches/docvalues/solr/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java Mon Dec  6 00:47:16 2010
@@ -19,20 +19,18 @@ package org.apache.solr.spelling;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.util.List;
+
+import org.apache.lucene.index.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.search.spell.PlainTextDictionary;
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.SolrCore;
-import org.apache.solr.core.SolrResourceLoader;
 import org.apache.solr.schema.FieldType;
-import org.apache.solr.schema.IndexSchema;
 import org.apache.solr.util.HighFrequencyDictionary;
 import org.apache.solr.search.SolrIndexSearcher;
 
@@ -60,7 +58,7 @@ public class FileBasedSpellChecker exten
 
   public void build(SolrCore core, SolrIndexSearcher searcher) {
     try {
-      loadExternalFileDictionary(core.getSchema(), core.getResourceLoader());
+      loadExternalFileDictionary(core);
       spellChecker.clearIndex();
       spellChecker.indexDictionary(dictionary);
     } catch (IOException e) {
@@ -77,22 +75,28 @@ public class FileBasedSpellChecker exten
   }
 
   @SuppressWarnings("unchecked")
-  private void loadExternalFileDictionary(IndexSchema schema, SolrResourceLoader loader) {
+  private void loadExternalFileDictionary(SolrCore core) {
     try {
 
       // Get the field's analyzer
-      if (fieldTypeName != null
-              && schema.getFieldTypeNoEx(fieldTypeName) != null) {
-        FieldType fieldType = schema.getFieldTypes()
-                .get(fieldTypeName);
+      if (fieldTypeName != null && core.getSchema().getFieldTypeNoEx(fieldTypeName) != null) {
+        FieldType fieldType = core.getSchema().getFieldTypes().get(fieldTypeName);
         // Do index-time analysis using the given fieldType's analyzer
         RAMDirectory ramDir = new RAMDirectory();
-        IndexWriter writer = new IndexWriter(ramDir, fieldType.getAnalyzer(),
-                true, IndexWriter.MaxFieldLength.UNLIMITED);
-        writer.setMergeFactor(300);
-        writer.setMaxBufferedDocs(150);
 
-        List<String> lines = loader.getLines(sourceLocation, characterEncoding);
+        LogMergePolicy mp = new LogByteSizeMergePolicy();
+        mp.setMergeFactor(300);
+
+        IndexWriter writer = new IndexWriter(
+            ramDir,
+            new IndexWriterConfig(core.getSolrConfig().luceneMatchVersion, fieldType.getAnalyzer()).
+                setMaxBufferedDocs(150).
+                setMergePolicy(mp).
+                setMaxFieldLength(IndexWriterConfig.UNLIMITED_FIELD_LENGTH).
+                setOpenMode(IndexWriterConfig.OpenMode.CREATE)
+        );
+
+        List<String> lines = core.getResourceLoader().getLines(sourceLocation, characterEncoding);
 
         for (String s : lines) {
           Document d = new Document();
@@ -107,9 +111,9 @@ public class FileBasedSpellChecker exten
       } else {
         // check if character encoding is defined
         if (characterEncoding == null) {
-          dictionary = new PlainTextDictionary(loader.openResource(sourceLocation));
+          dictionary = new PlainTextDictionary(core.getResourceLoader().openResource(sourceLocation));
         } else {
-          dictionary = new PlainTextDictionary(new InputStreamReader(loader.openResource(sourceLocation), characterEncoding));
+          dictionary = new PlainTextDictionary(new InputStreamReader(core.getResourceLoader().openResource(sourceLocation), characterEncoding));
         }
       }