0
votes

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

1
What does the document posted to solr (for indexing) look like?d whelan
Not sure if i got your question correctly,, but i am indexing mysql tables for articles and here infield represents the category of the article itselfAlaa
@dwhelan : I have edited the question as well... i hope it is clearer nowAlaa
Can you show us your data-config.xml? Do you have nested entities or just one?javanna
@javanna : Question has been edited... please adviseAlaa

1 Answers

2
votes

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.