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
-------------
With the above query, I get the following record as the output
Empid: 2
Name: George
Grade Name: MBA
Grade: A

Note that, I dont get Emp with empid: 1 as the qualification is MBA
and has grade B only.

I would like to get this done through SOLR.

Note that, I have simplified my problem using emp and qualification
tables so that its easy to understand.

Once I configured the Schema.xml and data-config.xml, I was able to
index the employee and qualification and the
I have an entity structure generated by SOLR like this

<doc>
<str name="empname"> John<./str>
<str name="location">California </str>

<arr name="gradenames">
<str> MBA</str>
<str> LEAD</str>
</arr>

<arr name="grade">
<str> A</str>
<str> B</str>
</arr>
</doc>

<doc>
<str name="empname"> George<./str>
<str name="location">Nevada</str>

<arr name="gradenames">
<str> MBA</str>
<str> Graduate</str>
</arr>

<arr name="grade">
<str> A</str>
<str> C</str>
</arr>
</doc>

As you see in the above structure, the relation between qualifications
are lost. The linkage between MBA and  its corresponding Grade is
lost. So IF I do a search with Grade Name MBA and Grade as A, both the
docs will be returned.  This is incorrect data for me.

Is there a way by which I can get relation between the child entity
elements. In short how do I get the result as shown in the SQL above?

The answer probably is in the document or entity that is getting generated.

If the entity is as below, it might fix the same

<doc>
<str name="empname"> George<./str>
<str name="location">Nevada</str>

<arr name="gradename">
<str> MBA</str>
</arr>
<arr name="grade">
<str> A</str>
</doc>

<doc>
<str name="empname"> George<./str>
<str name="location">Nevada</str>

<arr name="gradename">
<str> graduate</str>
</arr>
<arr name="grade">
<str> C</str>
</doc>

Then, when I search, it will show one doc only.

Thanks
Viju

Reply via email to