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 Manali Joshi <jo...@gmail.com> on 2010/08/11 20:54:19 UTC

Data Import Handler Query

Hi,



I have installed solr 1.4 and am trying to use the Data Import Handler to
import data from a database. I have 2 tables which share a 1 to many
relation (1 Story to Many Images).



I want my index to contain attributes regarding “Story” and also all
“Images” that it has. Based on the DIH documentation, I have setup the
data-config.xml as follows:



<document>

     <entity name=*"story"*

                  query=*"select story_id, user_id, time, attach from story"
*

                  deltaImportQuery=*"select story_id, user_id, time, attach
from story where time > '${dataimporter.last_index_time}'"*

                deltaQuery=*"select story_id from story where time >
'${dataimporter.last_index_time}'"*>





           <entity name=*"image"*

                    query=*"select filename, filepath, type from images
where story_id='${story.story_id}'"*

                    parentDeltaQuery=*"select story_id from story where
story_id=${image.story_id}"*>

           </entity>



      </entity>

</document>



However, when I query the index, I find that it imports only the first
record from images that it finds for a story. Eg. If I have a story with 3
images, the index only has information about the first one. Is it possible
to get the data for all images for a story in the same index. If so, what am
I missing in the data config ?



Thanks.

Re: Data Import Handler Query

Posted by Manali Joshi <jo...@gmail.com>.
Thanks Alexey. That solved the issue. I am now able to get all images
information in the index.

On Thu, Aug 12, 2010 at 12:47 AM, Alexey Serba <as...@gmail.com> wrote:

> Try to define image solr fields <-> db columns mapping explicitly in
> "image" entity, i.e.
>
> <entity name="image" query="select filename, filepath, type from
> images where story_id='${story.story_id}'" >
>     <field column="filename" name="filename" />
>    <field column="filepath" name="filepath" />
>    <field column="type" name="type" />
> </entity>
>
> See
> http://www.lucidimagination.com/search/document/c8f2ed065ee75651/dih_and_multivariable_fields_problems
>
> On Thu, Aug 12, 2010 at 2:30 AM, Manali Joshi <jo...@gmail.com>
> wrote:
> > I tried making the schema fields that get the image data to
> > multiValued="true". But it still gets only the first image data. It
> doesn't
> > have information about all the images.
> >
> >
> >
> >
> > On Wed, Aug 11, 2010 at 1:15 PM, kenf_nc <ke...@realestate.com>
> wrote:
> >
> >>
> >> It may not be the data config. Do you have the fields in the schema.xml
> >> that
> >> the image data is going to set to be multiValued="true"?
> >>
> >> Although, I would think the last image would be stored, not the first,
> but
> >> haven't really tested this.
> >> --
> >> View this message in context:
> >>
> http://lucene.472066.n3.nabble.com/Data-Import-Handler-Query-tp1092010p1092917.html
> >> Sent from the Solr - User mailing list archive at Nabble.com.
> >>
> >
>

Re: Data Import Handler Query

Posted by Alexey Serba <as...@gmail.com>.
Try to define image solr fields <-> db columns mapping explicitly in
"image" entity, i.e.

<entity name="image" query="select filename, filepath, type from
images where story_id='${story.story_id}'" >
    <field column="filename" name="filename" />
    <field column="filepath" name="filepath" />
    <field column="type" name="type" />
</entity>

See http://www.lucidimagination.com/search/document/c8f2ed065ee75651/dih_and_multivariable_fields_problems

On Thu, Aug 12, 2010 at 2:30 AM, Manali Joshi <jo...@gmail.com> wrote:
> I tried making the schema fields that get the image data to
> multiValued="true". But it still gets only the first image data. It doesn't
> have information about all the images.
>
>
>
>
> On Wed, Aug 11, 2010 at 1:15 PM, kenf_nc <ke...@realestate.com> wrote:
>
>>
>> It may not be the data config. Do you have the fields in the schema.xml
>> that
>> the image data is going to set to be multiValued="true"?
>>
>> Although, I would think the last image would be stored, not the first, but
>> haven't really tested this.
>> --
>> View this message in context:
>> http://lucene.472066.n3.nabble.com/Data-Import-Handler-Query-tp1092010p1092917.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
>>
>

Re: Data Import Handler Query

Posted by Manali Joshi <jo...@gmail.com>.
I tried making the schema fields that get the image data to
multiValued="true". But it still gets only the first image data. It doesn't
have information about all the images.




On Wed, Aug 11, 2010 at 1:15 PM, kenf_nc <ke...@realestate.com> wrote:

>
> It may not be the data config. Do you have the fields in the schema.xml
> that
> the image data is going to set to be multiValued="true"?
>
> Although, I would think the last image would be stored, not the first, but
> haven't really tested this.
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Data-Import-Handler-Query-tp1092010p1092917.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Data Import Handler Query

Posted by kenf_nc <ke...@realestate.com>.
It may not be the data config. Do you have the fields in the schema.xml that
the image data is going to set to be multiValued="true"?

Although, I would think the last image would be stored, not the first, but
haven't really tested this.
-- 
View this message in context: http://lucene.472066.n3.nabble.com/Data-Import-Handler-Query-tp1092010p1092917.html
Sent from the Solr - User mailing list archive at Nabble.com.