You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2014/08/27 02:37:48 UTC
svn commit: r1620768 - in /lucene/dev/trunk/solr: CHANGES.txt
example/example-schemaless/solr/collection1/conf/solrconfig.xml
solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTests.java
Author: shalin
Date: Wed Aug 27 00:37:48 2014
New Revision: 1620768
URL: http://svn.apache.org/r1620768
Log:
SOLR-6437: Managed schema is not enabled with /update/json and /update/json/docs request handlers
Modified:
lucene/dev/trunk/solr/CHANGES.txt
lucene/dev/trunk/solr/example/example-schemaless/solr/collection1/conf/solrconfig.xml
lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTests.java
Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1620768&r1=1620767&r2=1620768&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Wed Aug 27 00:37:48 2014
@@ -227,7 +227,7 @@ New Features
a UUID into the unique Key field.
(Vitaliy Zhovtyuk, hossman, Steve Rowe, Erik Hatcher, shalin)
-* SOLR-6294: Remove the restriction of adding json by only wrapping it in an array in a
+* SOLR-6294: SOLR-6437: Remove the restriction of adding json by only wrapping it in an array in a
new path /update/json/docs (Noble Paul , hossman, Yonik Seeley, Steve Rowe)
* SOLR-6302: UpdateRequestHandlers are registered implicitly /update ,
Modified: lucene/dev/trunk/solr/example/example-schemaless/solr/collection1/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/example-schemaless/solr/collection1/conf/solrconfig.xml?rev=1620768&r1=1620767&r2=1620768&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/example-schemaless/solr/collection1/conf/solrconfig.xml (original)
+++ lucene/dev/trunk/solr/example/example-schemaless/solr/collection1/conf/solrconfig.xml Wed Aug 27 00:37:48 2014
@@ -1001,6 +1001,29 @@
</lst>
</requestHandler>
+ <requestHandler name="/update/json" class="solr.UpdateRequestHandler">
+ <!-- See below for information on defining
+ updateRequestProcessorChains that can be used by name
+ on each Update Request
+ -->
+ <lst name="defaults">
+ <str name="update.contentType">application/json</str>
+ <str name="update.chain">add-unknown-fields-to-the-schema</str>
+ </lst>
+ </requestHandler>
+
+ <requestHandler name="/update/json/docs" class="solr.UpdateRequestHandler">
+ <!-- See below for information on defining
+ updateRequestProcessorChains that can be used by name
+ on each Update Request
+ -->
+ <lst name="defaults">
+ <str name="update.contentType">application/json</str>
+ <str name="update.chain">add-unknown-fields-to-the-schema</str>
+ <bool name="json.command">false</bool>
+ </lst>
+ </requestHandler>
+
<!-- Solr Cell Update Request Handler
http://wiki.apache.org/solr/ExtractingRequestHandler
Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTests.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTests.java?rev=1620768&r1=1620767&r2=1620768&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTests.java (original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTests.java Wed Aug 27 00:37:48 2014
@@ -17,14 +17,22 @@
package org.apache.solr.client.solrj;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.InputStreamEntity;
import org.apache.solr.client.solrj.impl.BinaryRequestWriter;
import org.apache.solr.client.solrj.impl.BinaryResponseParser;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
+import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.util.ExternalPaths;
import org.junit.BeforeClass;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.ByteArrayInputStream;
+
public class SolrSchemalessExampleTests extends SolrExampleTestsBase {
private static Logger log = LoggerFactory
.getLogger(SolrSchemalessExampleTests.class);
@@ -33,7 +41,27 @@ public class SolrSchemalessExampleTests
public static void beforeTest() throws Exception {
createJetty(ExternalPaths.EXAMPLE_SCHEMALESS_HOME, null, null);
}
-
+
+ @Test
+ public void testArbitraryJsonIndexing() throws Exception {
+ HttpSolrServer server = (HttpSolrServer) getSolrServer();
+ server.deleteByQuery("*:*");
+ server.commit();
+ assertNumFound("*:*", 0); // make sure it got in
+
+ // two docs, one with uniqueKey, another without it
+ String json = "{\"id\":\"abc1\", \"name\": \"name1\"} {\"name\" : \"name2\"}";
+ HttpClient httpClient = server.getHttpClient();
+ HttpPost post = new HttpPost(server.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());
+ server.commit();
+ assertNumFound("*:*", 2);
+ }
+
+
@Override
public SolrServer createNewSolrServer() {
try {