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 2015/01/14 09:05:37 UTC
svn commit: r1651588 - in /lucene/dev/branches/branch_5x: ./ 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/apache/solr...
Author: noble
Date: Wed Jan 14 08:05:36 2015
New Revision: 1651588
URL: http://svn.apache.org/r1651588
Log:
SOLR-6937 In schemaless mode ,replace spaces and special characters with underscore
Added:
lucene/dev/branches/branch_5x/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/branch_5x/ (props changed)
lucene/dev/branches/branch_5x/solr/ (props changed)
lucene/dev/branches/branch_5x/solr/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_5x/solr/core/ (props changed)
lucene/dev/branches/branch_5x/solr/server/ (props changed)
lucene/dev/branches/branch_5x/solr/server/solr/configsets/data_driven_schema_configs/conf/solrconfig.xml
lucene/dev/branches/branch_5x/solr/solrj/ (props changed)
lucene/dev/branches/branch_5x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestsBase.java
lucene/dev/branches/branch_5x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java
Modified: lucene/dev/branches/branch_5x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/CHANGES.txt?rev=1651588&r1=1651587&r2=1651588&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Wed Jan 14 08:05:36 2015
@@ -262,6 +262,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/branch_5x/solr/server/solr/configsets/data_driven_schema_configs/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/server/solr/configsets/data_driven_schema_configs/conf/solrconfig.xml?rev=1651588&r1=1651587&r2=1651588&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/server/solr/configsets/data_driven_schema_configs/conf/solrconfig.xml (original)
+++ lucene/dev/branches/branch_5x/solr/server/solr/configsets/data_driven_schema_configs/conf/solrconfig.xml Wed Jan 14 08:05:36 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/branch_5x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestsBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestsBase.java?rev=1651588&r1=1651587&r2=1651588&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestsBase.java (original)
+++ lucene/dev/branches/branch_5x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestsBase.java Wed Jan 14 08:05:36 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/branch_5x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java?rev=1651588&r1=1651587&r2=1651588&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java (original)
+++ lucene/dev/branches/branch_5x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java Wed Jan 14 08:05:36 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() {