Wednesday, September 11, 2013

Add auto generated field to Solr 4





11.       Define new type :
fieldType name="uuid" class="solr.UUIDField" indexed="true" />
22.       Add new field
<field name="rami" type="uuid" indexed="true" stored="true" default="NEW"/>
(parameter – default-“NEW” does the trick!)

33.                       <updateRequestProcessorChain name="uuid">
<processor class="solr.UUIDUpdateProcessorFactory">
<str name="fieldName">rami</str>
</processor>
<processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>

44.       To the relevant handler add the chain
Example: for /update/extract
  <requestHandler name="/update/extract"
                  startup="lazy"
                  class="solr.extraction.ExtractingRequestHandler" >
    <lst name="defaults">
      <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>
                  <str name="update.chain">uuid</str>
    </lst>
  </requestHandler>



Now u can executer / update/extract without passing filed “rami” and it will be automatically generated.

No comments:

Post a Comment