2011-02-09 54 views
2

我新的Apache Solr實現,我想用它來索引PDF文件。我設法得到它,至今運行,我現在可以搜索添加PDF文件。檢索提取的文本使用Apache Solr實現

不過,我需要能夠檢索結果的搜索文本。

我發現在默認solrconfig.xml中正是有關的XML片段:

<requestHandler name="/update/extract" class="org.apache.solr.handler.extraction.ExtractingRequestHandler" startup="lazy"> 
<lst name="defaults"> 
    <!-- All the main content goes into "text"... if you need to return 
     the extracted text or do highlighting, use a stored field. --> 
    <str name="fmap.content">text</str> 
    <str name="lowernames">true</str> 
    <str name="uprefix">ignored_</str> 

    <!-- capture link hrefs but ignore div attributes --> 
    <str name="captureAttr">true</str> 
    <str name="fmap.a">links</str> 
    <str name="fmap.div">ignored_</str> 
</lst> 

從我從這裏(http://www.lucidimagination.com/Community/Hear -from-the-Experts/Articles/Content-Extraction-Tika),我想我必須爲存儲=「true」和索引=「true」的schema.xml添加一個新字段(例如「content」)。不過,我真的不知道如何準確地做到這一點?

讚賞任何幫助,THX

+0

嗯,我似乎已經管理它,我把「文本」字段的「存儲」屬性設置爲「true」。 – DeX3 2011-02-09 18:15:45

回答

4

添加schema.xml中看起來像這樣:

<?xml version="1.0" encoding="UTF-8" ?> 

<schema name="whatever" version="1.2"> 
    <types> 
     <fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/> 
     <fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/> 
     <fieldType name="float" class="solr.TrieFloatField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/> 
     <fieldType name="long" class="solr.TrieLongField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/> 
     <fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/> 
     <fieldType name="date" class="solr.TrieDateField" omitNorms="true" precisionStep="0" positionIncrementGap="0"/> 
     <fieldType name="text" class="solr.TextField" positionIncrementGap="100"> 
      <analyzer type="index"> 
       <charFilter class="solr.HTMLStripCharFilterFactory"/> 
       <charFilter class="solr.MappingCharFilterFactory" mapping="../../mapping-ISOLatin1Accent.txt"/> 
       <tokenizer class="solr.StandardTokenizerFactory"/> 
       <filter class="solr.StandardFilterFactory"/> 
       <filter class="solr.LowerCaseFilterFactory"/> 
      </analyzer> 
      <analyzer type="query"> 
       <charFilter class="solr.HTMLStripCharFilterFactory"/> 
       <charFilter class="solr.MappingCharFilterFactory" mapping="../../mapping-ISOLatin1Accent.txt"/> 
       <tokenizer class="solr.StandardTokenizerFactory"/> 
       <filter class="solr.StandardFilterFactory"/> 
       <filter class="solr.LowerCaseFilterFactory"/> 
      </analyzer> 
     </fieldType> 
    </types> 
    <fields> 
     <field name="internal_id" type="string" indexed="true" stored="true"/> 
     <field name="cat" type="int" indexed="true" stored="true"/> 
     <field name="desc" type="text" indexed="true" stored="true"/> 
    </fields> 
    <uniqueKey>internal_id</uniqueKey> 
    <defaultSearchField>desc</defaultSearchField> 
    <solrQueryParser defaultOperator="OR"/> 
    <similarity class="org.apache.lucene.search.DefaultSimilarity"/> 
</schema> 

如果「場」被「存儲」,它會在結果中顯示,在默認情況下。