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 Adam Estrada <es...@gmail.com> on 2010/12/15 21:49:22 UTC

[Adding] Entities when indexing a DB

All,

I have successfully indexed a single entity but when I try multiple entities
is the second is skipped all together. Is there something wrong with my
config file?

<?xml version="1.0" encoding="utf-8" ?>
<dataConfig>
  <dataSource type="JdbcDataSource"
       driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
       url="jdbc:sqlserver://10.0.2.93;databaseName="50_DEV"
       user="adam"
       password="password"/>
  <document name="events">
    <entity datasource="MISSIONS"
    query = "SELECT IdMission AS id,
                    CoreGroup AS cat,
                    StrMissionname AS subject,
                    strDescription AS description,
                    DateCreated AS pubdate
                FROM dbo.tblMission">
      <field column="id" name="id" />
      <field column="cat" name="cat" />
      <field column="subject" name="subject" />
      <field column="description" name="description" />
      <field column="pubdate" name="date" />
    </entity>
    <entity datasource="EVENTS"
     query = "SELECT strsubject AS subject,
                strsummary as description,
                datecreated as date,
                CoreGroup as cat,
                idevent as id
                FROM dbo.tblEvent">
      <field column="id" name="id" />
      <field column="cat" name="cat" />
      <field column="subject" name="subject" />
      <field column="description" name="description" />
      <field column="pubdate" name="date" />
    </entity>
  </document>
</dataConfig>

Re: [Adding] Entities when indexing a DB

Posted by Adam Estrada <es...@gmail.com>.
Ahhh...I found that I did not set a dataSource name and when I did that and
then referred each entity to that dataSource all went according to plan ;-)

<?xml version="1.0" encoding="utf-8" ?>
<dataConfig>
  <dataSource type="JdbcDataSource"
       name="bleh"
       driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
       url="jdbc:sqlserver://<server>;databaseName=50_DEV"
       user="adam"
       password="pw"/>
  <document>
    <entity name="Missions" dataSource="bleh"
    query = "SELECT (IdMission + 1000000) AS id,
                    idMission as missionid,
                    CoreGroup AS cat,
                    StrMissionname AS subject,
                    strDescription AS description,
                    DateCreated AS pubdate,
                    'Mission' AS cat2
                FROM dbo.tblMission">
      <field column="id" name="id" />
      <field column="missionid" name="missionid" />
      <field column="cat" name="cat" />
      <field column="cat2" name="cat2" />
      <field column="subject" name="subject" />
      <field column="description" name="description" />
      <field column="pubdate" name="date" />
    </entity>

    <entity name="Events" dataSource="bleh"
     query = "SELECT strsubject AS subject,
                strsummary as description,
                datecreated as date,
                CoreGroup as cat,
                idevent as id,
                'Event' AS cat2,
                IdEvent AS missionid
                FROM dbo.tblEvent">
      <field column="id" name="id" />
      <field column="missionid" name="missionid" />
      <field column="cat" name="cat" />
      <field column="cat2" name="cat2" />
      <field column="subject" name="subject" />
      <field column="description" name="description" />
      <field column="pubdate" name="date" />
    </entity>
  </document>
</dataConfig>

Solr Rocks!
Adam



On Wed, Dec 15, 2010 at 3:53 PM, Allistair Crossley <al...@roxxor.co.uk>wrote:

> mission.id and event.id if the same value will be overwriting the indexed
> document. your ids need to be unique across all documents. i usually have a
> field id_original that i map the table id to, and then for id per entity i
> usually prefix it with the entity name in the value mapped to the schema id
> field
>
> On 15 Dec 2010, at 20:49, Adam Estrada wrote:
>
> > All,
> >
> > I have successfully indexed a single entity but when I try multiple
> entities
> > is the second is skipped all together. Is there something wrong with my
> > config file?
> >
> > <?xml version="1.0" encoding="utf-8" ?>
> > <dataConfig>
> >  <dataSource type="JdbcDataSource"
> >       driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
> >       url="jdbc:sqlserver://10.0.2.93;databaseName="50_DEV"
> >       user="adam"
> >       password="password"/>
> >  <document name="events">
> >    <entity datasource="MISSIONS"
> >    query = "SELECT IdMission AS id,
> >                    CoreGroup AS cat,
> >                    StrMissionname AS subject,
> >                    strDescription AS description,
> >                    DateCreated AS pubdate
> >                FROM dbo.tblMission">
> >      <field column="id" name="id" />
> >      <field column="cat" name="cat" />
> >      <field column="subject" name="subject" />
> >      <field column="description" name="description" />
> >      <field column="pubdate" name="date" />
> >    </entity>
> >    <entity datasource="EVENTS"
> >     query = "SELECT strsubject AS subject,
> >                strsummary as description,
> >                datecreated as date,
> >                CoreGroup as cat,
> >                idevent as id
> >                FROM dbo.tblEvent">
> >      <field column="id" name="id" />
> >      <field column="cat" name="cat" />
> >      <field column="subject" name="subject" />
> >      <field column="description" name="description" />
> >      <field column="pubdate" name="date" />
> >    </entity>
> >  </document>
> > </dataConfig>
>
>

Re: [Adding] Entities when indexing a DB

Posted by Allistair Crossley <al...@roxxor.co.uk>.
mission.id and event.id if the same value will be overwriting the indexed document. your ids need to be unique across all documents. i usually have a field id_original that i map the table id to, and then for id per entity i usually prefix it with the entity name in the value mapped to the schema id field

On 15 Dec 2010, at 20:49, Adam Estrada wrote:

> All,
> 
> I have successfully indexed a single entity but when I try multiple entities
> is the second is skipped all together. Is there something wrong with my
> config file?
> 
> <?xml version="1.0" encoding="utf-8" ?>
> <dataConfig>
>  <dataSource type="JdbcDataSource"
>       driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
>       url="jdbc:sqlserver://10.0.2.93;databaseName="50_DEV"
>       user="adam"
>       password="password"/>
>  <document name="events">
>    <entity datasource="MISSIONS"
>    query = "SELECT IdMission AS id,
>                    CoreGroup AS cat,
>                    StrMissionname AS subject,
>                    strDescription AS description,
>                    DateCreated AS pubdate
>                FROM dbo.tblMission">
>      <field column="id" name="id" />
>      <field column="cat" name="cat" />
>      <field column="subject" name="subject" />
>      <field column="description" name="description" />
>      <field column="pubdate" name="date" />
>    </entity>
>    <entity datasource="EVENTS"
>     query = "SELECT strsubject AS subject,
>                strsummary as description,
>                datecreated as date,
>                CoreGroup as cat,
>                idevent as id
>                FROM dbo.tblEvent">
>      <field column="id" name="id" />
>      <field column="cat" name="cat" />
>      <field column="subject" name="subject" />
>      <field column="description" name="description" />
>      <field column="pubdate" name="date" />
>    </entity>
>  </document>
> </dataConfig>