mirror of https://github.com/apache/lucene.git
SOLR-6437: Managed schema is not enabled with /update/json and /update/json/docs request handlers
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1620768 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c5dd7783a3
commit
6f1c5de38f
|
@ -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 ,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 extends SolrExampleTestsBase {
|
|||
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 {
|
||||
|
|
Loading…
Reference in New Issue