Static field for document in Data Import Handlerfor Solr

前端 未结 2 1450
小鲜肉
小鲜肉 2021-01-22 15:27

Im making an index in solr from db in the following way:

  

  

  

        
相关标签:
2条回答
  • 2021-01-22 15:41
    <document name="Index">  
    <entity name="c" transformer="TemplateTransformer" query="SELECT * FROM C">  
      <field column="Name" name="name"/>  
      <field column="id" template="1"/>  
    </entity>  
    <entity name="p" transformer="TemplateTransformer" query="SELECT * FROM P">  
      <field column="Name" name="name"/>  
      <field column="id" template="1"/>  
    </entity>  
    </document> 
    
    0 讨论(0)
  • 2021-01-22 15:45

    You can add a column to your SQL query that contains static data like this:

    <document name="Index">  
      <entity name="c" query="SELECT *, 'foo' as NameFromC FROM C">  
        <field column="NameFromC" name="name"/>
      </entity>
    
      <entity name="p" query="SELECT *, 'bar' as NameFromP FROM P">  
        <field column="NameFromP" name="name"/>
      </entity>  
    </document>
    

    If you try to add a field with only name and template attributes, Solr will throw an error saying Field must have a column attribute.

    0 讨论(0)
提交回复
热议问题