Domanda

I am newbie in solr,
i have a table like this

id         infield        body
---------------------------------------------
1           ValX          Article1-Body
1           ValY          Article1-Body
1           ValZ          Article1-Body
2           ValW          Article2-Body
....

and my mysql query looks like

select A.id,B.infield, A.body from A inner join B on A.id=B.id;

and in schema.xml i have this

<field indexed="true" multiValued="true" name="infield" stored="true" type="string"/>

now when my query is * : *, i am supposed to get all infield like below

<str name="id">1</str>
<str name="body">Article1-Body</str>
<arr name="infield">    
   <str>ValX</str>
   <str>ValY</str>
   <str>ValZ</str>
</arr>

but i am getting this

<str name="id">1</str>
<str name="body">Article1-Body</str>
<arr name="infield">    
   <str>ValX</str>
</arr>

EDIT
my dataconfig.xml contains:

<?xml version="1.0" encoding="UTF-8"?>
<dataConfig>
  <dataSource autoCommit="true" batchSize="-1" convertType="true" driver="com.mysql.jdbc.Driver" password="pass" url="jdbc:mysql://127.0.0.1/test" user="root"/>
  <document name="items">
    <entity name="root" pk="id" preImportDeleteQuery="data_source:10" query="select A.id,B.infield, A.body from A inner join B on A.id=B.id;" transformer="TemplateTransformer">
      <field column="data_source" template="10"/>
      <field column="data_source_type" template="Jdbc"/>
      <field column="data_source_name" template="Test"/>
    </entity>
  </document>
</dataConfig>

any idea what might be wrong?
Thanks

È stato utile?

Soluzione

The query probably produces multiple records with the same id and hence the separate/individual records are getting overridden as they have the same id.
So you end up with just one infield value.
For multivalued fields you should include it as a sub entity which returns multiple values.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top