如何将json提取到集合中?

时间:2019-07-16 09:35:54

标签: solr

我在SolR方面经验很少,我正尝试在集合中提取JSON,但遇到了无法解决的错误。

我正在使用SolR 4.10.3(CDH 5.16)。

这是我的json文件ddbb.2019-07-15.json:

{"id":2,"timestamp":"2019-07-15T10:36:03.547T","datos":{"datalab_bigdata":158311392,"datalabin_externos1":136486124,"datalab_ri":1398,"datalanding":3369602553358,"derivatives_generic":78743939344,"derivatives_models_in":1454026466,"nz_acc_agilem01":59715251298,"nz_des_bbgtemp0":2411494534,"nz_des_brqrci01":11729162244,"nz_des_brqrqpru":210446881220,"operativizacion_in_etl":16750,"operativizacion_models_in":765604228,"rqopt":0,"standard":343583101992,"standard_ri":296627288,"xstandard_bdevnrt":64013507016}}

schema.xml(字段定义)的一部分。

我只使用这些字段:

<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="_root_" type="string" indexed="true" stored="false"/>
<field name="_version_" type="long" indexed="true" stored="true"/>

<uniqueKey>id</uniqueKey>

  <field name="timestamp" type="pdate" indexed="true" stored="true"/>
  <field name="ddbb" type="string" indexed="true" stored="true"/>

默认情况下,动态字段是

这是我正在使用的命令:

java -Durl=http://$SOLRHOST:8983/solr/collectionTest_shard1_replica1/update/json/docs -jar /usr/share/doc/solr-doc-4.10.3+cdh5.13.0+519/example/exampledocs/post.jar /home/cloudera/datos/*.json

这是我得到的错误:

SimplePostTool version 1.5
Posting files to base url 
http://:8983/solr/bankiaDDBB_shard1_replica1/update/json/docs using content-type application/xml..
POSTing file ddbb.2019-07-11.json
SimplePostTool: WARNING: Solr returned an error #500 (Internal Server Error) for url: 
http://:8983/solr/bankiaDDBB_shard1_replica1/update/json/docs
SimplePostTool: WARNING: Response: {"responseHeader": 
{"status":500,"QTime":2},"error":{"metadata":["error-class","org.apache.solr.common.SolrException","root-error-class","org.apache.solr.common.SolrException"],"msg":"Error while creating field 'timestamp{type=pdate,properties=indexed,stored,omitNorms,omitTermFreqAndPositions,sortMissingLast}' from value '2019-07-11T11:08:56.406T'","trace":"org.apache.solr.common.SolrException: Error while creating field 'timestamp{type=pdate,properties=indexed,stored,omitNorms,omitTermFreqAndPositions,sortMissingLast}' from value '2019-07-11T11:08:56.406T'\n\tat org.apache.solr.schema.FieldType.createField(FieldType.java:261)\n\tat org.apache.solr.schema.DateField.createField(DateField.java:206)\n\tat org.apache.solr.schema.FieldType.createFields(FieldType.java:304)\n\tat org.apache.solr.update.DocumentBuilder.addField(DocumentBuilder.java:50)\n\tat org.apache.solr.update.DocumentBuilder.toDocument(DocumentBuilder.java:125)\n\tat org.apache.solr.update.AddUpdateCommand.getLuceneDocument(AddUpdateCommand.java:78)\n\tat org.apache.solr.update.DirectUpdateHandler2.updateDocument(DirectUpdateHandler2.java:814)\n\tat org.apache.solr.update.DirectUpdateHandler2.addDoc0(DirectUpdateHandler2.java:235)\n\tat org.apache.solr.update.DirectUpdateHandler2.addDoc(DirectUpdateHandler2.java:164)\n\tat org.apache.solr.update.processor.RunUpdateProcessor.processAdd(RunUpdateProcessorFactory.java:69)\n\tat org.apache.solr.update.processor.UpdateRequestProcessor.processAdd(UpdateRequestProcessor.java:51)\n\tat org.apache.solr.update.processor.DistributedUpdateProcessor.doLocalAdd(DistributedUpdateProcessor.java:946)\n\tat org.apache.solr.update.processor.DistributedUpdateProcessor.versionAdd(DistributedUpdateProcessor.java:1101)\n\tat org.apache.solr.update.processor.DistributedUpdateProcessor.processAdd(DistributedUpdateProcessor.java:702)\n\tat org.apache.solr.update.processor.LogUpdateProcessor.processAdd(LogUpdateProcessorFactory.java:100)\n\tat org.apache.solr.handler.loader.JsonLoader$SingleThreadedJsonLoader.handleStreamingSingleDocs(JsonLoader.java:241)\n\tat org.apache.solr.handler.loader.JsonLoader$SingleThreadedJsonLoader.processUpdate(JsonLoader.java:124)\n\tat org.apache.solr.handler.loader.JsonLoader$SingleThreadedJsonLoader.load(JsonLoader.java:106)\n\tat org.apache.solr.handler.loader.JsonLoader.load(JsonLoader.java:68)\n\tat org.apache.solr.handler.UpdateRequestHandler$1.load(UpdateRequestHandler.java:99)\n\tat org.apache.solr.handler.ContentStreamHandlerBase.handleRequestBody(ContentStreamHandlerBase.java:74)\n\tat org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)\n\tat org.apache.solr.core.SolrCore.execute(SolrCore.java:2257)\n\tat org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:923)\n\tat org.apache.solr.servlet.SolrDispatchFilter.httpSolrCall(SolrDispatchFilter.java:484)\n\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:260)\n\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:254)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)\n\tat org.apache.solr.servlet.SolrHadoopAuthenticationFilter$2.doFilter(SolrHadoopAuthenticationFilter.java:408)\n\tat org.apache.hadoop.security.authentication.server.AuthenticationFilter.doFilter(AuthenticationFilter.java:631)\n\tat org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthenticationFilter.doFilter(DelegationTokenAuthenticationFilter.java:301)\n\tat org.apache.hadoop.security.authentication.server.AuthenticationFilter.doFilter(AuthenticationFilter.java:579)\n\tat org.apache.solr.servlet.SolrHadoopAuthenticationFilter.doFilter(SolrHadoopAuthenticationFilter.java:413)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)\n\tat org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)\n\tat org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)\n\tat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)\n\tat org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)\n\tat org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)\n\tat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)\n\tat org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)\n\tat org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:610)\n\tat org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:503)\n\tat java.lang.Thread.run(Thread.java:745)\nCaused by: org.apache.solr.common.SolrException: Invalid Date String:'2019-07-11T11:08:56.406T'\n\tat org.apache.solr.schema.DateField.parseMath(DateField.java:184)\n\tat org.apache.solr.schema.DateField.toInternal(DateField.java:154)\n\tat org.apache.solr.schema.FieldType.createField(FieldType.java:259)\n\t... 45 more\n","code":500}}
SimplePostTool: WARNING: IOException while reading response: java.io.IOException: Server returned HTTP response code: 500 for URL: http://:8983/solr/bankiaDDBB_shard1_replica1/update/json/docs
POSTing file ddbb.2019-07-15.json

该错误表明我对字段timestamp的定义存在疑问。我删除双引号,但又遇到另一个错误。

谢谢你

0 个答案:

没有答案