I have this situation
Entity Company_id
-----------------
E001 1
E001 2
E003 1
E002 2
E001 3
E003 3
I want to know how much companies that have entities (E001 and E003) in this case the result should be company 1 and 3.
In SQL it can be resolved by making a nested query but I should use something like luncene because of performance needs this query will be executed more that 50 times for each page.
Note : I can have to restrict on 3 or 4 entities also ex : all companies that have (E001 AND E002 AND E003 AND 3004).
Any help will be appreciated
EDIT I know that lucene is made for text search but let's suppose that each row is a Document in the index.