You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2014/10/16 13:26:40 UTC

svn commit: r1632275 [2/2] - in /lucene/dev/branches/lucene5969: ./ lucene/ lucene/backward-codecs/ lucene/backward-codecs/src/java/org/apache/lucene/codecs/ lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene40/ lucene/backward-codecs/src/...

Modified: lucene/dev/branches/lucene5969/solr/core/src/test-files/solr/collection1/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5969/solr/core/src/test-files/solr/collection1/conf/schema.xml?rev=1632275&r1=1632274&r2=1632275&view=diff
==============================================================================
--- lucene/dev/branches/lucene5969/solr/core/src/test-files/solr/collection1/conf/schema.xml (original)
+++ lucene/dev/branches/lucene5969/solr/core/src/test-files/solr/collection1/conf/schema.xml Thu Oct 16 11:26:38 2014
@@ -518,6 +518,9 @@
    <field name="timestamp" type="date" indexed="true" stored="true" docValues="true" default="NOW" multiValued="false"/>
    <field name="multiDefault" type="string" indexed="true" stored="true" default="muLti-Default" multiValued="true"/>
    <field name="intDefault" type="int" indexed="true" stored="true" default="42" multiValued="false"/>
+   <field name="intRemove" type="int" indexed="true" stored="true" multiValued="true"/>
+   <field name="dateRemove" type="date" indexed="true" stored="true" multiValued="true"/>
+   <field name="floatRemove" type="float" indexed="true" stored="true" multiValued="true"/>
 
    <field name="nopositionstext" type="nopositions" indexed="true" stored="true"/>
 

Modified: lucene/dev/branches/lucene5969/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdatesTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5969/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdatesTest.java?rev=1632275&r1=1632274&r2=1632275&view=diff
==============================================================================
--- lucene/dev/branches/lucene5969/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdatesTest.java (original)
+++ lucene/dev/branches/lucene5969/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdatesTest.java Thu Oct 16 11:26:38 2014
@@ -1,14 +1,18 @@
 package org.apache.solr.update.processor;
 
-import com.google.common.collect.ImmutableMap;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.schema.TrieDateField;
 import org.junit.Before;
 import org.junit.BeforeClass;
+import org.junit.Ignore;
 import org.junit.Test;
 
-import java.util.ArrayList;
-import java.util.List;
+import com.google.common.collect.ImmutableMap;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -108,6 +112,710 @@ public class AtomicUpdatesTest extends S
   }
 
   @Test
+  public void testRemoveInteger() throws Exception {
+    SolrInputDocument doc;
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1001");
+    doc.setField("intRemove", new String[]{"111", "222", "333", "333", "444"});
+    
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1002");
+    doc.setField("intRemove", new String[]{"111", "222", "222", "333", "444"});
+    assertU(adoc(doc));
+
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1020");
+    doc.setField("intRemove", new String[]{"111", "333", "444"});
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1021");
+    doc.setField("intRemove", new String[]{"111", "222", "444"});
+    assertU(adoc(doc));
+
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:222", "indent", "true"), "//result[@numFound = '3']");
+
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1001");
+    List<Long> removeList = new ArrayList<Long>();
+    removeList.add(new Long(222));
+    removeList.add(new Long(333));
+    doc.setField("intRemove", ImmutableMap.of("remove", removeList)); //behavior when hitting Solr through ZK
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:222", "indent", "true"), "//result[@numFound = '2']");
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1021");
+    removeList = new ArrayList<Long>();
+    removeList.add(new Long(222));
+    removeList.add(new Long(333));    
+    doc.setField("intRemove", ImmutableMap.of("remove", removeList)); //behavior when hitting Solr through ZK
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:222", "indent", "true"), "//result[@numFound = '1']");
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1001");
+    doc.setField("intRemove", ImmutableMap.of("remove", 111)); //behavior when hitting Solr directly
+
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:111", "indent", "true"), "//result[@numFound = '3']");
+  }
+
+
+  @Test
+  public void testRemoveIntegerInDocSavedWithInteger() throws Exception {
+    SolrInputDocument doc;
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1001");
+    doc.setField("intRemove", new Integer[]{111, 222, 333, 333, 444});
+    
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1002");
+    doc.setField("intRemove", new Integer[]{111, 222, 222, 333, 444});
+    assertU(adoc(doc));
+
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1020");
+    doc.setField("intRemove", new Integer[]{111, 333, 444});
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1021");
+    doc.setField("intRemove", new Integer[]{111, 222, 444});
+    assertU(adoc(doc));
+
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:222", "indent", "true"), "//result[@numFound = '3']");
+
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1001");
+    List<Long> removeList = new ArrayList<Long>();
+    removeList.add(new Long(222));
+    removeList.add(new Long(333));
+    doc.setField("intRemove", ImmutableMap.of("remove", removeList)); //behavior when hitting Solr through ZK
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:222", "indent", "true"), "//result[@numFound = '2']");
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1021");
+    removeList = new ArrayList<Long>();
+    removeList.add(new Long(222));
+    removeList.add(new Long(333));    
+    doc.setField("intRemove", ImmutableMap.of("remove", removeList)); //behavior when hitting Solr through ZK
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:222", "indent", "true"), "//result[@numFound = '1']");
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1001");
+    doc.setField("intRemove", ImmutableMap.of("remove", 111)); //behavior when hitting Solr directly
+
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:111", "indent", "true"), "//result[@numFound = '3']");
+  }
+
+  @Test
+  public void testRemoveIntegerUsingStringType() throws Exception {
+    SolrInputDocument doc;
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1001");
+    doc.setField("intRemove", new String[]{"111", "222", "333", "333", "444"});
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1002");
+    doc.setField("intRemove", new String[]{"111", "222", "222", "333", "444"});
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1020");
+    doc.setField("intRemove", new String[]{"111", "333", "444"});
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1021");
+    doc.setField("intRemove", new String[]{"111", "222", "444"});
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:222", "indent", "true"), "//result[@numFound = '3']");
+
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1001");
+    List<String> removeList = new ArrayList<String>();
+    removeList.add("222");
+    removeList.add("333");
+    doc.setField("intRemove", ImmutableMap.of("remove", removeList)); //behavior when hitting Solr through ZK
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:222", "indent", "true"), "//result[@numFound = '2']");
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1021");
+    removeList = new ArrayList<String>();
+    removeList.add("222");
+    removeList.add("333");
+    doc.setField("intRemove", ImmutableMap.of("remove", removeList)); //behavior when hitting Solr through ZK
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:222", "indent", "true"), "//result[@numFound = '1']");
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1001");
+    doc.setField("intRemove", ImmutableMap.of("remove", "111")); //behavior when hitting Solr directly
+
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:111", "indent", "true"), "//result[@numFound = '3']");
+  }
+
+  @Test
+  public void testRemoveIntegerUsingLongType() throws Exception {
+    SolrInputDocument doc;
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1001");
+    doc.setField("intRemove", new Long[]{111L, 222L, 333L, 333L, 444L});
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1002");
+    doc.setField("intRemove", new Long[]{111L, 222L, 222L, 333L, 444L});
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1020");
+    doc.setField("intRemove", new Long[]{111L, 333L, 444L});
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1021");
+    doc.setField("intRemove", new Long[]{111L, 222L, 444L});
+    assertU(adoc(doc));
+
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:222", "indent", "true"), "//result[@numFound = '3']");
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1001");
+    List<Long> removeList = new ArrayList<Long>();
+    removeList.add(222L);
+    removeList.add(333L);
+    doc.setField("intRemove", ImmutableMap.of("remove", removeList)); //behavior when hitting Solr through ZK
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:222", "indent", "true"), "//result[@numFound = '2']");
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1021");
+    removeList = new ArrayList<Long>();
+    removeList.add(222L);
+    removeList.add(333L);
+    doc.setField("intRemove", ImmutableMap.of("remove", removeList)); //behavior when hitting Solr through ZK
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:222", "indent", "true"), "//result[@numFound = '1']");
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1001");
+    doc.setField("intRemove", ImmutableMap.of("remove", 111L)); //behavior when hitting Solr directly
+
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:111", "indent", "true"), "//result[@numFound = '3']");
+  }
+
+
+  @Test
+  public void testRemoveIntegerUsingFloatType() throws Exception {
+    SolrInputDocument doc;
+
+    doc = new SolrInputDocument();
+//    add with float in integer field
+//    doc.setField("id", "1001");
+//    doc.setField("intRemove", new Float[]{111.10F, 222.20F, 333.30F, 333.30F, 444.40F});
+//    assertU(adoc(doc));
+//
+//    doc = new SolrInputDocument();
+//    doc.setField("id", "1002");
+//    doc.setField("intRemove", new Float[]{111.10F, 222.20F, 222.20F, 333.30F, 444.40F});
+//    assertU(adoc(doc));
+//
+//    doc = new SolrInputDocument();
+//    doc.setField("id", "1020");
+//    doc.setField("intRemove", new Float[]{111.10F, 333.30F, 444.40F});
+//    assertU(adoc(doc));
+//
+//    doc = new SolrInputDocument();
+//    doc.setField("id", "1021");
+//    doc.setField("intRemove", new Float[]{111.10F, 222.20F, 444.40F});
+
+    doc.setField("id", "1001");
+    doc.setField("intRemove", new String[]{"111", "222", "333", "333", "444"});
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1002");
+    doc.setField("intRemove", new String[]{"111", "222", "222", "333", "444"});
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1020");
+    doc.setField("intRemove", new String[]{"111", "333", "444"});
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1021");
+    doc.setField("intRemove", new String[]{"111", "222", "444"});    
+    assertU(adoc(doc));
+
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:222", "indent", "true"), "//result[@numFound = '3']");
+
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1001");
+    List<Float> removeList = new ArrayList<Float>();
+    removeList.add(222.20F);
+    removeList.add(333.30F);
+    doc.setField("intRemove", ImmutableMap.of("remove", removeList)); //behavior when hitting Solr through ZK
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:222", "indent", "true"), "//result[@numFound = '2']");
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1021");
+    removeList = new ArrayList<Float>();
+    removeList.add(222.20F);
+    removeList.add(333.30F);
+    doc.setField("intRemove", ImmutableMap.of("remove", removeList)); //behavior when hitting Solr through ZK
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:222", "indent", "true"), "//result[@numFound = '1']");
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1001");
+    doc.setField("intRemove", ImmutableMap.of("remove", 111L)); //behavior when hitting Solr directly
+
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:111", "indent", "true"), "//result[@numFound = '3']");
+  }
+  
+
+  @Test
+  public void testRemoveIntegerUsingDoubleType() throws Exception {
+    SolrInputDocument doc;
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1001");
+    doc.setField("intRemove", new String[]{"11111111", "22222222", "33333333", "33333333", "44444444"});
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1002");
+    doc.setField("intRemove", new String[]{"11111111", "22222222", "22222222", "33333333", "44444444"});
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1020");
+    doc.setField("intRemove", new String[]{"11111111", "33333333", "44444444"});
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1021");
+    doc.setField("intRemove", new String[]{"11111111", "22222222", "44444444"});
+    assertU(adoc(doc));
+
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:22222222", "indent", "true"), "//result[@numFound = '3']");
+
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1001");
+    List<Double> removeList = new ArrayList<Double>();
+    removeList.add(22222222D);
+    removeList.add(33333333D);
+    doc.setField("intRemove", ImmutableMap.of("remove", removeList)); //behavior when hitting Solr through ZK
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:22222222", "indent", "true"), "//result[@numFound = '2']");
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1021");
+    removeList = new ArrayList<Double>();
+    removeList.add(22222222D);
+    removeList.add(33333333D);
+    doc.setField("intRemove", ImmutableMap.of("remove", removeList)); //behavior when hitting Solr through ZK
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:22222222", "indent", "true"), "//result[@numFound = '1']");
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "1001");
+    doc.setField("intRemove", ImmutableMap.of("remove", 11111111D)); //behavior when hitting Solr directly
+
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "intRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "intRemove:11111111", "indent", "true"), "//result[@numFound = '3']");
+  }
+  
+  @Test
+  public void testRemoveDateUsingStringType() throws Exception {
+    SolrInputDocument doc;
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10001");
+    doc.setField("dateRemove", new String[]{"2014-09-01T12:00:00Z", "2014-09-02T12:00:00Z", "2014-09-03T12:00:00Z", "2014-09-03T12:00:00Z", "2014-09-04T12:00:00Z"});
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10002");
+    doc.setField("dateRemove", new String[]{"2014-09-01T12:00:00Z", "2014-09-02T12:00:00Z", "2014-09-02T12:00:00Z", "2014-09-03T12:00:00Z", "2014-09-04T12:00:00Z"});
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10020");
+    doc.setField("dateRemove", new String[]{"2014-09-01T12:00:00Z", "2014-09-03T12:00:00Z", "2014-09-04T12:00:00Z"});
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10021");
+    doc.setField("dateRemove", new String[]{"2014-09-01T12:00:00Z", "2014-09-02T12:00:00Z", "2014-09-04T12:00:00Z"});
+    assertU(adoc(doc));
+
+    assertU(commit());
+
+    assertQ(req("q", "dateRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "dateRemove:\"2014-09-02T12:00:00Z\"", "indent", "true"), "//result[@numFound = '3']");
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10001");
+    List<String> removeList = new ArrayList<String>();
+    removeList.add("2014-09-02T12:00:00Z");
+    removeList.add("2014-09-03T12:00:00Z");
+
+    doc.setField("dateRemove", ImmutableMap.of("remove", removeList)); //behavior when hitting Solr through ZK
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "dateRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "dateRemove:\"2014-09-02T12:00:00Z\"", "indent", "true"), "//result[@numFound = '2']");
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10021");
+    removeList = new ArrayList<String>();
+    removeList.add("2014-09-02T12:00:00Z");
+    removeList.add("2014-09-03T12:00:00Z");
+    doc.setField("dateRemove", ImmutableMap.of("remove", removeList)); //behavior when hitting Solr through ZK
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "dateRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "dateRemove:\"2014-09-02T12:00:00Z\"", "indent", "true"), "//result[@numFound = '1']");
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10001");
+    doc.setField("dateRemove", ImmutableMap.of("remove", "2014-09-01T12:00:00Z")); //behavior when hitting Solr directly
+
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "dateRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "dateRemove:\"2014-09-01T12:00:00Z\"", "indent", "true"), "//result[@numFound = '3']");
+  }
+  
+  @Ignore("Remove Date is not supported in other formats than UTC")
+  @Test
+  public void testRemoveDateUsingDateType() throws Exception {
+    SolrInputDocument doc;
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10001");
+    TrieDateField trieDF = new TrieDateField();
+    Date tempDate = trieDF.parseMath(null, "2014-02-01T12:00:00Z");
+    doc.setField("dateRemove", new Date[]{trieDF.parseMath(null, "2014-02-01T12:00:00Z"), 
+        trieDF.parseMath(null, "2014-07-02T12:00:00Z"),
+        trieDF.parseMath(null, "2014-02-03T12:00:00Z"),
+        trieDF.parseMath(null, "2014-02-03T12:00:00Z"),
+        trieDF.parseMath(null, "2014-02-04T12:00:00Z")
+        });
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10002");
+    doc.setField("dateRemove", new Date[]{trieDF.parseMath(null, "2014-02-01T12:00:00Z"), 
+        trieDF.parseMath(null, "2014-07-02T12:00:00Z"),
+        trieDF.parseMath(null, "2014-02-02T12:00:00Z"),
+        trieDF.parseMath(null, "2014-02-03T12:00:00Z"),
+        trieDF.parseMath(null, "2014-02-04T12:00:00Z")
+        });
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10020");
+    doc.setField("dateRemove", new Date[]{trieDF.parseMath(null, "2014-02-01T12:00:00Z"), 
+        trieDF.parseMath(null, "2014-02-03T12:00:00Z"),
+        trieDF.parseMath(null, "2014-02-04T12:00:00Z")
+        });
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10021");
+    doc.setField("dateRemove", new Date[]{trieDF.parseMath(null, "2014-02-01T12:00:00Z"), 
+        trieDF.parseMath(null, "2014-02-02T12:00:00Z"),
+        trieDF.parseMath(null, "2014-02-04T12:00:00Z")
+        });
+    assertU(adoc(doc));
+
+    assertU(commit());
+
+    assertQ(req("q", "dateRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    String dateString = trieDF.parseMath(null, "2014-02-02T12:00:00Z").toString();
+//    assertQ(req("q", "dateRemove:"+URLEncoder.encode(dateString, "UTF-8"), "indent", "true"), "//result[@numFound = '3']");
+//    assertQ(req("q", "dateRemove:\"2014-09-02T12:00:00Z\"", "indent", "true"), "//result[@numFound = '3']");
+//    assertQ(req("q", "dateRemove:"+dateString, "indent", "true"), "//result[@numFound = '3']"); //Sun Feb 02 10:00:00 FNT 2014
+    assertQ(req("q", "dateRemove:\"Sun Feb 02 10:00:00 FNT 2014\"", "indent", "true"), "//result[@numFound = '3']"); //Sun Feb 02 10:00:00 FNT 2014
+
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10001");
+    List<Date> removeList = new ArrayList<Date>();
+    removeList.add(trieDF.parseMath(null, "2014-09-02T12:00:00Z"));
+    removeList.add(trieDF.parseMath(null, "2014-09-03T12:00:00Z"));
+
+    doc.setField("dateRemove", ImmutableMap.of("remove", removeList)); //behavior when hitting Solr through ZK
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "dateRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "dateRemove:\"2014-09-02T12:00:00Z\"", "indent", "true"), "//result[@numFound = '2']");
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10021");
+    removeList = new ArrayList<Date>();
+    removeList.add(trieDF.parseMath(null, "2014-09-02T12:00:00Z"));
+    removeList.add(trieDF.parseMath(null, "2014-09-03T12:00:00Z"));
+    doc.setField("dateRemove", ImmutableMap.of("remove", removeList)); //behavior when hitting Solr through ZK
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "dateRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "dateRemove:\"2014-09-02T12:00:00Z\"", "indent", "true"), "//result[@numFound = '1']");
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10001");
+    doc.setField("dateRemove", ImmutableMap.of("remove", trieDF.parseMath(null, "2014-09-01T12:00:00Z"))); //behavior when hitting Solr directly
+
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "dateRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "dateRemove:\"2014-09-01T12:00:00Z\"", "indent", "true"), "//result[@numFound = '3']");
+  }
+ 
+  @Test
+  public void testRemoveFloatUsingFloatType() throws Exception {
+    SolrInputDocument doc;
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10001");
+    doc.setField("floatRemove", new Float[]{111.111F, 222.222F, 333.333F, 333.333F, 444.444F});
+
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10002");
+    doc.setField("floatRemove", new Float[]{111.111F, 222.222F, 222.222F, 333.333F, 444.444F});
+    assertU(adoc(doc));
+
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10020");
+    doc.setField("floatRemove", new Float[]{111.111F, 333.333F, 444.444F});
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10021");
+    doc.setField("floatRemove", new Float[]{111.111F, 222.222F, 444.444F});
+    assertU(adoc(doc));
+
+    assertU(commit());
+
+    assertQ(req("q", "floatRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "floatRemove:\"222.222\"", "indent", "true"), "//result[@numFound = '3']");
+
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10001");
+    List<Float> removeList = new ArrayList<Float>();
+    removeList.add(222.222F);
+    removeList.add(333.333F);
+
+    doc.setField("floatRemove", ImmutableMap.of("remove", removeList)); //behavior when hitting Solr through ZK
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "floatRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "floatRemove:\"222.222\"", "indent", "true"), "//result[@numFound = '2']");
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10021");
+    removeList = new ArrayList<Float>();
+    removeList.add(222.222F);
+    removeList.add(333.333F);
+    doc.setField("floatRemove", ImmutableMap.of("remove", removeList)); //behavior when hitting Solr through ZK
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "floatRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "floatRemove:\"222.222\"", "indent", "true"), "//result[@numFound = '1']");
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10001");
+    doc.setField("floatRemove", ImmutableMap.of("remove", "111.111")); //behavior when hitting Solr directly
+
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "floatRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "floatRemove:\"111.111\"", "indent", "true"), "//result[@numFound = '3']");
+  }
+  
+  @Test
+  public void testRemoveFloatUsingStringType() throws Exception {
+    SolrInputDocument doc;
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10001");
+    doc.setField("floatRemove", new String[]{"111.111", "222.222", "333.333", "333.333", "444.444"});
+
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10002");
+    doc.setField("floatRemove", new String[]{"111.111", "222.222", "222.222", "333.333", "444.444"});
+    assertU(adoc(doc));
+
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10020");
+    doc.setField("floatRemove", new String[]{"111.111", "333.333", "444.444"});
+    assertU(adoc(doc));
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10021");
+    doc.setField("floatRemove", new String[]{"111.111", "222.222", "444.444"});
+    assertU(adoc(doc));
+
+    assertU(commit());
+
+    assertQ(req("q", "floatRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "floatRemove:\"222.222\"", "indent", "true"), "//result[@numFound = '3']");
+
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10001");
+    List<String> removeList = new ArrayList<String>();
+    removeList.add("222.222");
+    removeList.add("333.333");
+
+    doc.setField("floatRemove", ImmutableMap.of("remove", removeList)); //behavior when hitting Solr through ZK
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "floatRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "floatRemove:\"222.222\"", "indent", "true"), "//result[@numFound = '2']");
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10021");
+    removeList = new ArrayList<String>();
+    removeList.add("222.222");
+    removeList.add("333.333");
+    doc.setField("floatRemove", ImmutableMap.of("remove", removeList)); //behavior when hitting Solr through ZK
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "floatRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "floatRemove:\"222.222\"", "indent", "true"), "//result[@numFound = '1']");
+
+    doc = new SolrInputDocument();
+    doc.setField("id", "10001");
+    doc.setField("floatRemove", ImmutableMap.of("remove", "111.111")); //behavior when hitting Solr directly
+
+    assertU(adoc(doc));
+    assertU(commit());
+
+    assertQ(req("q", "floatRemove:*", "indent", "true"), "//result[@numFound = '4']");
+    assertQ(req("q", "floatRemove:\"111.111\"", "indent", "true"), "//result[@numFound = '3']");
+  }
+
+  @Test
   public void testAdd() throws Exception {
     SolrInputDocument doc = new SolrInputDocument();
     doc.setField("id", "3");

Modified: lucene/dev/branches/lucene5969/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5969/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java?rev=1632275&r1=1632274&r2=1632275&view=diff
==============================================================================
--- lucene/dev/branches/lucene5969/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java (original)
+++ lucene/dev/branches/lucene5969/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java Thu Oct 16 11:26:38 2014
@@ -96,6 +96,7 @@ public class CloudSolrServer extends Sol
   private final LBHttpSolrServer lbServer;
   private final boolean shutdownLBHttpSolrServer;
   private HttpClient myClient;
+  private final boolean clientIsInternal;
   //no of times collection state to be reloaded if stale state error is received
   private static final int MAX_STALE_RETRIES = 5;
   Random rand = new Random();
@@ -177,6 +178,7 @@ public class CloudSolrServer extends Sol
    */
   public CloudSolrServer(String zkHost) {
       this.zkHost = zkHost;
+      this.clientIsInternal = true;
       this.myClient = HttpClientUtil.createClient(null);
       this.lbServer = new LBHttpSolrServer(myClient);
       this.lbServer.setRequestWriter(new BinaryRequestWriter());
@@ -184,7 +186,41 @@ public class CloudSolrServer extends Sol
       this.updatesToLeaders = true;
       shutdownLBHttpSolrServer = true;
       lbServer.addQueryParams(STATE_VERSION);
+  }
 
+  /**
+   * Create a new client object that connects to Zookeeper and is always aware
+   * of the SolrCloud state. If there is a fully redundant Zookeeper quorum and
+   * SolrCloud has enough replicas for every shard in a collection, there is no
+   * single point of failure. Updates will be sent to shard leaders by default.
+   *
+   * @param zkHost
+   *          The client endpoint of the zookeeper quorum containing the cloud
+   *          state. The full specification for this string is one or more comma
+   *          separated HOST:PORT values, followed by an optional chroot value
+   *          that starts with a forward slash. Using a chroot allows multiple
+   *          applications to coexist in one ensemble. For full details, see the
+   *          Zookeeper documentation. Some examples:
+   *          <p/>
+   *          "host1:2181"
+   *          <p/>
+   *          "host1:2181,host2:2181,host3:2181/mysolrchroot"
+   *          <p/>
+   *          "zoo1.example.com:2181,zoo2.example.com:2181,zoo3.example.com:2181"
+   * @param httpClient
+   *          the {@link HttpClient} instance to be used for all requests. The
+   *          provided httpClient should use a multi-threaded connection manager.
+   */
+  public CloudSolrServer(String zkHost, HttpClient httpClient)  {
+    this.zkHost = zkHost;
+    this.clientIsInternal = httpClient == null;
+    this.myClient = httpClient == null ? HttpClientUtil.createClient(null) : httpClient;
+    this.lbServer = new LBHttpSolrServer(myClient);
+    this.lbServer.setRequestWriter(new BinaryRequestWriter());
+    this.lbServer.setParser(new BinaryResponseParser());
+    this.updatesToLeaders = true;
+    shutdownLBHttpSolrServer = true;
+    lbServer.addQueryParams(STATE_VERSION);
   }
   
   /**
@@ -206,7 +242,31 @@ public class CloudSolrServer extends Sol
    * @see #CloudSolrServer(String)
    */
   public CloudSolrServer(Collection<String> zkHosts, String chroot) {
-    
+    this(zkHosts, chroot, null);
+  }
+
+  /**
+   * Create a new client object using multiple string values in a Collection
+   * instead of a standard zkHost connection string. Note that this method will
+   * not be used if there is only one String argument - that will use
+   * {@link #CloudSolrServer(String)} instead.
+   *
+   * @param zkHosts
+   *          A Java Collection (List, Set, etc) of HOST:PORT strings, one for
+   *          each host in the zookeeper ensemble. Note that with certain
+   *          Collection types like HashSet, the order of hosts in the final
+   *          connect string may not be in the same order you added them.
+   * @param chroot
+   *          A chroot value for zookeeper, starting with a forward slash. If no
+   *          chroot is required, use null.
+   * @param httpClient
+   *          the {@link HttpClient} instance to be used for all requests. The provided httpClient should use a
+   *          multi-threaded connection manager.
+   * @throws IllegalArgumentException
+   *           if the chroot value does not start with a forward slash.
+   * @see #CloudSolrServer(String)
+   */
+  public CloudSolrServer(Collection<String> zkHosts, String chroot, HttpClient httpClient) {
     StringBuilder zkBuilder = new StringBuilder();
     int lastIndexValue = zkHosts.size() - 1;
     int i = 0;
@@ -225,12 +285,13 @@ public class CloudSolrServer extends Sol
             "The chroot must start with a forward slash.");
       }
     }
-    
+
     /* Log the constructed connection string and then initialize. */
     log.info("Final constructed zkHost string: " + zkBuilder.toString());
-    
+
     this.zkHost = zkBuilder.toString();
-    this.myClient = HttpClientUtil.createClient(null);
+    this.clientIsInternal = httpClient == null;
+    this.myClient = httpClient == null ? HttpClientUtil.createClient(null) : httpClient;
     this.lbServer = new LBHttpSolrServer(myClient);
     this.lbServer.setRequestWriter(new BinaryRequestWriter());
     this.lbServer.setParser(new BinaryResponseParser());
@@ -246,8 +307,23 @@ public class CloudSolrServer extends Sol
    * @see #CloudSolrServer(String) for full description and details on zkHost
    */
   public CloudSolrServer(String zkHost, boolean updatesToLeaders) {
+    this(zkHost, updatesToLeaders, null);
+  }
+
+  /**
+   * @param zkHost
+   *          A zookeeper client endpoint.
+   * @param updatesToLeaders
+   *          If true, sends updates only to shard leaders.
+   * @param httpClient
+   *          the {@link HttpClient} instance to be used for all requests. The provided httpClient should use a
+   *          multi-threaded connection manager.
+   * @see #CloudSolrServer(String) for full description and details on zkHost
+   */
+  public CloudSolrServer(String zkHost, boolean updatesToLeaders, HttpClient httpClient) {
     this.zkHost = zkHost;
-    this.myClient = HttpClientUtil.createClient(null);
+    this.clientIsInternal = httpClient == null;
+    this.myClient = httpClient == null ? HttpClientUtil.createClient(null) : httpClient;
     this.lbServer = new LBHttpSolrServer(myClient);
     this.lbServer.setRequestWriter(new BinaryRequestWriter());
     this.lbServer.setParser(new BinaryResponseParser());
@@ -289,8 +365,8 @@ public class CloudSolrServer extends Sol
     this.lbServer = lbServer;
     this.updatesToLeaders = updatesToLeaders;
     shutdownLBHttpSolrServer = false;
+    this.clientIsInternal = false;
     lbServer.addQueryParams(STATE_VERSION);
-
   }
   
   public ResponseParser getParser() {
@@ -978,7 +1054,7 @@ public class CloudSolrServer extends Sol
       lbServer.shutdown();
     }
     
-    if (myClient!=null) {
+    if (clientIsInternal && myClient!=null) {
       myClient.getConnectionManager().shutdown();
     }
 

Modified: lucene/dev/branches/lucene5969/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5969/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java?rev=1632275&r1=1632274&r2=1632275&view=diff
==============================================================================
--- lucene/dev/branches/lucene5969/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java (original)
+++ lucene/dev/branches/lucene5969/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java Thu Oct 16 11:26:38 2014
@@ -45,8 +45,9 @@ import java.util.*;
  * Do <b>NOT</b> use this class for indexing in master/slave scenarios since documents must be sent to the
  * correct master; no inter-node routing is done.
  *
- * In SolrCloud (leader/replica) scenarios, this class may be used for updates since updates will be forwarded
- * to the appropriate leader.
+ * In SolrCloud (leader/replica) scenarios, it is usually better to use
+ * {@link org.apache.solr.client.solrj.impl.CloudSolrServer}, but this class may be used
+ * for updates because the server will forward them to the appropriate leader.
  *
  * Also see the <a href="http://wiki.apache.org/solr/LBHttpSolrServer">wiki</a> page.
  *
@@ -631,6 +632,9 @@ public class LBHttpSolrServer extends So
     };
   }
 
+  /**
+   * Return the HttpClient this instance uses.
+   */
   public HttpClient getHttpClient() {
     return httpClient;
   }
@@ -638,11 +642,25 @@ public class LBHttpSolrServer extends So
   public ResponseParser getParser() {
     return parser;
   }
-  
+
+  /**
+   * Changes the {@link ResponseParser} that will be used for the internal
+   * SolrServer objects.
+   *
+   * @param parser Default Response Parser chosen to parse the response if the parser
+   *               were not specified as part of the request.
+   * @see org.apache.solr.client.solrj.SolrRequest#getResponseParser()
+   */
   public void setParser(ResponseParser parser) {
     this.parser = parser;
   }
-  
+
+  /**
+   * Changes the {@link RequestWriter} that will be used for the internal
+   * SolrServer objects.
+   *
+   * @param requestWriter Default RequestWriter, used to encode requests sent to the server.
+   */
   public void setRequestWriter(RequestWriter requestWriter) {
     this.requestWriter = requestWriter;
   }

Modified: lucene/dev/branches/lucene5969/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrServerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5969/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrServerTest.java?rev=1632275&r1=1632274&r2=1632275&view=diff
==============================================================================
--- lucene/dev/branches/lucene5969/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrServerTest.java (original)
+++ lucene/dev/branches/lucene5969/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrServerTest.java Thu Oct 16 11:26:38 2014
@@ -32,6 +32,7 @@ import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 
+import org.apache.http.client.HttpClient;
 import org.apache.lucene.util.LuceneTestCase.Slow;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrServerException;
@@ -122,6 +123,7 @@ public class CloudSolrServerTest extends
   public void doTest() throws Exception {
     allTests();
     stateVersionParamTest();
+    customHttpClientTest();
   }
 
   private void allTests() throws Exception {
@@ -439,4 +441,20 @@ public class CloudSolrServerTest extends
     // see SOLR-6146 - this test will fail by virtue of the zkClient tracking performed
     // in the afterClass method of the base class
   }
+
+  public void customHttpClientTest() {
+    CloudSolrServer server = null;
+    ModifiableSolrParams params = new ModifiableSolrParams();
+    params.set(HttpClientUtil.PROP_SO_TIMEOUT, 1000);
+    HttpClient client = null;
+
+    try {
+      client = HttpClientUtil.createClient(params);
+      server = new CloudSolrServer(zkServer.getZkAddress(), client);
+      assertTrue(server.getLbServer().getHttpClient() == client);
+    } finally {
+      server.shutdown();
+      client.getConnectionManager().shutdown();
+    }
+  }
 }