In general, you need to "flatten" relational tables.

In this specific case, I see two choices:

1. Add a "customer_id" field to your contacts for the customer's id. The id field for a contact would need to be a unique id such as the concatenation of the customer id and the contact id. You can then query all contacts for a specified customer id.
2. Add "phone_number" as a multi-valued field for each customer.

The latter seems a little more compelling, for this specific example.

-- Jack Krupansky

-----Original Message----- From: Andre Lopes
Sent: Sunday, August 05, 2012 7:47 AM
To: solr-user@lucene.apache.org
Subject: How to configure schema.xml to take in account two database tables?

Hi,

I'm new to Solr. I've take some reads about how it works, but I can't
find a clue for my specific situation.

Here is my case. I've 2 database tables that I need to add to the
index, but they are related. One entry in the table "clients" could
have more than one entry in the table "contacts". Here is the visual
example:

Table clients:

id | name        | description
1  | customer 1  | This is the description of customer 1
2  | customer 2  | This is the description of customer 2
3  | customer 3  | This is the description of customer 3
4  | customer 4  | This is the description of customer 4

Table contacts:

id | phone_number
1  | 921234567
1  | 932122345
2  | 934545444
3  | 943322345
3  | 343445545
3  | 213443435

I think the case is simple. If in a search I input "921234567" I must
to present information about "customer 1".

My question... How can I setup the schema.xml in a way that I will
take in account this two database tables?


Best Regards,

Reply via email to