问题
I was trying to use DataImportHandler to index my MySQL Database using Solr in Cloud Mode, the following are the configurations it uses the _default configsets.
solr-7.3.0\server\solr\configsets\_default\conf\data-config.xml
# define data source
<dataConfig>
<dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/expressg_dbkevinzeigler" user="root" password=""/>
<document>
<entity name="product"
pk="id_prd"
query="SELECT id_prd, name_prd, description_prd FROM products_prd">
<field column="id_prd" name="id"/>
<field column="name_prd" name="name"/>
</entity>
</document>
</dataConfig>
Added the following to: solr-7.3.0\server\solr\configsets\_default\conf\solrconfig.xml
<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-dataimporthandler-7.3.0.jar" />
<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-dataimporthandler-7.3.0-extras.jar" />
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">data-config.xml</str>
</lst>
</requestHandler>
Added the following to: solr-7.3.0\server\solr\configsets\_default\conf\managed-schema.xml
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="name" type="string" indexed="true" stored="true" multiValued="false" />
When I tried DataImport in Solr Admin on my current collection it says:
"The solrconfig.xml file for this index does not have an operational DataImportHandler defined!"
Anybody encounter the same?
回答1:
Please follow below steps to create our own configsets and create a collection using these configurations for Solr Cloud mode.
1 : Create a copy of default configurations, from your Solr installation directory.
sudo cp -R _default/ db_config
2 : Edit solrconfig.xml, DIHconfigfile.xml and schema.xml(managed_schema)
files as per your requirement.
3 : Create a zip file of new configurations
(cd /usr/local/solr/server/solr/configsets/db_config/conf && zip -r - *) > db_config_set.zip
4 : Upload this configurations to ZooKeeper
curl -X POST --header "Content-Type:application/octet-stream" --data-binary @db_config_set.zip "http://your_host_ip:8983/solr/admin/configs?action=UPLOAD&name=db_config_set"
Once the upload is successful we could see our new configset while creating new collection in Solr Admin webpage. Creating custom configsets is useful while working on data import tasks.
Reference : https://lucene.apache.org/solr/guide/8_1/configsets-api.html
来源:https://stackoverflow.com/questions/50238528/solr-index-does-not-have-an-operational-dataimporthandler-defined