Question

I want to map from one column in MySQL database to multiple column in Solr. Suppose my db table is Car, here is my data-config.xml file:

<dataConfig>
  <document name="car">
    <entity name="car" query="select * from cars" transformer="TemplateTransformer">
      <field column="id" name="id" template="Car ${car.id}"/>
      <field column="id" name="id_ss" />
    </entity>
  </document>
</dataConfig>

In Solr schema I have 2 field with the following format:

id: with format "Car {id from db}"
id_ss: with format "{id from db}"

But after I've use tempate transformer, my data is index like this(even though I don't use template transformer over id_ss field):

id: "Car {id from db}"
id_ss: "Car {id from db}"

How can I make it work as I want?

Was it helpful?

Solution

do it this way:

<entity name="car" query="select id as id_ss, concat('Car ', id) as id from cars">
  <field column="id" name="id" template="Car ${car.id}"/>
  <field column="id_ss" name="id_ss" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top