lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From no...@apache.org
Subject svn commit: r1651589 - in /lucene/dev/branches/lucene_solr_5_0: ./ solr/ solr/core/ solr/core/src/java/org/apache/solr/update/processor/ solr/server/ solr/server/solr/configsets/data_driven_schema_configs/conf/ solr/solrj/ solr/solrj/src/test/org/apach...
Date Wed, 14 Jan 2015 08:08:13 GMT
Author: noble
Date: Wed Jan 14 08:08:12 2015
New Revision: 1651589

URL: http://svn.apache.org/r1651589
Log:
SOLR-6937 In schemaless mode ,replace spaces and special characters with underscore

Added:
    lucene/dev/branches/lucene_solr_5_0/solr/core/src/java/org/apache/solr/update/processor/FieldNameMutatingUpdateProcessorFactory.java
      - copied unchanged from r1651587, lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/FieldNameMutatingUpdateProcessorFactory.java
Modified:
    lucene/dev/branches/lucene_solr_5_0/   (props changed)
    lucene/dev/branches/lucene_solr_5_0/solr/   (props changed)
    lucene/dev/branches/lucene_solr_5_0/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/lucene_solr_5_0/solr/core/   (props changed)
    lucene/dev/branches/lucene_solr_5_0/solr/server/   (props changed)
    lucene/dev/branches/lucene_solr_5_0/solr/server/solr/configsets/data_driven_schema_configs/conf/solrconfig.xml
    lucene/dev/branches/lucene_solr_5_0/solr/solrj/   (props changed)
    lucene/dev/branches/lucene_solr_5_0/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestsBase.java
    lucene/dev/branches/lucene_solr_5_0/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java

Modified: lucene/dev/branches/lucene_solr_5_0/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/CHANGES.txt?rev=1651589&r1=1651588&r2=1651589&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/CHANGES.txt (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/CHANGES.txt Wed Jan 14 08:08:12 2015
@@ -259,6 +259,8 @@ New Features
 
 * SOLR-6581: Efficient DocValues support and numeric collapse field implementations 
   for Collapse and Expand (Joel Bernstein)
+
+* SOLR-6937: In schemaless mode ,replace spaces and special characters with underscore (Noble
Paul)
   
 
 Bug Fixes

Modified: lucene/dev/branches/lucene_solr_5_0/solr/server/solr/configsets/data_driven_schema_configs/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/server/solr/configsets/data_driven_schema_configs/conf/solrconfig.xml?rev=1651589&r1=1651588&r2=1651589&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/server/solr/configsets/data_driven_schema_configs/conf/solrconfig.xml
(original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/server/solr/configsets/data_driven_schema_configs/conf/solrconfig.xml
Wed Jan 14 08:08:12 2015
@@ -1324,6 +1324,10 @@
     <processor class="solr.LogUpdateProcessorFactory"/>
     <processor class="solr.DistributedUpdateProcessorFactory"/>
     <processor class="solr.RemoveBlankFieldUpdateProcessorFactory"/>
+    <processor class="solr.FieldNameMutatingUpdateProcessorFactory">
+      <str name="pattern">[^\w-]</str>
+      <str name="replacement">_</str>
+    </processor>
     <processor class="solr.ParseBooleanFieldUpdateProcessorFactory"/>
     <processor class="solr.ParseLongFieldUpdateProcessorFactory"/>
     <processor class="solr.ParseDoubleFieldUpdateProcessorFactory"/>

Modified: lucene/dev/branches/lucene_solr_5_0/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestsBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestsBase.java?rev=1651589&r1=1651588&r2=1651589&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestsBase.java
(original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestsBase.java
Wed Jan 14 08:08:12 2015
@@ -258,12 +258,14 @@ abstract public class SolrExampleTestsBa
     assertEquals(10, cnt.get());
   }
   
-  protected void assertNumFound(String query, int num)
+  protected QueryResponse assertNumFound(String query, int num)
       throws SolrServerException, IOException {
     QueryResponse rsp = getSolrClient().query(new SolrQuery(query));
     if (num != rsp.getResults().getNumFound()) {
       fail("expected: " + num + " but had: " + rsp.getResults().getNumFound()
           + " :: " + rsp.getResults());
     }
+    return rsp;
+
   }
 }

Modified: lucene/dev/branches/lucene_solr_5_0/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java?rev=1651589&r1=1651588&r2=1651589&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java
(original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java
Wed Jan 14 08:08:12 2015
@@ -25,6 +25,8 @@ import org.apache.http.entity.InputStrea
 import org.apache.solr.client.solrj.impl.BinaryRequestWriter;
 import org.apache.solr.client.solrj.impl.BinaryResponseParser;
 import org.apache.solr.client.solrj.impl.HttpSolrClient;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.common.SolrDocument;
 import org.apache.solr.util.ExternalPaths;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -34,7 +36,11 @@ import org.slf4j.LoggerFactory;
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.OutputStreamWriter;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
 import java.util.Properties;
+import java.util.Set;
 
 public class SolrSchemalessExampleTest extends SolrExampleTestsBase {
   private static Logger log = LoggerFactory.getLogger(SolrSchemalessExampleTest.class);
@@ -83,6 +89,44 @@ public class SolrSchemalessExampleTest e
     assertNumFound("*:*", 2);
   }
 
+  @Test
+  public void testFieldMutating() throws Exception {
+    HttpSolrClient client = (HttpSolrClient) getSolrClient();
+    client.deleteByQuery("*:*");
+    client.commit();
+    assertNumFound("*:*", 0); // make sure it got in
+    // two docs, one with uniqueKey, another without it
+    String json = "{\"name one\": \"name\"} " +
+        "{\"name  two\" : \"name\"}" +
+        "{\"first-second\" : \"name\"}" +
+        "{\"x+y\" : \"name\"}" +
+        "{\"p%q\" : \"name\"}" +
+        "{\"a&b\" : \"name\"}"
+        ;
+    HttpClient httpClient = client.getHttpClient();
+    HttpPost post = new HttpPost(client.getBaseURL() + "/update/json/docs");
+    post.setHeader("Content-Type", "application/json");
+    post.setEntity(new InputStreamEntity(new ByteArrayInputStream(json.getBytes("UTF-8")),
-1));
+    HttpResponse response = httpClient.execute(post);
+    assertEquals(200, response.getStatusLine().getStatusCode());
+    client.commit();
+    List<String> expected = Arrays.asList(
+        "name_one",
+        "name__two",
+        "first-second",
+        "a_b",
+        "p_q",
+        "x_y");
+    HashSet set = new HashSet();
+    QueryResponse rsp = assertNumFound("*:*", expected.size());
+    for (SolrDocument doc : rsp.getResults()) set.addAll(doc.getFieldNames());
+    for (String s : expected) {
+      assertTrue(s+" not created "+ rsp ,set.contains(s) );
+    }
+
+  }
+
+
 
   @Override
   public SolrClient createNewSolrClient() {



Mime
View raw message