日期:2014-05-16  浏览次数:20389 次

solr4.0.0学习(二) 数据库导入clob与blob为索引

导入clob很简单。但是blob好像没有提供方法,所以改了一下源码,重新编译替换class文件,竟然成功了。

先把配置文件贴上

SCHEMA.XML

<?xml version="1.0" ?>
<schema name="test" version="1.1">
  <types>
   <fieldtype name="string"  class="solr.StrField" sortMissingLast="true" omitNorms="true"/>

   <fieldType name="standard" class="solr.TextField" positionIncrementGap="100">
	  <analyzer type="index">
		<tokenizer class="solr.StandardTokenizerFactory"/>
		<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
		<filter class="solr.LowerCaseFilterFactory"/>
	  </analyzer>
	  <analyzer type="query">
		<tokenizer class="solr.StandardTokenizerFactory"/>
		<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
		<filter class="solr.LowerCaseFilterFactory"/>
	  </analyzer>
	</fieldType>

	<fieldType name="ik" class="solr.TextField">   
       <analyzer class="org.wltea.analyzer.lucene.IKAnalyzer"/>   
	</fieldType>

  </types>

 <fields>   
  <field name="blogId"      type="string"   indexed="false"  stored="true"  multiValued="false"/>
  <field name="blogTitle"   type="ik"   indexed="true"  stored="true"  multiValued="false" /> 
  <field name="blogAuthorName"   type="ik"   indexed="true"  stored="true"  multiValued="false" /> 
  <field name="blogContent"   type="ik"   indexed="true"  stored="true"  multiValued="false" /> 
  <field name="TITLE"   type="ik"   indexed="true"  stored="true"  /> 
  <field name="TEXT"   type="ik"   indexed="true"  stored="true"  /> 
 </fields>
 <defaultSearchField>blogTitle</defaultSearchField>
 <solrQueryParser defaultOperator="OR"/>

</schema>


这里的field只用到了blogContent一个。

SOLRCONFIG.XML

<?xml version="1.0" encoding="UTF-8" ?>
<config>
  <luceneMatchVersion>LUCENE_34</luceneMatchVersion>
  <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" />
      
 <!-- the dataimport requestHandler --> 
       <requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler"> 
               <lst name="defaults"> 
              <str name="co