Warning: I haven't tried this, but maybe it's relevant.
See: http://wiki.apache.org/solr/DataImportHandler
<http://wiki.apache.org/solr/DataImportHandler>particularly the "multiple
datasources" section. I'm thinking here that you have to
define a different data source for each separate table you want to extract.

Stefan's comments about using a transformer to make unique unique-ids per
table
seems spot on for that part of the problem....

Best
Erick

On Mon, Dec 13, 2010 at 9:31 AM, Jaakko Rajaniemi
<romu.mutt...@kolumbus.fi>wrote:

> Hello,
>
> Alright, let's describe the situation. I have a website and the website has
> a database with at least three tables.
>
> - "users" table  - (id, firstname, lastname)
> - "artwork" table  - (id, user, name, description)
> - "jobs" table  - (id, company, position, location, description)
>
> I want to implement a multi-purpose search field. I want the search field
> to treat rows from each of these tables as independent results. For example
> if I type "Paris", an example result set might look like a list of links
> like this:
>
> - Paris Hilton (from the "users" table)
> - A day in Paris (from the "artwork" table)
> - My Paris (from the "artwork" table)
> - Art teacher (from the "jobs" table if the location is Paris)
>
> I tried to search for solution for this on the Internet and found a
> somewhat similar thread floating on this mailing list, but I just couldn't
> understand it and the Solr documentation has its main focus on syntax, not
> implementation. I figured I would create three entities and relevant
> schema.xml entries in this way:
>
> dataimport.xml:
> <entity name="Users" query="select id,firstname,lastname from
> user"></entity>
> <entity name="Artwork" query="select id,user,name,description from
> artwork"></entity>
> <entity name="Jobs" query="select id,company,position,location,description
> from jobs"></entity>
>
> schema.xml:
> <field name="id" type="int" indexed="true" stored="true" required="true"/>
> <field name="firstname" type="string" indexed="true" stored="true"/>
> <field name="lastname" type="string" indexed="true" stored="true"/>
> <field name="user" type="int" indexed="true" stored="true"/>
> <field name="name" type="string" indexed="true" stored="true"/>
> <field name="description" type="text" indexed="true" stored="false"/>
> <field name="company" type="string" indexed="true" stored="true"/>
> <field name="position" type="string" indexed="true" stored="true"/>
> <field name="location" type="string" indexed="true" stored="false"/>
>
> This obviously does not work as I want. I only get results from the "users"
> table, and I cannot get results from neither "artwork" nor "jobs". I have
> found out that the possible solution is in putting <field> tags in the
> <entity> tag and somehow aliasing column names for Solr, but the logic
> behind this is completely alien to me and the blind tests I tried did not
> yield anything. My logic says that the "id" field is getting replaced by the
> "id" field of other entities and indexes are being overwritten. But if I
> aliased all "id" fields in all entities into something else, such as
> "user_id" and "job_id", I couldn't figure what to put in the <primaryKey>
> configuration in schema.xml because I have three different id fields from
> three different tables that are all primary keyed in the database!
>
> Obviously I'm not quite on track so some help would be greatly appreciated.
> Thanks!
> - Jaakko
>

Reply via email to