2012年12月20日 星期四

Resolve a SolrException in Solr or LucidWorks

       Solr (or LucidWorks ) requires unique id when you import data from Oracle database via Data Import Request Handler(DIH). If not, you would experience 2 kinds of exception(depends on what a system you use, Solr or LucidWorks)
1. org.apache.solr.common.SolrException: Document is missing mandatory uniqueKey field: id
2. Document [null] missing required field: id
       Unfortunately, even you alias the field name of primary key as "id". The system still reports "Document [xx] missing required field". The root cause is, Oracle always return field names as capital. So, how do we resolve it ?


  • Solr user
     You can add a field transform in data-config.xml like this
    <entity name="root" pk="id" preImportDeleteQuery="data_source:29" query="select id, description from table1" transformer="TemplateTransformer" >
       <field column="[your field name in capital]" name="id" />
    </entity>
  • LucidWorks user
      PLS manual edit dataconfig_[xx].xml in [LucidWorks]\conf\solr\cores\[your collection name]\conf. There is no way to edit it through ADMIN pages in LucidWorks. Find the entity XML element and add field transform element.
       <field column="[your field name in capital]" name="id" />

Hope it could resolve the problem you experience.

沒有留言:

張貼留言