使用数据导入处理程序将数据上载到Solr

问题描述 投票:0回答:2

嗨,我正在努力用数据导入处理程序将我的数据上传到solr。我正在做的是使用服务器文件夹中的命令启动solr服务器

solr start

然后,这允许我在我的计算机上打开一个本地主机,其中显示了我之前设置的核心。

Screenshot of solr running on computer

然后我编辑了文件solrconfig.xml和schema.xml

在solrconfig.xml中,我已将以下代码行放入

<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-dataimporthandler-.*.jar" /> 

<schemaFactory class="ClassicIndexSchemaFactory"/>

<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler" startup="lazy">
<lst name="defaults">
    <str name="config">data-config.xml</str>
</lst>

在schema.xml中(从托管模式文件重命名)我添加了

<field name="_version_" type="plong" indexed="true" stored="true"/>
<field name="id" type="string" indexed="true" stored="true" required="true"/>
<field name="title" type="string" indexed="true" stored="true"/>
<field name="revision" type="pint" indexed="true" stored="false"/>
<field name="user" type="string" indexed="true" stored="false"/>
<field name="userId" type="pint" indexed="true" stored="false"/>
<field name="text" type="text_en" indexed="true" stored="false"/>
<uniqueKey>id</uniqueKey>

然后我使用以下代码创建了一个data-config.xml文件

<dataConfig>
<dataSource type="FileDataSource" encoding="UTF-8"/>
<document>
    <entity name="page"
            processor="XPathEntityProcessor"
            stream="true"
            forEach="/mediawiki/page"
            url="/Volumes/BACKUP/enwiki-latest-pages-articles.xml"
            transformer="RegexTransformer,DateFormatTransformer"
            >
        <field column="id" xpath="/mediawiki/page/id" />
        <field column="title" xpath="/mediawiki/page/title" />
        <field column="revision" xpath="/mediawiki/page/revision/id" />
        <field column="user" xpath="/mediawiki/page/revision/contributor/username" />
        <field column="userId" xpath="/mediawiki/page/revision/contributor/id" />
        <field column="text" xpath="/mediawiki/page/revision/text" />
        <field column="timestamp" xpath="/mediawiki/page/revision/timestamp" dateTimeFormat="yyyy-MM-dd'T'hh:mm:ss'Z'" />
        <field column="$skipDoc" regex="^#REDIRECT .*" replaceWith="true" souceColName="text"/>
    </entity>
</document>

这里我想索引的xml存储在我的计算机上的外部硬盘驱动器上。一切似乎都运行良好,直到我在浏览器中键入以下内容

http://localhost:8983/solr/wiki/dataimport?command=full-import

并显示以下内容

full-import logging

有谁知道如何解决这一问题?我正在使用solr 7.7,而Stackoverflow上的所有问题似乎都适用于早期版本。我试图遵循的教程是https://www.youtube.com/watch?v=2VkFQTqrRYo&t=310s,这是旧的所以我认为这就是为什么我得到这个错误。

xml solr wikipedia dataimporthandler
2个回答
0
投票

错误说明了一切...... clasNotFoundException ...检查你的类路径,看起来DataImportHandler不在你的类路径上......

<lib dir="../../../dist/" regex="apache-solr-dataimporthandler-.*\.jar" />

配置更改后重新启动jetty服务器。


0
投票

原来我需要做的就是改变solrconfig.xml:

<updateRequestProcessorChain name="add-unknown-fields-to-the-schema" default="${update.autoCreateFields:false}"

(假而不是真)

© www.soinside.com 2019 - 2024. All rights reserved.