You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Fergus McMenemie <fe...@twig.me.uk> on 2009/02/12 14:14:26 UTC

Is this DIH entity forEach expression OK?

Hello,

I am having bother with forEach. I have XML source documents containing
many embedded images within mediaBlock elements. Each image has a an
associated caption. I want to implement a separate image search function
which searches the captions and brings back the associated image.

 <entity name="x"
    dataSource="myfilereader"
    processor="XPathEntityProcessor"
    url="${jc.fileAbsolutePath}"
    stream="false"
    forEach="/record | /record/mediaBlock"
    >

 <field column="vurl"                             xpath="/record/mediaBlock/mediaObject/@vurl" />
 <field column="imgCpation"                       xpath="/record/mediaBlock/caption"  />

Is is OK to have an xpath expression within forEach which is a child 
of another of the forEach xpath expressions?

Or.. is there a better way of doing this?

Regards
-- 

===============================================================
Fergus McMenemie               Email:fergus@twig.me.uk
Techmore Ltd                   Phone:(UK) 07721 376021

Unix/Mac/Intranets             Analyst Programmer
===============================================================

Re: Is this DIH entity forEach expression OK?

Posted by Noble Paul നോബിള്‍ नोब्ळ् <no...@gmail.com>.
forEach="/record | /record/mediaBlock" is likely to have problem .
This causes inconsistencies anyway because this is supposed to give
callbacks with same data.

you can definitely write a transformer which gives out multiple rows
if a record contains  /record/mediaBlock. the return value of a
transformer can be a Map<String, Object> or a List<Map<String,
Object>>. In the second case it can create multiple rows for each
incoming row
--Noble


On Thu, Feb 12, 2009 at 6:44 PM, Fergus McMenemie <fe...@twig.me.uk> wrote:
> Hello,
>
> I am having bother with forEach. I have XML source documents containing
> many embedded images within mediaBlock elements. Each image has a an
> associated caption. I want to implement a separate image search function
> which searches the captions and brings back the associated image.
>
>  <entity name="x"
>    dataSource="myfilereader"
>    processor="XPathEntityProcessor"
>    url="${jc.fileAbsolutePath}"
>    stream="false"
>    forEach="/record | /record/mediaBlock"
>    >
>
>  <field column="vurl"                             xpath="/record/mediaBlock/mediaObject/@vurl" />
>  <field column="imgCpation"                       xpath="/record/mediaBlock/caption"  />
>
> Is is OK to have an xpath expression within forEach which is a child
> of another of the forEach xpath expressions?
>
> Or.. is there a better way of doing this?
>
> Regards
> --
>
> ===============================================================
> Fergus McMenemie               Email:fergus@twig.me.uk
> Techmore Ltd                   Phone:(UK) 07721 376021
>
> Unix/Mac/Intranets             Analyst Programmer
> ===============================================================
>



-- 
--Noble Paul

Re: Is this DIH entity forEach expression OK? ... yes

Posted by Fergus McMenemie <fe...@twig.me.uk>.
>Hello,
>
>I am having bother with forEach. I have XML source documents containing
>many embedded images within mediaBlock elements. Each image has a an
>associated caption. I want to implement a separate image search function
>which searches the captions and brings back the associated image.
>
> <entity name="x"
>    dataSource="myfilereader"
>    processor="XPathEntityProcessor"
>    url="${jc.fileAbsolutePath}"
>    stream="false"
>    forEach="/record | /record/mediaBlock"
>    >
>
> <field column="vurl"                             xpath="/record/mediaBlock/mediaObject/@vurl" />
> <field column="imgCpation"                       xpath="/record/mediaBlock/caption"  />
>
>Is is OK to have an xpath expression within forEach which is a child 
>of another of the forEach xpath expressions?
>
Yes. It works fine, duplicate "uniqueKey"s were making it appear otherwise.

But....
-- 

===============================================================
Fergus McMenemie               Email:fergus@twig.me.uk
Techmore Ltd                   Phone:(UK) 07721 376021

Unix/Mac/Intranets             Analyst Programmer
===============================================================