You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2013/02/16 21:16:13 UTC

svn commit: r1446934 [2/2] - in /lucene/dev/branches/branch_4x/solr: ./ core/ core/src/java/org/apache/solr/core/ core/src/java/org/apache/solr/handler/component/ core/src/java/org/apache/solr/request/ core/src/java/org/apache/solr/schema/ core/src/jav...

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java?rev=1446934&r1=1446933&r2=1446934&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java Sat Feb 16 20:16:12 2013
@@ -75,6 +75,7 @@ public class StatsComponentTest extends 
   public void doTestFieldStatisticsResult(String f) throws Exception {
     assertU(adoc("id", "1", f, "-10"));
     assertU(adoc("id", "2", f, "-20"));
+    assertU(commit());
     assertU(adoc("id", "3", f, "-30"));
     assertU(adoc("id", "4", f, "-40"));
     assertU(commit());
@@ -205,6 +206,7 @@ public class StatsComponentTest extends 
   public void doTestFieldStatisticsMissingResult(String f) throws Exception {
     assertU(adoc("id", "1", f, "-10"));
     assertU(adoc("id", "2", f, "-20"));
+    assertU(commit());
     assertU(adoc("id", "3"));
     assertU(adoc("id", "4", f, "-40"));
     assertU(commit());
@@ -224,6 +226,7 @@ public class StatsComponentTest extends 
   public void doTestFacetStatisticsResult(String f) throws Exception {
     assertU(adoc("id", "1", f, "10", "active_s", "true",  "other_s", "foo"));
     assertU(adoc("id", "2", f, "20", "active_s", "true",  "other_s", "bar"));
+    assertU(commit());
     assertU(adoc("id", "3", f, "30", "active_s", "false", "other_s", "foo"));
     assertU(adoc("id", "4", f, "40", "active_s", "false", "other_s", "foo"));
     assertU(commit());
@@ -257,6 +260,7 @@ public class StatsComponentTest extends 
   public void doTestFacetStatisticsMissingResult(String f) throws Exception {
       assertU(adoc("id", "1", f, "10", "active_s", "true"));
       assertU(adoc("id", "2", f, "20", "active_s", "true"));
+      assertU(commit());
       assertU(adoc("id", "3", "active_s", "false"));
       assertU(adoc("id", "4", f, "40", "active_s", "false"));
       assertU(commit());
@@ -288,6 +292,7 @@ public class StatsComponentTest extends 
     SolrCore core = h.getCore();
     assertU(adoc("id", "1"));
     assertU(adoc("id", "2"));
+    assertU(commit());
     assertU(adoc("id", "3"));
     assertU(adoc("id", "4"));
     assertU(commit());
@@ -307,6 +312,7 @@ public class StatsComponentTest extends 
     SolrCore core = h.getCore();
     assertU(adoc("id", "1"));
     assertU(adoc("id", "2"));
+    assertU(commit());
     assertU(adoc("id", "3"));
     assertU(adoc("id", "4"));
     assertU(commit());
@@ -328,6 +334,7 @@ public class StatsComponentTest extends 
 
     assertU(adoc("id", "1"));
     assertU(adoc("id", "2"));
+    assertU(commit());
     assertU(adoc("id", "3"));
     assertU(commit());
 
@@ -347,6 +354,7 @@ public class StatsComponentTest extends 
     SchemaField foo_ss = core.getSchema().getField("foo_ss");
 
     assertU(adoc("id", "1", "active_i", "1", "foo_ss", "aa" ));
+    assertU(commit());
     assertU(adoc("id", "2", "active_i", "1", "foo_ss", "bb" ));
     assertU(adoc("id", "3", "active_i", "5", "foo_ss", "aa" ));
     assertU(commit());

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java?rev=1446934&r1=1446933&r2=1446934&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java Sat Feb 16 20:16:12 2013
@@ -19,8 +19,6 @@ package org.apache.solr.schema;
 
 import org.apache.solr.core.AbstractBadConfigTestBase;
 
-import java.util.regex.Pattern;
-
 public class BadIndexSchemaTest extends AbstractBadConfigTestBase {
 
   private void doTest(final String schema, final String errString) 
@@ -83,5 +81,12 @@ public class BadIndexSchemaTest extends 
     doTest("bad-schema-codec-global-vs-ft-mismatch.xml", "codec does not support");
   }
 
+  public void testDocValuesNotRequiredNoDefault() throws Exception {
+    doTest("bad-schema-docValues-not-required-no-default.xml", "has no default value and is not required");
+  }
+
+  public void testDocValuesUnsupported() throws Exception {
+    doTest("bad-schema-unsupported-docValues.xml", "does not support doc values");
+  }
 
 }

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/schema/CurrencyFieldTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/schema/CurrencyFieldTest.java?rev=1446934&r1=1446933&r2=1446934&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/schema/CurrencyFieldTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/schema/CurrencyFieldTest.java Sat Feb 16 20:16:12 2013
@@ -23,6 +23,7 @@ import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Test;
 
+import java.util.List;
 import java.util.Random;
 import java.util.Set;
 
@@ -71,18 +72,18 @@ public class CurrencyFieldTest extends S
     FieldType tmp = amount.getType();
     assertTrue(tmp instanceof CurrencyField);
     String currencyValue = "1.50,EUR";
-    IndexableField[] fields = amount.createFields(currencyValue, 2);
-    assertEquals(fields.length, 3);
+    List<IndexableField> fields = amount.createFields(currencyValue, 2);
+    assertEquals(fields.size(), 3);
 
     // First field is currency code, second is value, third is stored.
     for (int i = 0; i < 3; i++) {
-      boolean hasValue = fields[i].readerValue() != null
-              || fields[i].numericValue() != null
-              || fields[i].stringValue() != null;
-      assertTrue("Doesn't have a value: " + fields[i], hasValue);
+      boolean hasValue = fields.get(i).readerValue() != null
+              || fields.get(i).numericValue() != null
+              || fields.get(i).stringValue() != null;
+      assertTrue("Doesn't have a value: " + fields.get(i), hasValue);
     }
 
-    assertEquals(schema.getFieldTypeByName("string").toExternal(fields[2]), "1.50,EUR");
+    assertEquals(schema.getFieldTypeByName("string").toExternal(fields.get(2)), "1.50,EUR");
     
     // A few tests on the provider directly
     ExchangeRateProvider p = ((CurrencyField) tmp).getProvider();

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/schema/DateFieldTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/schema/DateFieldTest.java?rev=1446934&r1=1446933&r2=1446934&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/schema/DateFieldTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/schema/DateFieldTest.java Sat Feb 16 20:16:12 2013
@@ -17,17 +17,15 @@
 
 package org.apache.solr.schema;
 
-import org.apache.lucene.document.Field;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+
 import org.apache.lucene.index.IndexableField;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.solr.util.DateMathParser;
-
 import org.junit.Ignore;
 
-import java.util.Date;
-import java.util.TimeZone;
-import java.util.Locale;
-
 public class DateFieldTest extends LuceneTestCase {
   public static TimeZone UTC = TimeZone.getTimeZone("UTC");
   protected DateField f = null;

Copied: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/schema/DocValuesTest.java (from r1446922, lucene/dev/trunk/solr/core/src/test/org/apache/solr/schema/DocValuesTest.java)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/schema/DocValuesTest.java?p2=lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/schema/DocValuesTest.java&p1=lucene/dev/trunk/solr/core/src/test/org/apache/solr/schema/DocValuesTest.java&r1=1446922&r2=1446934&rev=1446934&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/schema/DocValuesTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/schema/DocValuesTest.java Sat Feb 16 20:16:12 2013
@@ -23,12 +23,14 @@ import org.apache.lucene.index.AtomicRea
 import org.apache.lucene.index.FieldInfo.DocValuesType;
 import org.apache.lucene.index.FieldInfos;
 import org.apache.lucene.queries.function.FunctionValues;
+import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.search.SolrIndexSearcher;
 import org.apache.solr.util.RefCounted;
 import org.junit.BeforeClass;
 
+@SuppressCodecs("Lucene3x")
 public class DocValuesTest extends SolrTestCaseJ4 {
 
   @BeforeClass

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/schema/PolyFieldTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/schema/PolyFieldTest.java?rev=1446934&r1=1446933&r2=1446934&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/schema/PolyFieldTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/schema/PolyFieldTest.java Sat Feb 16 20:16:12 2013
@@ -16,14 +16,16 @@ package org.apache.solr.schema;
  * limitations under the License.
  */
 
-import org.apache.lucene.queries.function.ValueSource;
+import java.util.List;
+
 import org.apache.lucene.index.IndexableField;
+import org.apache.lucene.queries.function.ValueSource;
 import org.apache.lucene.search.BooleanClause;
 import org.apache.lucene.search.BooleanQuery;
 import org.apache.lucene.search.Query;
 import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.core.SolrCore;
 import org.apache.solr.common.SolrException;
+import org.apache.solr.core.SolrCore;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -83,14 +85,14 @@ public class PolyFieldTest extends SolrT
     assertEquals(pt.getDimension(), 2);
     double[] xy = new double[]{35.0, -79.34};
     String point = xy[0] + "," + xy[1];
-    IndexableField[] fields = home.createFields(point, 2);
-    assertEquals(fields.length, 3);//should be 3, we have a stored field
+    List<IndexableField> fields = home.createFields(point, 2);
+    assertEquals(fields.size(), 3);//should be 3, we have a stored field
     //first two fields contain the values, third is just stored and contains the original
     for (int i = 0; i < 3; i++) {
-      boolean hasValue = fields[i].binaryValue() != null
-          || fields[i].stringValue() != null
-          || fields[i].numericValue() != null;
-      assertTrue("Doesn't have a value: " + fields[i], hasValue);
+      boolean hasValue = fields.get(i).binaryValue() != null
+          || fields.get(i).stringValue() != null
+          || fields.get(i).numericValue() != null;
+      assertTrue("Doesn't have a value: " + fields.get(i), hasValue);
     }
     /*assertTrue("first field " + fields[0].tokenStreamValue() +  " is not 35.0", pt.getSubType().toExternal(fields[0]).equals(String.valueOf(xy[0])));
     assertTrue("second field is not -79.34", pt.getSubType().toExternal(fields[1]).equals(String.valueOf(xy[1])));
@@ -100,7 +102,7 @@ public class PolyFieldTest extends SolrT
     home = schema.getField("home_ns");
     assertNotNull(home);
     fields = home.createFields(point, 2);
-    assertEquals(fields.length, 2);//should be 2, since we aren't storing
+    assertEquals(fields.size(), 2);//should be 2, since we aren't storing
 
     home = schema.getField("home_ns");
     assertNotNull(home);
@@ -179,4 +181,4 @@ public class PolyFieldTest extends SolrT
     clearIndex();
   }
 
-}
\ No newline at end of file
+}

Modified: lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/schema.xml?rev=1446934&r1=1446933&r2=1446934&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/schema.xml (original)
+++ lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/schema.xml Sat Feb 16 20:16:12 2013
@@ -70,6 +70,15 @@
        <types> fieldType section
      indexed: true if this field should be indexed (searchable or sortable)
      stored: true if this field should be retrievable
+     docValues: true if this field should have doc values. Doc values are
+       useful for faceting, grouping, sorting and function queries. Although not
+       required, doc values will make the index faster to load, more
+       NRT-friendly and more memory-efficient. They however come with some
+       limitations: they are currently only supported by StrField, UUIDField
+       and all Trie*Fields, and depending on the field type, they might
+       require the field to be single-valued, be required or have a default
+       value (check the documentation of the field type you're interested in
+       for more information)
      multiValued: true if this field may contain multiple values per document
      omitNorms: (expert) set to true to omit the norms associated with
        this field (this disables length normalization and index-time
@@ -156,6 +165,17 @@
 
    <field name="_version_" type="long" indexed="true" stored="true"/>
 
+   <!--
+     Some fields such as popularity and manu_exact could be modified to
+     leverage doc values:
+     <field name="popularity" type="int" indexed="true" stored="true" docValues="true" default="0" />
+     <field name="manu_exact" type="string" indexed="false" stored="false" docValues="true" default="" />
+
+     Although it would make indexing slightly slower and the index bigger, it
+     would also make the index faster to load, more memory-efficient and more
+     NRT-friendly.
+     -->
+
    <!-- Uncommenting the following will create a "timestamp" field using
         a default value of "NOW" to indicate when each document was indexed.
      -->
@@ -282,7 +302,10 @@
        standard package such as org.apache.solr.analysis
     -->
 
-    <!-- The StrField type is not analyzed, but indexed/stored verbatim. -->
+    <!-- The StrField type is not analyzed, but indexed/stored verbatim.
+       It supports doc values but in that case the field needs to be
+       single-valued and either required or have a default value.
+      -->
     <fieldType name="string" class="solr.StrField" sortMissingLast="true" />
 
     <!-- boolean type: "true" or "false" -->
@@ -306,6 +329,9 @@
 
     <!--
       Default numeric field types. For faster range queries, consider the tint/tfloat/tlong/tdouble types.
+
+      These fields support doc values, but they require the field to be
+      single-valued and either be required or have a default value.
     -->
     <fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>
     <fieldType name="float" class="solr.TrieFloatField" precisionStep="0" positionIncrementGap="0"/>