The schema content that I have put in is

   <field name="EMPID" type="integer" indexed="true" stored="true"
required="true" multiValued="false" />
   <field name="empname" type="string" indexed="true" stored="true" />
   <field name="gradeid" type="integer" indexed="true" stored="true"/>
   <field name="gradename" type="string" indexed="true" stored="true"/>
   <field name="grade" type="string" indexed="true" stored="true"/>
 <uniqueKey>EMPID</uniqueKey>

The dataconfig file is
<document>
        <entity name="employee" query="select * from employee">
            <entity name="qualification"  query="select * from
qualification where empid='${employee.EMPID}'"/>
        </entity>
    </document>

With this as well, when I try, I get the entity as below -
<result name="response" numFound="3" start="0">
<doc>
<int name="EMPID">3</int><str name="empname">Viktor</str></doc>
<doc><int name="EMPID">2</int>
<str name="empname">George</str>
<str name="grade">C</str>
<int name="gradeid">4</int>
<str name="gradename">PM</str></doc>
<doc><int name="EMPID">1</int><str name="empname">John</str>
<str name="grade">B</str><int name="gradeid">2</int><str
name="gradename">LEAD</str>
</doc>

The issue is that, employee George has 2 qualifications but is not
shown in the result. This is due to unique id I believe. Can you
provide some help?



On Fri, Oct 26, 2012 at 8:46 PM, Gora Mohanty <g...@mimirtech.com> wrote:
> On 25 October 2012 23:48, v vijith <vvij...@gmail.com> wrote:
>> Dear All,
>>
>> Apologize for lengthy email ....
>>
>> SOLR Version: 4
>>
>> Im a newbie to SOLR and have gone through tutorial but could not get a
>> solution. The below requirement doesnt seem to be impossible but I
>> think Im missing the obvious.
>>
>> In my RDBMS, there is a Qualification table and an Employee table. An
>> employee can have many qualifications. The qualification can have
>> following attributes - GradeName and Grade. The search using sql query
>> to achieve my requirement is as below
>>
>> select * from qualification a, employee b where a.empid= b.empid and
>> a.gradename='MBA' and b.grade='A';
>>
>> This will return me the employee along with the dept who has the grade
>> as MBA and has grade of A.
>>
>> Employee: 2 records
>> -------------------------
>> Empid: 1
>> Name: John
>> Location: California
>>
>> Qualifications:
>> Gradeid: 1
>> Empid: 1
>> Name: MBA
>> Grade: B
>>
>> Gradeid: 2
>> Empid: 1
>> Name: LEAD
>> Grade: A
>> --------------------
>>
>> Empid: 2
>> Name: George
>> Location: Nevada
>>
>> Qualifications:
>> Gradeid: 3
>> Empid: 2
>> Name: MBA
>> Grade: A
>>
>> Gradeid: 4
>> Empid: 2
>> Name: Graduate
>> Grade: C
>
> Stop thinking of Solr in terms of RDBMS. Instead, flatten out your
> data. Thus, in your example, you could have a schema with the
> following fields:
> doc_id name location qualification grade
> doc_id is a unique identifier for Solr. If you want to retain Empid
> and Gradeid you could also add these.
>
> and the following entries
> 1 John California MBA B
> 2 John California Lead A
> 3 George Nevada MBA A
> 4 George Nevada Graduate C
>
> Searching for qualification:MBA and grade:A will then give you only
> record 3.
>
> Regards,
> Gora

Reply via email to