0

我有一个包含 xml 的数据库列,我想在该列中使用 apache solr 内容进行索引,我有以下 data-config.xml (配置)。数据库名称为“solrdb”,列名称为“xmlfield”,似乎有问题,错误在底部指定。

<dataConfig>
        <!--Data source to connect to database-->
        <dataSource 
            name="XmlDocDS" 
            type="JdbcDataSource" 
            driver="com.mysql.jdbc.Driver" 
            url="jdbc:mysql://127.0.0.1/solrdb" 
            user="root" 
            password="root" /> 
        <!-- Data Source for getting xml columne data-->    
        <dataSource 
            name="solrFieldReaderDS" 
            type="FieldReaderDataSource"/>
        <document>
            <entity 
                name="xmltable"
                rootEntity="false"
                datasource="XmlDocDS"
                query="select xmlfield from xmltable">
                <field column="xmldata" blob="true" />
                <entity 
                    name="page" 
                    dataSource="solrFieldReaderDS" 
                    dataField="xmltable.xmldata"                 
                    processor="XPathEntityProcessor"             
                    forEach="/page"> 
                    <field column="id" xpath="/mediawiki/page/id"/> 
                    <field column="Title" xpath="/mediawiki/page/title"/> 
                </entity> 
            </entity>
        </document>
</dataConfig>

错误如下:

SEVERE: Exception while processing: xmltable document : null:org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to execute query: select xmlfield from xmltable Processing Document # 1
4

2 回答 2

0

在这部分 JDBC 导入器代码中抛出错误:

try {
    Connection c = getConnection();
    stmt = c.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
    stmt.setFetchSize(batchSize);
    stmt.setMaxRows(maxRows);
    LOG.debug("Executing SQL: " + query);
    long start = System.currentTimeMillis();
    if (stmt.execute(query)) {
      resultSet = stmt.getResultSet();
    }
    LOG.trace("Time taken for sql :"
            + (System.currentTimeMillis() - start));
    colNames = readFieldNames(resultSet.getMetaData());
  } catch (Exception e) {
    wrapAndThrow(SEVERE, e, "Unable to execute query: " + query);
  }

所以连接或查询可能会出错(数据库有问题吗?)。还有“执行 SQL”和“sql 所用时间:”的 grep 日志

于 2012-05-29T12:00:17.853 回答
0

there was an error in connection, for some reason it was nto able to connect to my local machine, i changed the database host and it connected!, the problem is that I have the configuration in place and FieldReaderDataSource seems to work fine, but now when it completes everything it says documents indexed/updated = 0

here is my xml configuration

<dataSource
        name="jdbcDataSource"
        driver="com.mysql.jdbc.Driver"
        url="xxxx"
        user="yyyy"
        password="zzzz" readOnly="true"/>

        <dataSource 
            name="solrFieldReaderDS" 
            type="FieldReaderDataSource"/>
        <document>
            <entity
                name="tabledata"
                dataSource="jdbcDataSource"
                query="select codeID,codeText from ArticlePoolState where codeID=3">
                <entity 
                    name="xmldata" 
                    dataSource="solrFieldReaderDS" 
                    forEach="/med"
                    dataField="tabledata.codeText"               
                    processor="XPathEntityProcessor"> 
                    <field column="title" xpath="/title"/> 
                </entity>
            </entity>
        </document>

The query is fine.

于 2012-05-31T09:33:46.677 回答