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 Stefan Matheis <ma...@googlemail.com> on 2011/03/01 09:41:56 UTC

Re: Sub entities

Brian,

except for your sql-syntax error in the specie_relations-query "SELECT
specie_id FROMspecie_relations .." (missing whitespace after FROM)
your config looks okay.

following questions:
* is there a field named specie in your schema? (otherwise dih will
silently ignore it)
* did you check your mysql-query log? to see which queries were
executed and what their result is?

And, just as quick notice .. there is no need to use <field
column="foo" name="foo"> (while both attribute have the same value).

Regards
Stefan

On Mon, Feb 28, 2011 at 9:52 PM, Brian Lamb
<br...@journalexperts.com> wrote:
> Hi all,
>
> I was able to get my dataimport to work correctly but I'm a little unclear
> as to how the entity within an entity works in regards to search results.
> When I do a search for all results, it seems only the outermost responses
> are returned. For example, I have the following in my db config file:
>
> <dataConfig>
>  <dataSource type="JdbcDataSource" name="mystuff" batchSize="-1"
> driver="com.mysql.jdbc.Driver"
> url="jdbc:mysql://localhost/db?characterEncoding=UTF8&amp;zeroDateTimeBehavior=convertToNull"
> user="user" password="password"/>
>    <document>
>      <entity name="animal" dataSource="mystuff" query="SELECT * FROM
> animals">
>        <field column="id" name="id" />
>        <field column="type" name="type" />
>        <field column="genus" name="genus" />
>
>        <!-- Add in the species -->
>        <entity name="specie_relations" dataSource="mystuff" query="SELECT
> specie_id FROMspecie_relations WHERE animal_id=${animal.id}">
>          <entity name="species" dataSource="mystuff" query="SELECT specie
> FROM species WHERE id=${specie_relations.specie_id}">
>            <field column="specie" name="specie" />
>          </entity>
>        </entity>
>      </entity>
>    </document>
>  </dataSource>
> </dataConfig>
>
> However, specie never shows up in my search results:
>
> <doc>
>  <str name="type">Mammal</str>
>  <str name="id">1</str>
>  <str name="genus">Canis</str>
> </doc>
>
> I had hoped the results would include the species. Can it? If so, what is my
> malfunction?
>

Re: Sub entities

Posted by "remi.vanb" <re...@gmail.com>.
Hello,

I had the same problem, only the first result was indexed in the sub-entity,
but was solved by setting the 'multiValued' attribute to "true" on the field
in schema.xml


--
View this message in context: http://lucene.472066.n3.nabble.com/Sub-entities-tp2598369p2837723.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Sub entities

Posted by Brian Lamb <br...@journalexperts.com>.
Thanks for the help Stefan. It seems removing column="specie" fixed it.

On Tue, Mar 1, 2011 at 11:18 AM, Stefan Matheis <
matheis.stefan@googlemail.com> wrote:

> Brian,
>
> On Tue, Mar 1, 2011 at 4:52 PM, Brian Lamb
> <br...@journalexperts.com> wrote:
> > <field column="specie" multiValued="true" name="specie" type="string"
> > indexed="true" stored="true" required="false" />
>
> Not sure, but iirc <field> in this context has no column-Attribute ..
> that should normally not break your solr-configuration.
>
> Are you sure, that your animal has multiple species assigned? Checked
> the Query from the MySQL-Query-Log and verified that it returns more
> than one record?
>
> Otherwise you could enable
> http://wiki.apache.org/solr/DataImportHandler#LogTransformer for your
> dataimport, which outputs a log-row for every record .. just to
> ensure, that your Query-Results is correctly imported
>
> HTH, Regards
> Stefan
>

Re: Sub entities

Posted by Stefan Matheis <ma...@googlemail.com>.
Brian,

On Tue, Mar 1, 2011 at 4:52 PM, Brian Lamb
<br...@journalexperts.com> wrote:
> <field column="specie" multiValued="true" name="specie" type="string"
> indexed="true" stored="true" required="false" />

Not sure, but iirc <field> in this context has no column-Attribute ..
that should normally not break your solr-configuration.

Are you sure, that your animal has multiple species assigned? Checked
the Query from the MySQL-Query-Log and verified that it returns more
than one record?

Otherwise you could enable
http://wiki.apache.org/solr/DataImportHandler#LogTransformer for your
dataimport, which outputs a log-row for every record .. just to
ensure, that your Query-Results is correctly imported

HTH, Regards
Stefan

Re: Sub entities

Posted by Brian Lamb <br...@journalexperts.com>.
Yes, it looks like I had left off the field (misspelled it actually). I
reran the full import and the fields did properly show up. However, it is
still not working as expected. Using the example below, a result returned
would only list one specie instead of a list of species. I have the
following in my schema.xml file:

<field column="specie" multiValued="true" name="specie" type="string"
indexed="true" stored="true" required="false" />

I reran the fullimport but it is still only listing one specie instead of
multiple. Is my above declaration incorrect?

On Tue, Mar 1, 2011 at 3:41 AM, Stefan Matheis <
matheis.stefan@googlemail.com> wrote:

> Brian,
>
> except for your sql-syntax error in the specie_relations-query "SELECT
> specie_id FROMspecie_relations .." (missing whitespace after FROM)
> your config looks okay.
>
> following questions:
> * is there a field named specie in your schema? (otherwise dih will
> silently ignore it)
> * did you check your mysql-query log? to see which queries were
> executed and what their result is?
>
> And, just as quick notice .. there is no need to use <field
> column="foo" name="foo"> (while both attribute have the same value).
>
> Regards
> Stefan
>
> On Mon, Feb 28, 2011 at 9:52 PM, Brian Lamb
> <br...@journalexperts.com> wrote:
> > Hi all,
> >
> > I was able to get my dataimport to work correctly but I'm a little
> unclear
> > as to how the entity within an entity works in regards to search results.
> > When I do a search for all results, it seems only the outermost responses
> > are returned. For example, I have the following in my db config file:
> >
> > <dataConfig>
> >  <dataSource type="JdbcDataSource" name="mystuff" batchSize="-1"
> > driver="com.mysql.jdbc.Driver"
> >
> url="jdbc:mysql://localhost/db?characterEncoding=UTF8&amp;zeroDateTimeBehavior=convertToNull"
> > user="user" password="password"/>
> >    <document>
> >      <entity name="animal" dataSource="mystuff" query="SELECT * FROM
> > animals">
> >        <field column="id" name="id" />
> >        <field column="type" name="type" />
> >        <field column="genus" name="genus" />
> >
> >        <!-- Add in the species -->
> >        <entity name="specie_relations" dataSource="mystuff" query="SELECT
>  > specie_id FROM specie_relations WHERE animal_id=${animal.id}">
> >          <entity name="species" dataSource="mystuff" query="SELECT specie
> > FROM species WHERE id=${specie_relations.specie_id}">
> >            <field column="specie" name="specie" />
> >          </entity>
> >        </entity>
> >      </entity>
> >    </document>
> >  </dataSource>
> > </dataConfig>
> >
> > However, specie never shows up in my search results:
> >
> > <doc>
> >  <str name="type">Mammal</str>
> >  <str name="id">1</str>
> >  <str name="genus">Canis</str>
> > </doc>
> >
> > I had hoped the results would include the species. Can it? If so, what is
> my
> > malfunction?
> >
>