尝试在 Solr3.6 上使用 Solr 的 DataImportHandler 时出现错误。我在 /etc/solr/dist 中有 jar 文件,并且在 /etc/solr/core0 和 /etc/solr/core1 运行两个内核
这是我看到的异常:
Jun 19, 2013 9:43:48 AM org.apache.solr.core.SolrCore execute
INFO: [core1] webapp=/solr path=/dataimport params={command=full-import} status=0 QTime=3
Jun 19, 2013 9:43:48 AM org.apache.solr.handler.dataimport.DataImporter doFullImport
INFO: Starting Full Import
Jun 19, 2013 9:43:48 AM org.apache.solr.handler.dataimport.SimplePropertiesWriter readIndexerProperties
WARNING: Unable to read: dataimport.properties
Jun 19, 2013 9:43:48 AM org.apache.solr.update.DirectUpdateHandler2 deleteAll
INFO: [core1] REMOVING ALL DOCUMENTS FROM INDEX
Jun 19, 2013 9:43:49 AM org.apache.solr.update.processor.LogUpdateProcessor finish
INFO: {deleteByQuery=*:*} 0 3
Jun 19, 2013 9:43:49 AM org.apache.solr.common.SolrException log
SEVERE: Full Import failed:java.lang.RuntimeException: org.apache.solr.handler.dataimport.DataImportHandlerException: Exception in full dump while deleting all documents. Processing Document # 1
at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:264)
at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:375)
at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:445)
at org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:426)
Caused by: org.apache.solr.handler.dataimport.DataImportHandlerException: Exception in full dump while deleting all documents. Processing Document # 1
at org.apache.solr.handler.dataimport.SolrWriter.doDeleteAll(SolrWriter.java:127)
at org.apache.solr.handler.dataimport.DocBuilder.cleanByQuery(DocBuilder.java:1153)
at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:224)
... 3 more
Caused by: org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: NativeFSLock@/etc/solr/core1/data/index/write.lock: java.io.FileNotFoundException: /etc/solr/core1/data/index/write.lock (Permission denied)
at org.apache.lucene.store.Lock.obtain(Lock.java:84)
at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:1098)
at org.apache.solr.update.SolrIndexWriter.<init>(SolrIndexWriter.java:84)
at org.apache.solr.update.UpdateHandler.createMainIndexWriter(UpdateHandler.java:101)
at org.apache.solr.update.DirectUpdateHandler2.deleteAll(DirectUpdateHandler2.java:165)
at org.apache.solr.update.DirectUpdateHandler2.deleteByQuery(DirectUpdateHandler2.java:324)
at org.apache.solr.update.processor.RunUpdateProcessor.processDelete(RunUpdateProcessorFactory.java:71)
at org.apache.solr.update.processor.LogUpdateProcessor.processDelete(LogUpdateProcessorFactory.java:137)
at org.apache.solr.handler.dataimport.SolrWriter.doDeleteAll(SolrWriter.java:125)
... 5 more
Caused by: java.io.FileNotFoundException: /etc/solr/core1/data/index/write.lock (Permission denied)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:233)
at org.apache.lucene.store.NativeFSLock.obtain(NativeFSLockFactory.java:203)
at org.apache.lucene.store.Lock.obtain(Lock.java:95)
... 13 more
这是我的 Solr 配置:
<?xml version="1.0" encoding="UTF-8" ?>
<config>
<luceneMatchVersion>LUCENE_36</luceneMatchVersion>
<lib dir="dist/" regex="solr-dataimporthandler-.*\.jar" />
<!-- The DirectoryFactory to use for indexes.
solr.StandardDirectoryFactory, the default, is filesystem based.
solr.RAMDirectoryFactory is memory based, not persistent, and doesn't work with replication. -->
<directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.StandardDirectoryFactory}"/>
<updateHandler class="solr.DirectUpdateHandler2" />
<requestDispatcher handleSelect="true" >
<requestParsers enableRemoteStreaming="false" multipartUploadLimitInKB="2048" />
</requestDispatcher>
<requestHandler name="standard" class="solr.StandardRequestHandler" default="true" />
<requestHandler name="/update" class="solr.XmlUpdateRequestHandler" />
<requestHandler name="/admin/" class="org.apache.solr.handler.admin.AdminHandlers" />
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">data-config.xml</str>
</lst>
</requestHandler>
<!-- config for the admin interface -->
<admin>
<defaultQuery>solr</defaultQuery>
</admin>
</config>
这是我的架构 XML:
<?xml version="1.0" ?>
<schema name="deals" version="1.1">
<types>
<fieldType name="string" class="solr.TextField">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<fieldType name="text_exact_fuzzy" class="solr.TextField" omitNorms="false">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StandardFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StandardFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
</types>
<fields>
<!-- general -->
<field name="deal_id" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="headline" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="tagline" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="description" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="terms" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="start_date" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="end_date" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="price" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="value" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="discount_percentage" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="discount_value" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="category_id" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="url" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="merchant_name" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="merchant_phone" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="merchant_email" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="merchant_url" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="bullets" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="merchant_address" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="date_created" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="date_modified" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="merchant_city" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="merchant_zip" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="provider" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="provider_id" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="currency_code" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="clickthru" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="views" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="ord" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="is_deleted" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="category_suggest" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="image" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="merchant_state" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="slug" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="city_id" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="incomplete" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="group_id" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="start_date_2" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="end_date_2" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="block_national" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="removal_flag" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="provider_logo" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="approval_status" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="partner_id" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="city_name" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="special" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="old_cat" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="is_template" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="lat" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="lon" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
<field name="country" type="text_exact_fuzzy" indexed="true" stored="true" required="true" />
</fields>
<!-- field to use to determine and enforce document uniqueness. -->
<uniqueKey>deal_id</uniqueKey>
<!-- field for the QueryParser to use when an explicit fieldname is absent -->
<defaultSearchField>headline</defaultSearchField>
<!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
<solrQueryParser defaultOperator="AND"/>
</schema>
这是我的 data-config.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<dataConfig>
<dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://#####/######" user="#####" password="#####" />
<document name="Deals">
<entity name="deal" query="SELECT * FROM deals">
<field column="deal_id" name="deal_id" />
<field column="headline" name="headline" />
<field column="tagline" name="tagline" />
<field column="description" name="description" />
<field column="terms" name="terms" />
<field column="start_date" name="start_date" />
<field column="end_date" name="end_date" />
<field column="price" name="price" />
<field column="value" name="value" />
<field column="discount_percentage" name="discount_percentage" />
<field column="discount_value" name="discount_value" />
<field column="category_id" name="category_id" />
<field column="url" name="url" />
<field column="merchant_name" name="merchant_name" />
<field column="merchant_phone" name="merchant_phone" />
<field column="merchant_email" name="merchant_email" />
<field column="merchant_url" name="merchant_url" />
<field column="bullets" name="bullets" />
<field column="merchant_address" name="merchant_address" />
<field column="date_created" name="date_created" />
<field column="date_modified" name="date_modified" />
<field column="merchant_city" name="merchant_city" />
<field column="merchant_zip" name="merchant_zip" />
<field column="provider" name="provider" />
<field column="provider_id" name="provider_id" />
<field column="currency_code" name="currency_code" />
<field column="clickthru" name="clickthru" />
<field column="views" name="views" />
<field column="ord" name="ord" />
<field column="is_deleted" name="is_deleted" />
<field column="category_suggest" name="category_suggest" />
<field column="image" name="image" />
<field column="merchant_state" name="merchant_state" />
<field column="slug" name="slug" />
<field column="city_id" name="city_id" />
<field column="incomplete" name="incomplete" />
<field column="group_id" name="group_id" />
<field column="start_date_2" name="start_date_2" />
<field column="end_date_2" name="end_date_2" />
<field column="block_national" name="block_national" />
<field column="removal_flag" name="removal_flag" />
<field column="provider_logo" name="provider_logo" />
<field column="approval_status" name="approval_status" />
<field column="partner_id" name="partner_id" />
<field column="city_name" name="city_name" />
<field column="special" name="special" />
<field column="old_cat" name="old_cat" />
<field column="is_template" name="is_template" />
<field column="lat" name="lat" />
<field column="lon" name="lon" />
<field column="country" name="country" />
</entity>
</document>
</dataConfig>
我已经通过验证器运行了我的 xml 文件,它们看起来都很好。有什么建议么?在此先感谢 - 我一直在努力让它工作 3 天。