2017-08-24 7 views
1

(編集:UbuntuでのSolr-6.6.0)SolrのFieldStreamDataSourceは、 "サポートされていないタイプ:文字列" スロー(nullでない)

私はインデックスを持つブロブエントリが含まれてMySQLデータベースを、SolrのDataImportHandlerを使用しようとしていますRTFファイル。他のすべての非のBlobフィールドがインデックスを取得しながら

How do I index Rich Format Documents in Blobs

Unsupported type Exception on Importing Documents from Database

は、私は次のJava ランタイムエラーを取得しておいてください。これらの答えに指定されている。このために私は、FieldStreamDataSourceを使用しています

原因:java.lang.RuntimeExce()メソッドは、FieldStreamDataSource.getData()メソッドのから継承されています。 ption:サポートされていないタイプ:クラス java.lang.Stringでorg.apache.solr.handler.dataimport.FieldStreamDataSource.getData(FieldStreamDataSource.java:77)で org.apache.solr.handler.dataimport.FieldStreamDataSource.getDataでJava classのこれらの行を指し org.apache.solr.handler.dataimport.DebugLogger $ 2.getData(DebugLogger.java:187)

で(FieldStreamDataSource.java:47) ( '矢印を参照< === '):

@Override 
    public InputStream getData(String query) { 
    Object o = wrapper.getVariableResolver().resolve(dataField); 
    if (o == null) { 
     throw new DataImportHandlerException(SEVERE, "No field available for name : " + dataField); 
    } else if (o instanceof Blob) {          // <========= XXX 
     Blob blob = (Blob) o; 
     try { 
     return blob.getBinaryStream(); 
     } catch (SQLException sqle) { 
     LOG.info("Unable to get data from BLOB"); 
     return null; 
     } 
    } else if (o instanceof byte[]) { 
     byte[] bytes = (byte[]) o; 
     return new ByteArrayInputStream(bytes); 
    } else { 
     throw new RuntimeException("unsupported type : " + o.getClass()); // <========= XXX 
    } 

これは、getData()メソッドがBlob型ではなく文字列を取得していることを意味します。

私はBLOB値がデータベースにnullのときにこのエラーが発生し、多くの他のスレッドに示唆されている知っている:しかし、それはここではそうではありません

Unsupported type Exception on Importing Documents from Database

Solr DIH Throwing Error Unsupported Type Class Java.Lang.String

私はこのテストDBに5つのエントリしか持たないので、そのうちのどれもがヌル値を持たないからです。ここで

"verbose-output": [ 
     "entity:reports1", 
     [ 
      "document#1", 
      [ 
      "query", 
      "SELECT id, institute, exam_date, age, acc, pacs FROM reports", 
      "time-taken", 
      "0:0:0.8", 
      null, 
      "----------- row #1-------------", 
      "id", 
      "1", 
      "institute", 
      "RADIOLOGY", 
      "age", 
      "68", 
      "acc", 
      "165184654", 
      "pacs", 
      "233215", 
      "exame_date", 
      "2016-02-05T00:00:00Z", 
      null, 
      "---------------------------------------------", 
      "entity:reports2", 
      [ 
       "query", 
       "SELECT report FROM reports WHERE id='1'", 
       "time-taken", 
       "0:0:0.6", 
       null, 
       "----------- row #1-------------", 
       "report",     // <========= COLUMN NAME RETURNED FROM THE SQL SELECT 
       "e1xydGYxXGFkZWZ[...]", // <========= VALUE RETURNED FROM THE SQL SELECT 
       null, 
       "---------------------------------------------", 
       "entity:report", 
       [ 
       "query", 
       "report", 
       "EXCEPTION",    // <========== EXCEPTION THROWN 
       "java.lang.RuntimeException: unsupported type : class java.lang.String\n\tat org.apache.solr.handler.dataimport.FieldStreamDataSource.getData(FieldStreamDataSource.java:77)\n\tat org.apache.solr.handler.dataimport.FieldStreamDataSource.getData(FieldStreamDataSource.java:47)\n\tat org.apache.solr.handler.dataimport.DebugLogger$2.getData(DebugLogger.java:187)\n\tat org.apache.solr.handler.dataimport.TikaEntityProcessor.nextRow(TikaEntityProcessor.java:128)\n\tat org.apache.solr.handler.dataimport.EntityProcessorWrapper.nextRow(EntityProcessorWrapper.java:267)\n\tat org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:475)\n\tat org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:516)\n\tat org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:516)\n\tat org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:414)\n\tat org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:329)\n\tat org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:232)\n\tat org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:415)\n\tat org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:474)\n\tat org.apache.solr.handler.dataimport.DataImportHandler.handleRequestBody(DataImportHandler.java:180)\n\tat org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:173)\n\tat org.apache.solr.core.SolrCore.execute(SolrCore.java:2477)\n\tat org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.java:723)\n\tat org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:529)\n\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:361)\n\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:305)\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1691)\n\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:582)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)\n\tat org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)\n\tat org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180)\n\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512)\n\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)\n\tat org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213)\n\tat org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:119)\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)\n\tat org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.java:335)\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)\n\tat org.eclipse.jetty.server.Server.handle(Server.java:534)\n\tat org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320)\n\tat org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)\n\tat org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273)\n\tat org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)\n\tat org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)\n\tat org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303)\n\tat org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148)\n\tat org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)\n\tat java.lang.Thread.run(Thread.java:748)\n", 
        "time-taken", 
        "0:0:0.0" 
        ] 
       ] 
       ], 

は私です: はまた、私はBlob値が実際に(「=== <」矢印を参照)DBから取得されたことを示しているSolrのDIHインタフェース、からデバッグ出力をチェックしていますデータ-config.xmlの

<dataConfig> 

     <dataSource 
      name="db" 
      type="JdbcDataSource" 
      driver="com.mysql.jdbc.Driver" 
      url="jdbc:mysql://localhost:3306/RIS" 
      user="root" 
      password="********"/> 

     <dataSource name="fieldStream" type="FieldStreamDataSource"/> 

     <document> 
      <entity 
       name="reports1" 
       query="SELECT id, institute, exam_date, age, acc, pacs FROM reports" 
       dataSource="db" 
      > 
       <field column="id"   name="id"/> 
       <field column="institute" name="institute"/> 
       <field column="exam_date" name="exam_date"/> 
       <field column="age"   name="age"/> 
       <field column="acc"   name="acc"/> 
       <field column="pacs"   name="pacs"/> 


       <entity 
        name="reports2" 
        query="SELECT report FROM reports WHERE id='${reports1.id}'" 
        dataSource="db" 
       > 
        <entity 
         name="report" 
         dataSource="fieldStream" 
         processor="TikaEntityProcessor" 
         url="report" 
         dataField="reports2.REPORT" 
         format="text" 
         onError="continue"> 
         <field column="text" name="report"/> 
        </entity> 
       </entity> 

      </entity> 

     </document> 
</dataConfig> 

だから、DBのBLOB列から取得した値が文字列ではなく、BLOB型として渡すかreckonizedされているように私には見えます。私は何か間違っているかどうか誰にでも手伝ってもらえますか?私はどこでも検索しましたし、解決策を見ることができない。(私は日のためにしようとしたにも関わらず)私は(むしろ些細な)問題を発見した

答えて

0

/

感謝

にdataFieldプロパティを変更します小文字は、this答えからの経験に反して、トリックをしました。下の変更(矢印 '< ==='を参照)をdata-config.xmlに行い、すべてのエントリをインデックスに登録しました。

<entity 
    name="reports2" 
    query="SELECT report FROM reports WHERE id='${reports1.id}'" 
    dataSource="db"> 
     <entity 
      name="report" 
      dataSource="fieldStream" 
      processor="TikaEntityProcessor" 
      url="report" 
      dataField="reports2.report" // <===== instead of reports2.REPORT 
      format="text" 
      onError="continue"> 

      <field column="text" name="report"/> 
     </entity> 

しかし、これは私に(別の答えであればわからない)を指摘する価値があるかもしれません無関係な問題を与えませんでした。

データベースから返された列( "report")はSolrスキーマフィールド( "report")と同じ名前だったため、索引付けはSQL問合せ後に自動で行われ、BLOBからバイナリ値を索引付けします。 TikaEntityProcessorによって次のエンティティで抽出されたテキストは無視されました。私は、2つのフィールド(MySQLとSolr)がこの値に対して異なる名前を持っていることを確認してこれを修正しました。

以下、矢印( '< ===')は、インデックス作成がどこで起こったかを示しています(計画より早く)。

<entity 
    name="reports2" 
    query="SELECT report FROM reports WHERE id='${reports1.id}'" // <======== DIH indexed this column (report) from the DB into the Solr field of same name (binary representation) 
    dataSource="db"> 
     <entity 
      name="report" 
      dataSource="fieldStream" 
      processor="TikaEntityProcessor" 
      url="report" 
      dataField="reports2.report" 
      format="text" 
      onError="continue"> 

      <field column="text" name="report"/> //<======== instead of waiting for this column (text), the output from Tika (extracted text) 
     </entity> 
</entity> 
関連する問題