Two answers: 1) Do you have maybe user names or timestamps for the comments? Usually people want those also. 2) You can store the comments as one long string, or as multiple entries in a field. Your database should have a concatenate function that will take field X from multiple documents in a join and make a long string. I would concatenate the comments into one string with a magic separator, and then just split them up in my application.
It is not simple to get multiple join results into one document. Here's how it works: a) Collect all of the results of 'comment' into one long string and use a unique character to separate them. This is your one document from your query. b) Use the RegexTransformer in the DIH to split the long string into several values. http://lucidworks.lucidimagination.com/display/solr/Uploading+Structured+Data+Store+Data+with+the+Data+Import+Handler On Sat, Oct 13, 2012 at 6:21 AM, Marvin <markus.pfeif...@ebcont-et.com> wrote: > Hi there! > I have 2 tables 'blog' and 'comment'. A blog can contains n comments (blog > --1:n-- comment). Up to date I use following select to insert the data into > solr index: > > <entity name="blog" dataSource="mssqlDatasource" pk="id" > transformer="ClobTransformer" > query="SELECT b.id, b.market, b.title AS blogTitle, b.message AS > blogMessage, c.message AS commentMessage > FROM blog b LEFT JOIN comment c ON b.id = c.source_id > AND c.source_type = 'blog'"> > <field column="blogMessage" name="blogMessage" clob="true" /> > <field column="commentMessage" name="commentMessage" clob="true" > /> > </entity> > > The index result looks like: > > <doc> > <str name="id">1</str> > <str name="market">12</str> > <str name="title">blog of title 1</str> > <str name="blogMessage">message of blog 1</str> > <str name="commentMessage">message of comment</str> > </doc> > > <doc> > <str name="id">1</str> > <str name="market">12</str> > <str name="title">blog of title 1</str> > <str name="blogMessage">message of blog 1</str> > <str name="commentMessage">message of comment - Im the second > comment</str> > </doc> > > I would say this is stupid because I got too many index data with the same > blog just the comments are different. Is it possible to set 'comments' as > 'subentity' like following: > > <entity name="blog" dataSource="mssqlDatasource" pk="id" > transformer="ClobTransformer" > query="SELECT b.id, b.market, b.title AS blogTitle, b.message AS > blogMessage > FROM blog b"> > <field column="blogMessage" name="blogMessage" clob="true" /> > > <entity name="comment" dataSource="mssqlDatasource" pk="id" > transformer="ClobTransformer" > query="SELECT c.id, c.message as commentMessage > FROM comment c > WHERE c.source_id = ${blog.id}"> > <field column="commentMessage" name="commentMessage" > clob="true" /> > </entity> > </entity> > > > Is that possible? > How would the result looks like (cant test it until monday)? > All example I found the "sub" entity just select 1 column but I need at > least 2. > > > > -- > View this message in context: > http://lucene.472066.n3.nabble.com/Solr-db-data-config-xml-general-asking-to-entity-tp4013533.html > Sent from the Solr - User mailing list archive at Nabble.com. -- Lance Norskog goks...@gmail.com