You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2016/06/16 12:08:46 UTC

[16/50] [abbrv] lucene-solr:apiv2: SOLR-9187: Support dates and booleans in /export handler, support boolean DocValues fields

SOLR-9187: Support dates and booleans in /export handler, support boolean DocValues fields


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/79d1b8c2
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/79d1b8c2
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/79d1b8c2

Branch: refs/heads/apiv2
Commit: 79d1b8c22768b6c902a4e880698733277796820c
Parents: 32c8dfa
Author: Erick Erickson <er...@apache.org>
Authored: Sat Jun 11 10:25:07 2016 -0700
Committer: Erick Erickson <er...@apache.org>
Committed: Sat Jun 11 17:33:25 2016 -0700

----------------------------------------------------------------------
 .../apache/solr/schema/BooleanFieldTest.java    | 78 ++++++++++++++++++++
 1 file changed, 78 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/79d1b8c2/solr/core/src/test/org/apache/solr/schema/BooleanFieldTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/schema/BooleanFieldTest.java b/solr/core/src/test/org/apache/solr/schema/BooleanFieldTest.java
new file mode 100644
index 0000000..8f13204
--- /dev/null
+++ b/solr/core/src/test/org/apache/solr/schema/BooleanFieldTest.java
@@ -0,0 +1,78 @@
+package org.apache.solr.schema;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.solr.SolrTestCaseJ4;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class BooleanFieldTest extends SolrTestCaseJ4 {
+  @BeforeClass
+  public static void beforeClass() throws Exception {
+    initCore("solrconfig-basic.xml", "schema15.xml");
+  }
+
+  // Note, docValues-based boolean tests are tested elsewhere refering to more appropriate schemas
+  @Test
+  public void testBoolField() {
+
+    // found an odd case when adding booleans to docValues and noticed that we didn't have any boolean
+    // specific tests. Only caught the odd case by accident so let's have a place for explicit tests
+    assertU(adoc("id", "0")); // missing
+    assertU(adoc("id", "1", "bind", "true", "bsto", "true", "bindsto", "true", "bindstom", "true", "bindstom", "false"));
+    assertU(adoc("id", "2", "bind", "false", "bsto", "false", "bindsto", "false", "bindstom", "false", "bindstom", "true"));
+    assertU(adoc("id", "3", "bind", "false"));
+    assertU(adoc("id", "4", "bsto", "false"));
+    assertU(adoc("id", "5", "bindsto", "true"));
+    assertU(adoc("id", "6", "bindstom", "true"));
+    assertU(commit());
+
+    assertQ(req("q", "*:*", "sort", "id asc", "fl", "id,bind,bsto,bindsto,bindstom")
+        ,"count(//result/doc[1]/bool[@name='bind'])=0"
+        ,"count(//result/doc[1]/bool[@name='bsto'])=0"
+        ,"count(//result/doc[1]/bool[@name='bindsto'])=0"
+        ,"count(//result/doc[2]/bool[@name='bind'])=0"
+        ,"count(//result/doc[3]/bool[@name='bind'])=0"
+        ,"//result/doc[2]/bool[@name='bsto'][.='true']"
+        ,"//result/doc[2]/bool[@name='bindsto'][.='true']"
+        ,"//result/doc[3]/bool[@name='bsto'][.='false']"
+        ,"//result/doc[3]/bool[@name='bindsto'][.='false']"
+        ,"//result/doc[2]/arr[@name='bindstom']/bool[1][.='true']"
+        ,"//result/doc[2]/arr[@name='bindstom']/bool[2][.='false']"
+        ,"//result/doc[3]/arr[@name='bindstom']/bool[1][.='false']"
+        ,"//result/doc[3]/arr[@name='bindstom']/bool[2][.='true']"
+
+    );
+    
+    // Make sure faceting is behaving.
+    assertQ(req("q", "*:*", "facet", "true", 
+        "facet.field", "bind", 
+        "facet.field", "bsto",
+        "facet.field", "bindsto",
+        "facet.field", "bindstom"),
+        "//lst[@name='bind']/int[@name='false'][.='2']",
+        "//lst[@name='bind']/int[@name='true'][.='1']",
+        "//lst[@name='bsto'][not(node())]",
+        "//lst[@name='bsto'][not(node())]",
+        "//lst[@name='bindsto']/int[@name='false'][.='1']",
+        "//lst[@name='bindsto']/int[@name='true'][.='2']",
+        "//lst[@name='bindstom']/int[@name='false'][.='2']",
+        "//lst[@name='bindstom']/int[@name='true'][.='3']");
+  }
+
+}