You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@lucene.apache.org by Khurram Shehzad <kh...@live.com> on 2018/04/10 08:44:08 UTC

Lucene nested query

Hi guys!


I've a scenario where the lucene query depends on the result of another lucene query.


For example, find all the employees of the department where one of its employee's email address = 'abc@email.com'


SQL would be like:


select * from employee where dept_no in(

select dept_no from employee where email = 'abc@email.com'

)


Please note that employee is a huge data and inner query can result into 5 million rows


Any thoughts how to replicate this scenario using core lucene?


Regards,

Khurram

Re: Lucene nested query

Posted by Rob Audenaerde <ro...@gmail.com>.
Your query can be seen as an inner join:

select t0.* from employee t0 inner join employee t1 on t0.dept_no =
t1.dept_no where t1.email='abc@email.com'

Maybe JoinUtill can help you.

http://lucene.apache.org/core/7_0_0/join/org/apache/lucene/search/join/JoinUtil.html?is-external=true

On Tue, Apr 10, 2018 at 10:44 AM, Khurram Shehzad <kh...@live.com>
wrote:

> Hi guys!
>
>
> I've a scenario where the lucene query depends on the result of another
> lucene query.
>
>
> For example, find all the employees of the department where one of its
> employee's email address = 'abc@email.com'
>
>
> SQL would be like:
>
>
> select * from employee where dept_no in(
>
> select dept_no from employee where email = 'abc@email.com'
>
> )
>
>
> Please note that employee is a huge data and inner query can result into 5
> million rows
>
>
> Any thoughts how to replicate this scenario using core lucene?
>
>
> Regards,
>
> Khurram
>