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/03 21:05:34 UTC

DIH, assigning multiple xpaths to the same solr field

Hello all,

Inside my DIH data-config.xml file I really wish to use an xpath
expression along the lines of "//para". However this is not allowed
so for the moment I am explicitly listing each of the different 
xpaths and assigning them to a single solr field as follows:-

   <entity name="x"
      dataSource="myfilereader"
      processor="XPathEntityProcessor"
      url="${jc.fileAbsolutePath}"
      stream="false"
      forEach="/record">
   <field column="para"             xpath="/record/sect1/para" />
   <field column="para"             xpath="/record/list/listitem/para" />
   <field column="para"             xpath="/a/b/c/para" />
   <field column="para"             xpath="/d/e/f/g/para" />
 
Below is the line from my schema.xml

   <field name="para" type="text" indexed="true"  stored="true"  multiValued="true"/>

Now a given document will only have one style of layout, and of course
the /a/b/c /d/e/f/g  stuff is made up. For a document that has a single
<para>Hello world</para> element I see search results as follows, the
one <para> string seems to have been entered into the index four times.
I only saw duplicate results before adding the extra made-up stuff.

<arr name="para">
<str>Hello world</str>
<str>Hello world</str>
<str>Hello world</str>
<str>Hello world</str>
</arr>

I suspect this could be another DIH bug. Should this be entered into JIRA
or am I doing something wrong?

Regards Fergus.
-- 

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

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

Re: DIH, assigning multiple xpaths to the same solr field: solved

Posted by Fergus McMenemie <fe...@twig.me.uk>.
Thanks Shalin,

Using the following appears to work properly!
   <field column="para1"   name="para"   xpath="/record/sect1/para" />
   <field column="para2"   name="para"   xpath="/record/list/listitem/para" />
   <field column="para3"   name="para"   xpath="/a/b/c/para" />
   <field column="para4"   name="para"   xpath="/d/e/f/g/para" />

Regards Fergus

>On Wed, Feb 4, 2009 at 1:35 AM, Fergus McMenemie <fe...@twig.me.uk> wrote:
>
>>   <entity name="x"
>>      dataSource="myfilereader"
>>      processor="XPathEntityProcessor"
>>      url="${jc.fileAbsolutePath}"
>>      stream="false"
>>      forEach="/record">
>>   <field column="para"             xpath="/record/sect1/para" />
>>   <field column="para"             xpath="/record/list/listitem/para" />
>>   <field column="para"             xpath="/a/b/c/para" />
>>   <field column="para"             xpath="/d/e/f/g/para" />
>>
>> Below is the line from my schema.xml
>>
>>   <field name="para" type="text" indexed="true"  stored="true"
>>  multiValued="true"/>
>>
>> Now a given document will only have one style of layout, and of course
>> the /a/b/c /d/e/f/g  stuff is made up. For a document that has a single
>> <para>Hello world</para> element I see search results as follows, the
>> one <para> string seems to have been entered into the index four times.
>> I only saw duplicate results before adding the extra made-up stuff.
>>
>>
>I think there is something fishy with the XPathEntityProcessor. For now, I
>think you can work around by giving each field a different 'column' and
>attribute 'name=para' on each of them.
>
>-- 
>Regards,
>Shalin Shekhar Mangar.

-- 

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

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

Re: DIH, assigning multiple xpaths to the same solr field

Posted by Noble Paul നോബിള്‍ नोब्ळ् <no...@gmail.com>.
it is safe to use different column names as Shalin suggested. After
all a row is a map with the column value as the key. If you map
multiple values to the same column it may overwrite each other. use
explicit 'name' attributes

On Wed, Feb 4, 2009 at 2:17 AM, Shalin Shekhar Mangar
<sh...@gmail.com> wrote:
> On Wed, Feb 4, 2009 at 1:35 AM, Fergus McMenemie <fe...@twig.me.uk> wrote:
>
>>   <entity name="x"
>>      dataSource="myfilereader"
>>      processor="XPathEntityProcessor"
>>      url="${jc.fileAbsolutePath}"
>>      stream="false"
>>      forEach="/record">
>>   <field column="para"             xpath="/record/sect1/para" />
>>   <field column="para"             xpath="/record/list/listitem/para" />
>>   <field column="para"             xpath="/a/b/c/para" />
>>   <field column="para"             xpath="/d/e/f/g/para" />
>>
>> Below is the line from my schema.xml
>>
>>   <field name="para" type="text" indexed="true"  stored="true"
>>  multiValued="true"/>
>>
>> Now a given document will only have one style of layout, and of course
>> the /a/b/c /d/e/f/g  stuff is made up. For a document that has a single
>> <para>Hello world</para> element I see search results as follows, the
>> one <para> string seems to have been entered into the index four times.
>> I only saw duplicate results before adding the extra made-up stuff.
>>
>>
> I think there is something fishy with the XPathEntityProcessor. For now, I
> think you can work around by giving each field a different 'column' and
> attribute 'name=para' on each of them.
>
> --
> Regards,
> Shalin Shekhar Mangar.
>



-- 
--Noble Paul

Re: DIH, assigning multiple xpaths to the same solr field

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
On Wed, Feb 4, 2009 at 1:35 AM, Fergus McMenemie <fe...@twig.me.uk> wrote:

>   <entity name="x"
>      dataSource="myfilereader"
>      processor="XPathEntityProcessor"
>      url="${jc.fileAbsolutePath}"
>      stream="false"
>      forEach="/record">
>   <field column="para"             xpath="/record/sect1/para" />
>   <field column="para"             xpath="/record/list/listitem/para" />
>   <field column="para"             xpath="/a/b/c/para" />
>   <field column="para"             xpath="/d/e/f/g/para" />
>
> Below is the line from my schema.xml
>
>   <field name="para" type="text" indexed="true"  stored="true"
>  multiValued="true"/>
>
> Now a given document will only have one style of layout, and of course
> the /a/b/c /d/e/f/g  stuff is made up. For a document that has a single
> <para>Hello world</para> element I see search results as follows, the
> one <para> string seems to have been entered into the index four times.
> I only saw duplicate results before adding the extra made-up stuff.
>
>
I think there is something fishy with the XPathEntityProcessor. For now, I
think you can work around by giving each field a different 'column' and
attribute 'name=para' on each of them.

-- 
Regards,
Shalin Shekhar Mangar.